On Oct 28, 2010, at 12:04 PM, Daniel Verite wrote:
> A.M. wrote:
>
>> In PostgreSQL, query canceling is implemented by opening a
>> second connection and passing specific data which is received
>> from the first connection
>
> With libpq's PQCancel(), a second connection is not necessary.
To clarify, PQcancel() opens a new socket to the backend and sends the cancel message. (The server's socket address is
passedas part of the cancel structure to PQcancel.)
http://git.postgresql.org/gitweb?p=postgresql.git;a=blob;f=src/interfaces/libpq/fe-connect.c;h=8f318a1a8cc5bf2d49b2605dd76581609cf9be32;hb=HEAD#l2964
The point is that a query can be cancelled from anywhere really and cancellation will not use the original connection
socket.
Cheers,
M