Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tuvMl-00EDpy-Ch for pgsql-docs@arkaria.postgresql.org; Wed, 19 Mar 2025 15:29:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tuvMi-006cqs-6p for pgsql-docs@arkaria.postgresql.org; Wed, 19 Mar 2025 15:29:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tuvMh-006cqk-VQ for pgsql-docs@lists.postgresql.org; Wed, 19 Mar 2025 15:29:55 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tuvMe-003mdS-0E for pgsql-docs@lists.postgresql.org; Wed, 19 Mar 2025 15:29:55 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 52JFToHL706650; Wed, 19 Mar 2025 11:29:50 -0400 From: Tom Lane To: David Fiedler cc: pgsql-docs@lists.postgresql.org Subject: Re: WHEN SQLSTATE '00000' THEN equals to WHEN OTHERS THEN In-reply-to: References: Comments: In-reply-to David Fiedler message dated "Wed, 19 Mar 2025 15:03:34 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <706648.1742398190.1@sss.pgh.pa.us> Date: Wed, 19 Mar 2025 11:29:50 -0400 Message-ID: <706649.1742398190@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Fiedler 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