Add support for query execution timeout

A new "statement_timeout" setting bails out if execution of a query hangs for more than the given number of milliseconds. The mechanism does not make use of the STATEMENT_TIMEOUT postgresql setting but rather implements a timeout on the client side, to deal with hangs due to (for example) a pgbouncer in the middle or whatever other pooler queue.

When timeout is reached the code simply closes the connection and throws an exception.

Addresses #632. Review welcome (the setting could maybe be called "query_timeout" to not confuse it with the postgresql setting)

\cc @springmeyer, @artemp, @abonnasseau
Yes, as long as getResult is non-const...
See 868d345122a9c4847219e0799b7d3014e6f05615