Re: SQLSTATEs for warnings - Mailing list pgsql-hackers

From Tom Lane
Subject Re: SQLSTATEs for warnings
Date
Msg-id 9132.1059402223@sss.pgh.pa.us
Whole thread Raw
In response to SQLSTATEs for warnings  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: SQLSTATEs for warnings  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
Peter Eisentraut <peter_e@gmx.net> writes:
> In other words, an info, notice, or warning must have a class 00, 01, 02.

I suspect though that the spec is assuming that the SQLSTATE code is the
*only* way for the application to determine whether the message is
success, warning, or error.  Since we have other signaling mechanisms
(the severity field, or even more basically the Error/Notice message
type distinction), I'm not convinced we need to be entirely anal about
this division.

AFAICS the alternative to misusing error-class SQLSTATEs as warnings is
that we invent implementation-specific warning codes.  Is it really
worth having two codes for what amounts to the same condition?

> However, I noticed several warnings that use codes that are intended for
> errors, for example in portalcmds.c and xact.c.

Several of them are things that probably *ought* to be errors, as you
noted in a later message.  I don't recall exactly what other sins I
committed in this area (the whole effort is already becoming a blur ;-)).
We have time to rejigger around the edges though --- I have no objection
to reassigning codes during beta.  Once we release it will get harder.

A possibly related sin in the same category is that I think that the
class-40 SQLSTATEs are intended to imply that the server has forcibly
aborted your whole transaction --- not just the current statement, which
is what I think the spec envisions for all the other error classes.
We do not currently make that distinction, but sooner or later we will.
Perhaps we should avoid the class-40 codes and make our own
implementation-dependent codes for deadlock detection and so forth.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Passing server_encoding to the client is not future-proof
Next
From: "Jenny -"
Date:
Subject: granularity of locks in postgresql