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

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: David Fiedler <david(dot)fido(dot)fiedler(at)gmail(dot)com>, pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: WHEN SQLSTATE '00000' THEN equals to WHEN OTHERS THEN
Date: 2025-03-19 15:32:20
Message-ID: c77b6c0b51b55338b0353dadb04e1880610a8a41.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs pgsql-hackers

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

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message Kirk Parker 2025-03-20 14:08:50 Re: Ambiguity in IS JSON description and logic
Previous Message Tom Lane 2025-03-19 15:29:50 Re: WHEN SQLSTATE '00000' THEN equals to WHEN OTHERS THEN

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2025-03-19 15:34:59 Re: Disabling vacuum truncate for autovacuum
Previous Message Nathan Bossart 2025-03-19 15:31:22 Re: optimize file transfer in pg_upgrade