On Wed, 6 Mar 2024 at 19:22, Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:
> Docs: one bogus "that that".
will fix
> Did we consider having PQcancelConn() instead be called
> PQcancelCreate()?
Fine by me
> Also, the comment still says
> "Asynchronously cancel a query on the given connection. This requires
> polling the returned PGcancelConn to actually complete the cancellation
> of the query." but this is no longer a good description of what this
> function does.
will fix
> Why do we return a non-NULL pointer from PQcancelConn in the first three
> cases where we return errors? (original conn was NULL, original conn is
> PGINVALID_SOCKET, pqCopyPGconn returns failure) Wouldn't it make more
> sense to free the allocated object and return NULL? Actually, I wonder
> if there's any reason at all to return a valid pointer in any failure
> cases; I mean, do we really expect that application authors are going to
> read/report the error message from a PGcancelConn that failed to be fully
> created?
I think having a useful error message when possible is quite nice. And
I do think people will read/report this error message. Especially
since many people will simply pass it to PQcancelBlocking, whether
it's NULL or not. And then check the status, and then report the error
if the status was CONNECTION_BAD.
> but in any case we
> should set ->cancelRequest in all cases, not only after the first tests
> for errors.
makes sense
> I think the extra PGconn inside pg_cancel_conn is useless; it would be
> simpler to typedef PGcancelConn to PGconn in fe-cancel.c, and remove the
> indirection through the extra struct.
That sounds nice indeed. I'll try it out.
> We could move the definition of struct pg_cancel to fe-cancel.c. Nobody
> outside that needs to know that definition anyway.
will do