LibPQ: Lifetime of PGresult passed in to PQnoticeReceiver callback

From: Dominique Devienne <ddevienne(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: LibPQ: Lifetime of PGresult passed in to PQnoticeReceiver callback
Date: 2021-12-13 08:46:05
Message-ID: CAFCRh--W80S=gdFB34Oqt1Nh9hhQffoFh4vincooVbRj-M8nEQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

The doc at
https://www.postgresql.org/docs/current/libpq-notice-processing.html is not
clear to me on whether it should be PQclear'd or not. Who manages the
lifetime of that PGresult?

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?

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.

Thanks for any insights. --DD

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rainer Duffner 2021-12-13 09:50:04 Re: Postgresql + containerization possible use case
Previous Message Achilleas Mantzios 2021-12-13 08:29:10 Re: Postgresql + containerization possible use case