pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joe Conway <mail@joeconway.com>
To: Tristan Partin <tristan@neon.tech>
To: Heikki Linnakangas <hlinnaka@iki.fi>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: gdo@leader.it
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17946: LC_MONETARY & DO LANGUAGE plperl - BUG
Date: Fri, 9 Jun 2023 15:05:40 -0400
Message-ID: <ca35e375-be82-322d-8c81-78127d8fb33f@joeconway.com> (raw)
In-Reply-To: <CT887GSPI31W.BQCSW35JL67L@gonk>
References: <17946-3e84cb577e9551c3@postgresql.org>
	<1564676.1685043220@sss.pgh.pa.us>
	<555bb26e-c27c-ab65-028f-3fd5b82df9de@iki.fi>
	<CT887GSPI31W.BQCSW35JL67L@gonk>

On 6/9/23 11:31, Tristan Partin wrote:
> On Mon Jun 5, 2023 at 11:00 AM CDT, Heikki Linnakangas wrote:
>> On 25/05/2023 15:33, Tom Lane wrote:
>> > PG Bug reporting form <noreply@postgresql.org> writes:
>> >> After upgrading an application using Postgresql from version 10 to 12,
>> >> fields of type "money" are no longer generated with the € symbol but with
>> >> $.
>> > 
>> > Hmm, seems to work for me:
>>
>> I can reproduce this:
>>
>> psql (16beta1)
>> Type "help" for help.
>>
>> postgres=# DO LANGUAGE 'plperl' $$ elog(NOTICE, 'foo') $$;
>> NOTICE:  foo
>> DO
>> postgres=# SET lc_monetary TO 'en_GB.UTF-8';
>> SET
>> postgres=# SELECT 12.34::money AS price;
>>   price
>> --------
>>   $12.34
>> (1 row)
>>
>>
>> If I don't call the plperl function, it works as expected:
>>
>> sql (16beta1)
>> Type "help" for help.
>>
>> postgres=# SET lc_monetary TO 'en_GB.UTF-8';
>> SET
>> postgres=# SELECT 12.34::money AS price;
>>   price
>> --------
>>   £12.34
>> (1 row)
>>
>> I should note that 'en_GB.UTF-8' is the default locale in my system, and 
>> that's what I used in initdb. I don't know if it makes a difference.
> 
> I am looking into this bug. I have also reproduced it.

It reproduces for me on both pg16beta1 and pg10. I wonder if it isn't a 
behavior change in libperl itself. It seems that merely doing "load 
'plperl';" is enough to cause the issue as long as it is done prior to 
doing "SET lc_monetary TO 'en_GB.UTF-8'; SELECT 12.34::money AS price;". 
When done in the opposite order the problem does not occur.

8<------------------------------
# On pg10 with perl v5.34.0
# note that on my system
# LC_NUMERIC=""
# LC_ALL=""
# LANG="en_US.UTF-8"
#
# this works correctly
psql nmx << EOF
SET lc_monetary TO 'en_GB.UTF-8';
SELECT 12.34::money AS price;
load 'plperl';
SELECT 12.34::money AS price;
EOF
SET
  price
--------
  £12.34
(1 row)

LOAD
  price
--------
  £12.34
(1 row)

# this does not
psql nmx << EOF
SET lc_monetary TO 'en_GB.UTF-8';
load 'plperl';
SELECT 12.34::money AS price;
EOF
SET
LOAD
  price
--------
  $12.34
(1 row)
8<------------------------------

Since I am also seeing this on pg10, I wonder if it is a change in 
perl.I found this[1]:

   "What did change is that perl space code no
    longer pays attention to the LC_NUMERIC
    category outside 'use locale'. This is the way
    it has always worked, AFAIK, for LC_COLLATE
    and, mostly, LC_CTYPE, and for some uses of
    LC_NUMERIC."


[1] "locale changes in 5.19.1 break LC_NUMERIC
      handling"
      https://github.com/Perl/perl5/issues/13089
-- 
Joe Conway
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com






view thread (38+ messages)  latest in thread

Message-ID: <ca35e375-be82-322d-8c81-78127d8fb33f@joeconway.com>
Permalink:  ../ca35e375-be82-322d-8c81-78127d8fb33f@joeconway.com/
Also on:    postgresql.org/message-id/ca35e375-be82-322d-8c81-78127d8fb33f@joeconway.com

 · 

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-bugs@postgresql.org
  Cc: mail@joeconway.com, tristan@neon.tech, hlinnaka@iki.fi, tgl@sss.pgh.pa.us, gdo@leader.it
  Subject: Re: BUG #17946: LC_MONETARY & DO LANGUAGE plperl - BUG
  In-Reply-To: <ca35e375-be82-322d-8c81-78127d8fb33f@joeconway.com>
  References: <17946-3e84cb577e9551c3@postgresql.org> <1564676.1685043220@sss.pgh.pa.us> <555bb26e-c27c-ab65-028f-3fd5b82df9de@iki.fi> <CT887GSPI31W.BQCSW35JL67L@gonk> <ca35e375-be82-322d-8c81-78127d8fb33f@joeconway.com>

* 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