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: AANLkTinU2S2vuYryvZgYp+q3few_M7MJnUf9pRigEP4f@mail.gmail.com (view raw or flat)
Thread:
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,
PG_DIAG_MESSAGE_PRIMARY);
}

So, SQLSTATE field is not always presents.

Regards,
Dmitriy

Responses

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-2014 The PostgreSQL Global Development Group