On Fri, August 10, 2007 23:50, Rob Lemley wrote: > I am interested in adding PQCancel (and friends) support to libpqxx. > > I've found one mention of it in the TODO > (http://pqxx.org/development/libpqxx/changeset/825) > but it seems to have been removed from the current TODO. > > Currently we use PQrequestCancel() to stop long running queries > when our application server (ie postgresql client) must shutdown. > > Before I go further, I was wondering anyone has insights > about using PQCancel (PQrequestCancel is deprecated), > and/or implementing a cancel function in libpqxx (presumably > as a member of the connection_base class).
Interesting idea. A "cancel" option could make sense in three places: 1. In connection_base for multi-threaded programs. This will take some careful thought about thread synchronization: what happens to lazyconnections that may be initialized concurrently with the cancel request, or worse, to asyncconnections? The implementation may have to figure out whether it's supposed to be canceling a connection attempt or a query. 2. In pipeline, the only place where arbitrary queries can be executed asynchronously. Here the worry is semantics: do you set a specific query to cancel, or just "whatever is going on"? 3. As a timeout option for connection_base::exec()! It may invite more cancellations than is really healthy, but it'd be a very user-friendly way to support realtime-ish behaviour. User interaction, for instance, is a very common realtime task. And of course there's the matter of transactions. Do you abort the transaction (if any)? What if you're not currently executing any queries so that the cancel is a no-op from the database's perspective? Do you abort, throw, ignore? Jeroen _______________________________________________ Libpqxx-general mailing list [email protected] http://gborg.postgresql.org/mailman/listinfo/libpqxx-general
