From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Jakob Egger <jakob(at)eggerapps(dot)at> |
Cc: | "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com> |
Subject: | Re: PG_DIAG_SEVERITY and a possible bug in pq_parse_errornotice() |
Date: | 2016-08-25 15:43:51 |
Message-ID: | 11859.1472139831@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Jakob Egger <jakob(at)eggerapps(dot)at> writes:
> My PostgreSQL client checks the PG_DIAG_SEVERITY error field to determine the error level.
> However, I have now learned that this field is localized. This means that a server configured with --enable-nls might for example return the string ERREUR instead of ERROR.
Check.
> So if I want to determine the error level, do I need to compare against all localised variations in my app? Or is there another way?
Generally, we've presumed that clients don't really need to know the
difference between error levels, beyond the error-versus-notice
distinction that's embedded in the message type. If you have an
application where that's actually important, it would be interesting to
know what it is.
> I browsed through the PostgreSQL source and discovered that pq_parse_errornotice() (in src/backend/libpq/pqmq.c) uses the same naive strcmp() approach to determine error level. This means that it will fail when the server is compiled with --enable-nls. I am not sure what the impact of this is, since I couldn't really figure out where that function is used.
Ooops. Indeed, that is broken:
postgres=# select 1/0; -- using French locale
ERREUR: division par zro
postgres=# set force_parallel_mode=1;
SET
postgres=# select stringu1::int2 from tenk1 where unique1 = 1;
ERREUR: unknown error severity
CONTEXT: parallel worker
Not sure what we ought to do about that, but we need to do something.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Kuntal Ghosh | 2016-08-25 16:41:01 | Re: WAL consistency check facility |
Previous Message | Fabien COELHO | 2016-08-25 15:42:56 | Re: [PATCH v2] Add overflow checks to money type input function |