agora inbox for pgsql-docs@postgresql.org  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Fiedler <david.fido.fiedler@gmail.com>
Cc: pgsql-docs@lists.postgresql.org
Subject: Re: WHEN SQLSTATE '00000' THEN equals to WHEN OTHERS THEN
Date: Wed, 19 Mar 2025 11:29:50 -0400
Message-ID: <706649.1742398190@sss.pgh.pa.us> (raw)
In-Reply-To: <CAHjN70-=H5EpTOuZVbC8mPvRS5EfZ4MY2=OUdVDWoyGvKhb+Rw@mail.gmail.com>
References: <CAHjN70-=H5EpTOuZVbC8mPvRS5EfZ4MY2=OUdVDWoyGvKhb+Rw@mail.gmail.com>

David Fiedler <david.fido.fiedler@gmail.com> writes:
> I've stumbled across a code that used this condition, resulting in
> unexpected behavior. I think it worths a note that catching 00000 is not
> possible and that it results in a catch all handler.

Hmph.  The code thinks

	 * OTHERS is represented as code 0 (which would map to '00000', but we
	 * have no need to represent that as an exception condition).

but it evidently didn't consider the possibility of a user writing
'00000'.  I'm more inclined to consider this a bug and change plpgsql
to use something else internally to represent OTHERS.  We could use
-1, which AFAICS cannot be generated by MAKE_SQLSTATE.

			regards, tom lane





view thread (4+ messages)  latest in thread

Message-ID: <706649.1742398190@sss.pgh.pa.us>
Permalink:  ../706649.1742398190@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/706649.1742398190@sss.pgh.pa.us

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, david.fido.fiedler@gmail.com, pgsql-docs@lists.postgresql.org
  Subject: Re: WHEN SQLSTATE '00000' THEN equals to WHEN OTHERS THEN
  In-Reply-To: <706649.1742398190@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox