Access last_sqlstate from libpq
От | Daniel Frey |
---|---|
Тема | Access last_sqlstate from libpq |
Дата | |
Msg-id | D0EA7D79-62C5-4733-B437-3A5C7C20746D@gmx.de обсуждение исходный текст |
Ответы |
Re: Access last_sqlstate from libpq
Re: Access last_sqlstate from libpq |
Список | pgsql-hackers |
Hi, I am the author of a PostgreSQL C++ client library, taoPQ (https://github.com/taocpp/taopq), wrapping the C-API of libpq. In case of an error when I received a PGresult*, I can access the SQLSTATE by calling PGresult* pgresult = ...; const char* sqlstate = PQresultErrorField( pgresult, PG_DIAG_SQLSTATE ); 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) Obviously, I can take the error message from PQerrorMessage and throw a generic runtime error - but it would be so much nicerif I could use the SQLSTATE to throw the correct exception class and give users more information just like I do forPGresult*. 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? Regards, Daniel
В списке pgsql-hackers по дате отправления: