Re: BUG #16048: SQLSTATE 22P05 is not captured in exception clause

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: fabiogibon(at)gmail(dot)com
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16048: SQLSTATE 22P05 is not captured in exception clause
Date: 2019-10-11 14:19:20
Message-ID: 16177.1570803560@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)org> 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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2019-10-11 14:36:54 Re: BUG #16049: log_line_prefix=%a and log_connections - application_name missing
Previous Message PG Bug reporting form 2019-10-11 14:12:49 BUG #16049: log_line_prefix=%a and log_connections - application_name missing