Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bcwoy-0003f4-BT for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Aug 2016 15:44:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bcwox-0005sS-V5 for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Aug 2016 15:44:00 +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_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bcwow-0005qo-Tg for pgsql-hackers@postgresql.org; Thu, 25 Aug 2016 15:43:58 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bcwou-0002mY-9D for pgsql-hackers@postgresql.org; Thu, 25 Aug 2016 15:43:58 +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 u7PFhpoB011860; Thu, 25 Aug 2016 11:43:51 -0400 From: Tom Lane To: Jakob Egger cc: "pgsql-hackers@postgresql.org" , Robert Haas Subject: Re: PG_DIAG_SEVERITY and a possible bug in pq_parse_errornotice() In-reply-to: References: Comments: In-reply-to Jakob Egger message dated "Thu, 25 Aug 2016 17:22:38 +0200" Date: Thu, 25 Aug 2016 11:43:51 -0400 Message-ID: <11859.1472139831@sss.pgh.pa.us> X-Pg-Spam-Score: -2.1 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Jakob Egger 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