Fix user.run_query exception handler for PostgreSQL 9.3

Closes #299