From: | Euler Taveira de Oliveira <euler(at)timbira(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Robert Haas <robertmhaas(at)gmail(dot)com>, Dmitriy Igrishin <dmitigr(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: SQLSTATE of notice PGresult |
Date: | 2010-08-25 03:04:38 |
Message-ID: | 4C748846.50504@timbira.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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/
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2010-08-25 03:21:24 | Re: git: uh-oh |
Previous Message | Euler Taveira de Oliveira | 2010-08-25 02:50:31 | Re: SQLSTATE of notice PGresult |