Re: Access last_sqlstate from libpq

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Daniel Frey <d(dot)frey(at)gmx(dot)de>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Access last_sqlstate from libpq
Date: 2021-09-17 23:45:25
Message-ID: CAKFQuwb+SoR3CtZcnsueoir0U5ozdis-o1MZP1+fLz-jozQGYQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Friday, September 17, 2021, Daniel Frey <d(dot)frey(at)gmx(dot)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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2021-09-17 23:51:09 Re: postgres.h included from relcache.h - but removing it breaks pg_upgrade
Previous Message Daniel Frey 2021-09-17 23:36:35 Access last_sqlstate from libpq