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/