Re: LibPQ: Lifetime of PGresult passed in to PQnoticeReceiver callback - Mailing list pgsql-general

From Dmitry Igrishin
Subject Re: LibPQ: Lifetime of PGresult passed in to PQnoticeReceiver callback
Date
Msg-id CAAfz9KP0nvwUA9Ux2vzioJM5F=6HG9yoUTEz2ovd+nDtrLbawA@mail.gmail.com
Whole thread Raw
In response to LibPQ: Lifetime of PGresult passed in to PQnoticeReceiver callback  (Dominique Devienne <ddevienne@gmail.com>)
List pgsql-general
пн, 13 дек. 2021 г. в 11:43, Dominique Devienne <ddevienne@gmail.com>:
>
> Hi,
>
> The doc at https://www.postgresql.org/docs/current/libpq-notice-processing.html is not clear to me on whether it
shouldbe PQclear'd or not. Who manages the lifetime of that PGresult? 
libpq. That PGresult cleared by libpq right after the calling back to
the notice receiver.

>
> Also, the "could be called as long as either the PGconn or PGresult exist" mention,
> implies we do not need to clear the notice callback before PQfinish'ing the connection.
> (and that does not seem possible, given passing in a NULL pointer is just a *get* it seems).
> Is that correct?
There is no need to reset neither the notice receiver nor notice
processor before the call of PQfinish().

>
> Yet we are seeing our notice callback being called with an invalid PGresult (i.e. crash accessing it).
> What could be the reasons for that? I'm assuming user-error in our code, but I don't see why yet.
Please, ensure that there's no call of PQfinish() while either the
notice receiver or notice processor is runned.
Also, if the notice receiver delegates processing to another thread
then the PGresult must be copied and cleared by the application after
done.

PS. Please, avoid the notice processor.



pgsql-general by date:

Previous
From: Dominique Devienne
Date:
Subject: Re: LibPQ: Lifetime of PGresult passed in to PQnoticeReceiver callback
Next
From: Dennis
Date:
Subject: