resolved issue 233, fixed session write handler for postgres backend.  Modified all database query functions to rethrow errors so that they can be used with transactions with rollback on error