Skip site navigation (1) Skip section navigation (2)

SQLSTATE of notice PGresult

From: Dmitriy Igrishin <dmitigr(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: SQLSTATE of notice PGresult
Date: 2010-08-20 10:13:45
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
Hey all,

Accordingly to the documentation of libpq, SQLSTATE code field "is not
localizable, and
is always present.". But it seems, in some cases it isn't. E.g.

  /* the main code */
  PGresult* res = Pg::PQexec(conn, "select 1");
  Oid id = PQparamtype(res, 1);

  /* the notice receiver */
  void myNoticeReceiver(void *arg, const PGresult *res)
  /* Presents - "NOTICE" */
  const char* severity = Pg::PQresultErrorField(res, PG_DIAG_SEVERITY);

  /* NOT presents - NULL. Why not "00000" ? */
  const char* sqlstate = Pg::PQresultErrorField(res, PG_DIAG_SQLSTATE);

  /* Presents - "parameter number 1 is out of range 0..-1" */
  const char* primary = Pg::PQresultErrorField(res,

So, SQLSTATE field is not always presents.



pgsql-hackers by date

Next:From: Magnus HaganderDate: 2010-08-20 11:02:00
Subject: Re: git: uh-oh
Previous:From: Magnus HaganderDate: 2010-08-20 09:21:18
Subject: Re: Fw: patch for pg_ctl.c to add windows service start-type

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group