Re: BUG #17946: LC_MONETARY & DO LANGUAGE plperl - BUG - Mailing list pgsql-bugs

From Joe Conway
Subject Re: BUG #17946: LC_MONETARY & DO LANGUAGE plperl - BUG
Date
Msg-id f1856a5d-3703-66ff-e7c7-01d2489315c1@joeconway.com
Whole thread Raw
In response to Re: BUG #17946: LC_MONETARY & DO LANGUAGE plperl - BUG  (Joe Conway <mail@joeconway.com>)
Responses Re: BUG #17946: LC_MONETARY & DO LANGUAGE plperl - BUG  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
On 6/9/23 22:10, Joe Conway wrote:
> On 6/9/23 15:05, Joe Conway wrote:
>> 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
> I can reproduce with a simple test program by linking libperl:
> 
> 8<-------- test.c ----------------

A bit more spelunking leads me to the following observations and 
conclusions:

1/ On RHEL7 with perl v5.16.3 the problem does not occur

2/ On RHEL9 with perl v5.32.1 the problem does occur

3/ The difference in behavior is triggered by the newer perl doing a 
bunch of newlocale/uselocale calls not done by the older perl, combined 
with a glibc behavior which seems surprising at best.

 From localeinfo.h in glibc source tree:
8<------------------------
/* This fetches the thread-local locale_t pointer, either one set with
    uselocale or &_nl_global_locale.  */
#define _NL_CURRENT_LOCALE      (__libc_tsd_get (locale_t, LOCALE))
8<------------------------

4/ I successfully tested a fix in the simplified reproducer program sent 
earlier. It amounts to adding:

8<------------------------
   uselocale(LC_GLOBAL_LOCALE);
8<------------------------

prior to calling

8<------------------------
   extlconv = localeconv();
8<------------------------

5/ The attached fixes the issue for me on pg10 and passes check-world.

Comments?

-- 
Joe Conway
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

Attachment

pgsql-bugs by date:

Previous
From: Joe Conway
Date:
Subject: Re: BUG #17946: LC_MONETARY & DO LANGUAGE plperl - BUG
Next
From: Tom Lane
Date:
Subject: Re: BUG #17946: LC_MONETARY & DO LANGUAGE plperl - BUG