Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iIvlP-0006DP-3C for pgsql-bugs@arkaria.postgresql.org; Fri, 11 Oct 2019 14:19:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iIvlN-0006h5-SP for pgsql-bugs@arkaria.postgresql.org; Fri, 11 Oct 2019 14:19:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iIvlN-0006gr-KO for pgsql-bugs@lists.postgresql.org; Fri, 11 Oct 2019 14:19:25 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iIvlL-0005Pj-6q for pgsql-bugs@lists.postgresql.org; Fri, 11 Oct 2019 14:19:25 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x9BEJKnU016178; Fri, 11 Oct 2019 10:19:20 -0400 From: Tom Lane To: fabiogibon@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16048: SQLSTATE 22P05 is not captured in exception clause In-reply-to: <16048-ff86833b63f1a0a2@postgresql.org> References: <16048-ff86833b63f1a0a2@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Fri, 11 Oct 2019 14:03:35 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <16176.1570803560.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Fri, 11 Oct 2019 10:19:20 -0400 Message-ID: <16177.1570803560@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Bug reporting form writes: > I have a database using LATIN1 (and I can't change it), so, when the > user informar a invalid character it is not captured in exception clause. > See a short sample: > DO $$ > DECLARE > v varchar; > BEGIN > v := 'ABCŸ'; > EXCEPTION > WHEN others THEN > RAISE INFO 'Error State: %', SQLSTATE; > END$$; Sorry, that's not a bug, and you're going to have to find some other way to deal with the issue. This error will be thrown while trying to convert the incoming query string to the database encoding, long before anything in the server would be able to recognize that this even is a DO command, let alone is one containing an exception clause. Exception clauses don't work for syntax errors either, for largely similar reasons. regards, tom lane