pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jakob Egger <jakob@eggerapps.at>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Cc: Robert Haas <robertmhaas@gmail.com>
Subject: Re: PG_DIAG_SEVERITY and a possible bug in pq_parse_errornotice()
Date: Thu, 25 Aug 2016 11:43:51 -0400
Message-ID: <11859.1472139831@sss.pgh.pa.us> (raw)
In-Reply-To: <A88E0006-13CB-49C6-95CC-1A77D717213C@eggerapps.at>
References: <A88E0006-13CB-49C6-95CC-1A77D717213C@eggerapps.at>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Jakob Egger <jakob@eggerapps.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 zéro
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


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (15+ messages)  latest in thread

Message-ID: <11859.1472139831@sss.pgh.pa.us>
Permalink:  ../11859.1472139831@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/11859.1472139831@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, jakob@eggerapps.at, robertmhaas@gmail.com
  Subject: Re: PG_DIAG_SEVERITY and a possible bug in pq_parse_errornotice()
  In-Reply-To: <11859.1472139831@sss.pgh.pa.us>
  References: <A88E0006-13CB-49C6-95CC-1A77D717213C@eggerapps.at> <11859.1472139831@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox