libpq: How to get the error code after a failed PGconn connection
От | Hello World |
---|---|
Тема | libpq: How to get the error code after a failed PGconn connection |
Дата | |
Msg-id | CAB8jeLmtrsH8Uo_VZnKSP_bThty37webO5igqr-mX=w3sGJxzA@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: libpq: How to get the error code after a failed PGconn connection
|
Список | pgsql-hackers |
<div dir="ltr"><div class="" itemprop="description">Given the following code.<br /><br />PGconn* const conn=PQconnectdbParams(keywords,values, false);<br />if(! conn || PQstatus(conn)!=CONNECTION_OK){ /* error code? */ }<br/><br /> - In case of a failed connection is there a way to get the error code to be able to distinguish between a (e.g.)bad password and the server being down.<br /><br />(I know I can get the error message, but I want to be able to reactto the cause of the error according to its cause, plus the error message is localized so I can't even scan that forkeywords such as "permission denied").<br /><br /></div><div class="" itemprop="description">ps. I've looked at how psqldoes it, and it seems it just prints the error message and exists.<br /><br />ps. I've tried to take a look at the sourcebut it seems it just sets the status to CONNECTION_BAD no matter the cause of error, then sets a specific error message.<br/><br />Any help appreciated.<br /></div><div class="" itemprop="description"><br />Thanks.</div></div>
В списке pgsql-hackers по дате отправления: