Re: WHEN SQLSTATE '00000' THEN equals to WHEN OTHERS THEN
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-hackers@lists.postgresql.org
Cc: David Fiedler <david.fido.fiedler@gmail.com>
Date: 2025-03-20T16:04:19Z
Lists: pgsql-hackers, pgsql-docs
Attachments
- make-OTHERS-disjoint-from-sqlstates.patch (text/x-diff) patch
[ redirecting to -hackers ] I wrote: > 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. Here's a patch for this. I'm unsure whether to change it in back branches; is it conceivable that somebody is depending on WHEN SQLSTATE '00000' mapping to WHEN OTHERS? regards, tom lane
Commits
-
plpgsql: make WHEN OTHERS distinct from WHEN SQLSTATE '00000'.
- 58fdca2204de 18.0 landed