Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q6CdQ-0006IE-3E for pgsql-bugs@arkaria.postgresql.org; Mon, 05 Jun 2023 16:00:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q6CdO-0003ZV-Us for pgsql-bugs@arkaria.postgresql.org; Mon, 05 Jun 2023 16:00:42 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q6CdO-0003Z9-IE for pgsql-bugs@lists.postgresql.org; Mon, 05 Jun 2023 16:00:42 +0000 Received: from meesny.iki.fi ([2001:67c:2b0:1c1::201]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q6CdL-000N07-1f for pgsql-bugs@lists.postgresql.org; Mon, 05 Jun 2023 16:00:41 +0000 Received: from [192.168.1.115] (dsl-hkibng22-54f8db-125.dhcp.inet.fi [84.248.219.125]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) (Authenticated sender: hlinnaka) by meesny.iki.fi (Postfix) with ESMTPSA id 4QZdcL5P6GzyPK; Mon, 5 Jun 2023 19:00:34 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1685980836; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+kuzRrny0CFr2CFue9Uc/f7rwnGm1GBUG+VqQtbKVQY=; b=KWDWzX87m0kszIIG7XMkjPgO3Y2nwqgR+xFjfZ0SwZ80IZ1baL0xYKzsQ+UHcXMrotJ/V4 EIzmHctPZ1BQAgWp2jQqIQx07XGAs0WLlnG7u9L2Dxl6shX46CffpCP6mmr20BPhgW9lSJ TBjCVos/JrFAi8QhCM4fqbmJ1TawWd4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1685980836; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+kuzRrny0CFr2CFue9Uc/f7rwnGm1GBUG+VqQtbKVQY=; b=iI7QsU7ysIERmQwE5uzGiJK9LHGQOdKU/i4bi2BZZfHRpZdxNmVWjYC7JyDF0nu41qPRrD bWZVLafhE3iRdTKjxLKbJQelLLU9CKERLfC3vIq+f0ZMCpzv1KzZRhVo2PhSEPXM+otXYu UskiE4ecl5fL7tPHVLTTPXaAWiFXl30= ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=hlinnaka smtp.mailfrom=hlinnaka@iki.fi ARC-Seal: i=1; s=meesny; d=iki.fi; t=1685980836; a=rsa-sha256; cv=none; b=GaH8CUfkprISPjrW1dMV2maB/89eHzZ8KwvsW/kq7HpndR0JeIfka2o500YtQEjoPsgG9J uVVj5pOvII6UrHwaPhryzrdQnqHk/NtniNkfp+DYTCeRq/QS6qhnNEgMfIBomd2QmWhoqx pojxyHYBr51k129SPWIrnwQO5IFjnG4= Message-ID: <555bb26e-c27c-ab65-028f-3fd5b82df9de@iki.fi> Date: Mon, 5 Jun 2023 19:00:34 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: BUG #17946: LC_MONETARY & DO LANGUAGE plperl - BUG Content-Language: en-US To: Tom Lane , gdo@leader.it Cc: pgsql-bugs@lists.postgresql.org References: <17946-3e84cb577e9551c3@postgresql.org> <1564676.1685043220@sss.pgh.pa.us> From: Heikki Linnakangas In-Reply-To: <1564676.1685043220@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 25/05/2023 15:33, Tom Lane wrote: > PG Bug reporting form 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. > IIRC, we've seen trouble in the past with some versions of libperl > clobbering the host application's locale settings. Maybe you > have a plperl.on_init or plperl.on_plperl_init action that is > causing that to happen? In any case, I'd call it a Perl bug not > a Postgres bug I did some debugging, initializing the perl interpreter calls uselocale(): #0 __GI___uselocale (newloc=0x7f9f47ff0940 <_nl_C_locobj>) at ./locale/uselocale.c:31 #1 0x00007f9f373bd069 in ?? () from /usr/lib/x86_64-linux-gnu/libperl.so.5.36 #2 0x00007f9f373bce74 in ?? () from /usr/lib/x86_64-linux-gnu/libperl.so.5.36 #3 0x00007f9f373bfc15 in Perl_init_i18nl10n () from /usr/lib/x86_64-linux-gnu/libperl.so.5.36 #4 0x00007f9f48b74cfb in plperl_init_interp () at plperl.c:809 #5 0x00007f9f48b78adc in _PG_init () at plperl.c:483 #6 0x000055c98b8e9b63 in internal_load_library (libname=0x55c98bebaf90 "/home/heikki/pgsql.fsmfork/lib/plperl.so") at dfmgr.c:289 #7 0x000055c98b8ea1c2 in load_external_function (filename=filename@entry=0x55c98bebb1c0 "$libdir/plperl", funcname=funcname@entry=0x55c98beba378 "plperl_inline_handler", signalNotFound=signalNotFound@entry=true, filehandle=filehandle@entry=0x7ffd20942b48) at dfmgr.c:116 #8 0x000055c98b8ea864 in fmgr_info_C_lang (functionId=129304, procedureTuple=0x7f9f4778ccb8, finfo=0x7ffd20942bf0) at fmgr.c:386 #9 fmgr_info_cxt_security (functionId=129304, finfo=0x7ffd20942bf0, mcxt=, ignore_security=) at fmgr.c:246 #10 0x000055c98b8eba72 in fmgr_info (finfo=0x7ffd20942bf0, functionId=) at fmgr.c:129 #11 OidFunctionCall1Coll (functionId=, collation=collation@entry=0, arg1=94324124262840) at fmgr.c:1386 #12 0x000055c98b5e1385 in ExecuteDoStmt (pstate=pstate@entry=0x55c98beba0b0, stmt=stmt@entry=0x55c98be90858, atomic=atomic@entry=false) at functioncmds.c:2144 #13 0x000055c98b7c24ce in standard_ProcessUtility (pstmt=0x55c98be908e0, queryString=0x55c98be8fd50 "DO LANGUAGE 'plperl' $$ elog(NOTICE, 'foo') $$;", readOnlyTree=, context=PROCESS_UTILITY_TOPLEVEL, params=0x0, queryEnv=0x0, dest=0x55c98be90b80, qc=0x7ffd20942f30) at utility.c:714 #14 0x000055c98b7c0d9f in PortalRunUtility (portal=portal@entry=0x55c98bf0b710, pstmt=pstmt@entry=0x55c98be908e0, isTopLevel=isTopLevel@entry=true, setHoldSnapshot=setHoldSnapshot@entry=false, dest=0x55c98be90b80, qc=0x7ffd20942f30) at pquery.c:1158 #15 0x000055c98b7c0ecb in PortalRunMulti (portal=portal@entry=0x55c98bf0b710, isTopLevel=isTopLevel@entry=true, setHoldSnapshot=setHoldSnapshot@entry=false, dest=dest@entry=0x55c98be90b80, altdest=altdest@entry=0x55c98be90b80, qc=qc@entry=0x7ffd20942f30) at pquery.c:1322 #16 0x000055c98b7c139d in PortalRun (portal=portal@entry=0x55c98bf0b710, count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=true, run_once=run_once@entry=true, dest=dest@entry=0x55c98be90b80, altdest=altdest@entry=0x55c98be90b80, qc=0x7ffd20942f30) at pquery.c:791 #17 0x000055c98b7bd85d in exec_simple_query (query_string=0x55c98be8fd50 "DO LANGUAGE 'plperl' $$ elog(NOTICE, 'foo') $$;") at postgres.c:1274 #18 0x000055c98b7bf978 in PostgresMain (dbname=, username=) at postgres.c:4632 #19 0x000055c98b73f743 in BackendRun (port=, port=) at postmaster.c:4461 #20 BackendStartup (port=) at postmaster.c:4189 #21 ServerLoop () at postmaster.c:1779 #22 0x000055c98b74077a in PostmasterMain (argc=argc@entry=3, argv=argv@entry=0x55c98be88fc0) at postmaster.c:1463 #23 0x000055c98b4a96be in main (argc=3, argv=0x55c98be88fc0) at main.c:198 I think the uselocale() call renders ineffective the setlocale() calls that we make later. Maybe we should replace our setlocale() calls with uselocale(), too. -- Heikki Linnakangas Neon (https://neon.tech)