Re: SQLSTATE of notice PGresult - Mailing list pgsql-hackers

From Euler Taveira de Oliveira
Subject Re: SQLSTATE of notice PGresult
Date
Msg-id 4C748846.50504@timbira.com
Whole thread Raw
In response to Re: SQLSTATE of notice PGresult  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: SQLSTATE of notice PGresult
List pgsql-hackers
Tom Lane escreveu:
> The real issue
> here is that there are no SQLSTATEs assigned for any error/warning
> conditions generated internally in libpq.
> 
Did you mean successful conditions? Only warning/error conditions produce a
SQLSTATE.

> As far as this particular example goes, I think it's highly debatable
> whether "out of range parameter number" should be only a NOTICE, and
> almost certainly wrong to say that it ought to be associated with an
> 00000 SQLSTATE.  But figuring out what it ought to be is part of the
> dogwork that nobody's done yet.
> 
It should match the actual PostgreSQL behavior. There are two classes (01xxx
and 02xxx) for warnings.

What I'm thinking is something like

*** src/interfaces/libpq/fe-protocol3.c 28 Apr 2010 13:46:23 -0000  1.43
--- src/interfaces/libpq/fe-protocol3.c 21 Aug 2010 02:41:01 -0000
***************
*** 206,211 ****
--- 206,219 ----                       if (!conn->result)                           return;                   }
+                   /*
+                    * If the command was successful completed, set the
+                    * appropriate SQLSTATE. Pre-9.1 don't set it.
+                    * ERRCODE_SUCCESSFUL_COMPLETION code (aka 00000) is
+                    * hardcoded here because we avoid including elog routines
+                    * here.
+                    */
+                   pqSaveMessageField(conn->result, PG_DIAG_SQLSTATE, "00000");
strncpy(conn->result->cmdStatus,conn->workBuffer.data,                           CMDSTATUS_LEN);
conn->asyncStatus= PGASYNC_READY;
 


(I only patch the 'Command Complete' message here but it is necessary to patch
other success messages too.)


--  Euler Taveira de Oliveira http://www.timbira.com/


pgsql-hackers by date:

Previous
From: Euler Taveira de Oliveira
Date:
Subject: Re: SQLSTATE of notice PGresult
Next
From: Tom Lane
Date:
Subject: Re: git: uh-oh