Re: WHEN SQLSTATE '00000' THEN equals to WHEN OTHERS THEN

Laurenz Albe <laurenz.albe@cybertec.at>

From: Laurenz Albe <laurenz.albe@cybertec.at>
To: David Fiedler <david.fido.fiedler@gmail.com>, pgsql-docs@lists.postgresql.org
Date: 2025-03-19T15:32:20Z
Lists: pgsql-hackers, pgsql-docs
On Wed, 2025-03-19 at 15:03 +0100, David Fiedler wrote:
> 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.
> What do you think? Should I post the expected text somewhere?

The code makes no sense, but what about this:

DO $$BEGIN RAISE EXCEPTION SQLSTATE '00000'; END;$$;
ERROR:  00000
CONTEXT:  PL/pgSQL function inline_code_block line 1 at RAISE

Yours,
Laurenz Albe



Commits

  1. plpgsql: make WHEN OTHERS distinct from WHEN SQLSTATE '00000'.