SQLSTATE of notice PGresult - Mailing list pgsql-hackers

From Dmitriy Igrishin
Subject SQLSTATE of notice PGresult
Date
Msg-id AANLkTinU2S2vuYryvZgYp+q3few_M7MJnUf9pRigEP4f@mail.gmail.com
Whole thread Raw
Responses Re: SQLSTATE of notice PGresult
List pgsql-hackers
Hey all,<br /><br />Accordingly to the documentation of libpq, SQLSTATE code field "is not localizable, and<br />is
alwayspresent.". But it seems, in some cases it isn't. E.g.<br /><br />  /* the main code */<br />  PGresult* res =
Pg::PQexec(conn,"select 1");<br />   Oid id = PQparamtype(res, 1);<br /><br />  /* the notice receiver */<br />  void
myNoticeReceiver(void*arg, const PGresult *res)<br />{<br />  /* Presents - "NOTICE" */<br />  const char* severity =
Pg::PQresultErrorField(res,PG_DIAG_SEVERITY);<br /><br />  /* NOT presents - NULL. Why not "00000" ? */<br />  const
char*sqlstate = Pg::PQresultErrorField(res, PG_DIAG_SQLSTATE);<br /><br />  /* Presents - "parameter number 1 is out of
range0..-1" */<br />  const char* primary = Pg::PQresultErrorField(res, PG_DIAG_MESSAGE_PRIMARY);<br /> }<br /><br
/>So,SQLSTATE field is not always presents.<br /><br />Regards,<br />Dmitriy<br /> 

pgsql-hackers by date:

Previous
From: Magnus Hagander
Date:
Subject: Re: Fw: patch for pg_ctl.c to add windows service start-type
Next
From: Magnus Hagander
Date:
Subject: Re: git: uh-oh