[Libpqxx-general] cancellation of synchronous sql statements
Jeroen T. Vermeulen
jtv at xs4all.nl
Thu Aug 20 05:19:05 UTC 2009
On Wed, August 19, 2009 00:07, Madden, Don (DCOR) wrote:
> If you execute commands (asynchronously) in a "pipeline", there is a
> public method to "cancel()" an ongoing query.
>
> If you execute the SQL commands in a blocking call, you could the
> cancel the ongoing command via a signal handler (e.g SIGALRM). lIbpq
> supports this via PQcancel(). "libpqxx" doesn't seem to have any
> equivalent public method. In the connection_base, the wrapper method,
> "cancel_query()" is private. Likewise I couldn't find any public method
> to get a raw libpq connection, PGConn in libpqxx's connection_base
> classes?
This sounds like a useful feature. I just made cancel_query public for
your use, and made the function try a bit harder to be graceful about
deactivated connections. See revision [1574]. It should work safely from
signal handlers; using it from other threads is safe for libpq versions
8.0 and up, but not before. (The thread-safety descriptions already knew
about this).
What this still needs is a good test. I'd be most grateful if you could
come up with one that fits in the test suite in test/unit/ !
Jeroen
More information about the Libpqxx-general
mailing list