Re: Access last_sqlstate from libpq - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: Access last_sqlstate from libpq
Date
Msg-id CAKFQuwb+SoR3CtZcnsueoir0U5ozdis-o1MZP1+fLz-jozQGYQ@mail.gmail.com
Whole thread Raw
In response to Access last_sqlstate from libpq  (Daniel Frey <d.frey@gmx.de>)
Responses Re: Access last_sqlstate from libpq  (Daniel Frey <d.frey@gmx.de>)
List pgsql-hackers


On Friday, September 17, 2021, Daniel Frey <d.frey@gmx.de> wrote:

However, this is not possible in a couple of other cases where I don't have a PGresult*, only the PGconn* is available:

* PQconnectdb (and variants)

* PQputCopyData
* PQputCopyEnd
* PQgetCopyData

* lo_* (large object functions)

After some research, it appears that PGconn* does have a field called last_sqlstate - it just can't be accessed.
Are there any problems adding a simple accessor to libpq? Or is there some way to access it that I'm missing?

I suspect the reason for the omission is that there isn’t any usable data to be gotten.  Those interfaces are not SQL interfaces and thus do not have a relevant last_sqlstate to report.

David J.

pgsql-hackers by date:

Previous
From: Daniel Frey
Date:
Subject: Access last_sqlstate from libpq
Next
From: Alexander Korotkov
Date:
Subject: Re: postgres.h included from relcache.h - but removing it breaks pg_upgrade