Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vpvdo-001NtV-0L for pgsql-bugs@arkaria.postgresql.org; Tue, 10 Feb 2026 21:51:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vpvdm-0010pO-0T for pgsql-bugs@arkaria.postgresql.org; Tue, 10 Feb 2026 21:51:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vpvdl-0010pG-2i for pgsql-bugs@lists.postgresql.org; Tue, 10 Feb 2026 21:51:26 +0000 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vpvdk-000000002xC-2GGT for pgsql-bugs@lists.postgresql.org; Tue, 10 Feb 2026 21:51:26 +0000 Received: by mail-oi1-x229.google.com with SMTP id 5614622812f47-45f10d7eb81so1617620b6e.3 for ; Tue, 10 Feb 2026 13:51:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1770760283; cv=none; d=google.com; s=arc-20240605; b=BGO8KCk3dWgkhN2+dj/N8u3+QMMdZtqwotILDZeiVcGCR2MkbalZ0EedlqFgTN4HBs qMEipezLlSthGnt7cgaNHQhkjuThrl6JUXx1LQeGARmzmeCZMOT6ZZE9ZwK3TF6CMuke u9q2LIHTcCh4YKwovxEdLhP5yxyPBjFAZSGkT5GgWb7HzEfirZCM94Ub4XrSKXAyQKiX fAvMz5DzQkw+a+YzNr87QC5NBjOZjcOR4vtLV6TBlvq6vtWzPo6QFsyLqc25Sp+x5hKV herWbYq3abETX25oY7X1SfGlVGiRbm+EXv6BlGMm7uwXpssxBmrKT6EGc5P50av7ooOq FlxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=d9/3Sd7Y+1ywaKEkF232hrWXxxhFEf3AvNiqqLlzOjk=; fh=T5iIoKUB5H0640OS/i1i33IP2RGZm6FvPc0KmuxQg9Y=; b=SqQBv3vGvPQseTamtZc/mI/6tTrIxCb39XJZmrNTnjsuQ3g3NVo0i7Ad0hdJTspSG2 +himbid098FK1HvyEQngUupK810V4ACLaQyqHCVgkLhqkLIJVv44pFlah3EmEWpFwGkf WPgmLsyAzNp1BOk1ouy/Ndz3T9GD0BaODjXoNuSSAnBoHWvN5FIB46m1jPBYD3fL/WK2 x1x9tp6EetnOhDkD3iAFTOxv/IsND6oVEsVfxi97aAhM/vtdbg3LFz78ajCoawmwj0EL uJxQYcKulLI82Y3aktfHpO7dyFF+op2ZJrw8QrHkAKsk6ex2eNOxaOHTyo1mwZ/QjKT3 gPbw==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770760283; x=1771365083; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=d9/3Sd7Y+1ywaKEkF232hrWXxxhFEf3AvNiqqLlzOjk=; b=J6W8tORifjoPY5JGWVeJPcV7+BORKvaFnedJL34nRJfaxzERS5V4N8EAGGUu9X8R9D vw0g/rtq9fd/4DxEXfub4VqMO9CaHTqr4DkP0eq6G8LlrQgx1UjuIgbPH7NzRTy506N9 Y6WFdclW6Iau491dMCte4Rded7/UD2xTQBMFzCbJSOLS/Ox3vNeZob+UR9jS/NKvId9T 9t6n1vHJ2M7M9guyEIBkYp/JtzD4gdm5b2QqQdJgeUkvou2YZmsCLqFvCyMbokxR8dJx EHUQNE7SI8P19cbutshbkOo9lLTDXWN49cwbDsjpbd00LSr6zTHE2gdxb2V33zqDW5Qg vQ7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770760283; x=1771365083; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=d9/3Sd7Y+1ywaKEkF232hrWXxxhFEf3AvNiqqLlzOjk=; b=On5EL3mkH0cXdU3wdQbg+p13s62MphBMedmFSocSyUHrTTIUBkug+Vy+jNe48Fg/OG kED1hGMLZbWrvkfHK1EwxQhv5rnl8Jr7ua2Q/tdmktCypEo3hKocebWcgrygVLiM+xiH zxVKvLMWv818jDkDWjWh0q3a1j/RjSfgexW3PQgqL4BBwt5k1mULj/gPPAlu3dRLT7O+ IMdaEZ9Psh2lBq94KwFCAxTCl25kFdiE3+9hma/hV9m0sBAjhabM8njg96L1BkWzyV4E OeMOwfvsJ9SSMQo1EqOTRdCjd18767h7AnJ2cUj1AQgnjUKOgJTQSQ1tMR5vDCUvRjAI XOfA== X-Forwarded-Encrypted: i=1; AJvYcCWs7l5MUVCzDRba9BNnTYgr/iuvIH9vZsPNisVA9kg0Xz1PXcx+5ctD7rlQKZ7UuBGZh9wqC3Dev9rH@lists.postgresql.org X-Gm-Message-State: AOJu0Ywg4netwpZuTDV54Mjkiu6wmuRyVm8fH+RxiuPjy1RVx7wNljSQ Z0Hb1/8DcZlnnyjdxOt6nX5aU4KQFuYmeMD4gYdEfD/6GvNDVhx88SwhvEJ1L5gaZ89/zGqWjP9 Vi1HUeiCbvAWMcvHijjeo3zRHi2RJU6g= X-Gm-Gg: AZuq6aJ2sQBu8Fo3G6jCDseR+KK3SaHxHeEfOUG1S+JRGcaapv/rxRjZvYwNI+OtWiL s8Hmy/OcjRnNlanJDDIDi5A2ZR2EVs7oNeHgt6+cd8isS6xiXlJJuqDF2SxdI08JaXRHJ0PPGCk LVG9fpeNMRCDIEHEM7S/EBnIim77cAZAoMsJ/sgC0ZzK79q0DhdrFsGdWluDfTwJm6524+ii2WY QoiGxB8BMWvFywD67BEy/ISUVNncDWkVwP0L6nvoPaStksttK45SAjmhkspAUacoOASrw7y+jG2 LPxbqYI92gh6Kn5W4eE= X-Received: by 2002:a05:6820:f02f:b0:674:3230:ff1b with SMTP id 006d021491bc7-67437c7874bmr264822eaf.9.1770760282667; Tue, 10 Feb 2026 13:51:22 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: surya poondla Date: Tue, 10 Feb 2026 13:51:11 -0800 X-Gm-Features: AZwV_QjJY6zFLhJvi6wZorTK4s0Wns9WmZ-blA4fWxM0BscuF86kqmFiD8IO8lA Message-ID: Subject: Re: Possibly a bug To: jian he Cc: =?UTF-8?B?0JDQvdCw0YLQvtC70LjQuQ==?= , pgsql-bugs@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000a18189064a7f4127" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000a18189064a7f4127 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Jian, These current.* functions always use the "C" collation for their > output, so in this case, they are not related to session variables, in > my view. > Thank you, I did some more testing and see the below. postgres=3D# SELECT collation for (user); pg_collation_for ------------------ "C" (1 row) postgres=3D# SELECT collation for (current_user); pg_collation_for ------------------ "C" (1 row) postgres=3D# SELECT to_upper_varchar('=D1=82=D0=B5=D1=81=D1=82'::varchar)= ; to_upper_varchar ------------------ =D0=A2=D0=95=D0=A1=D0=A2 (1 row) postgres=3D# SELECT collation for ('=D1=82=D0=B5=D1=81=D1=82'); pg_collation_for ------------------ (1 row) postgres=3D# CREATE OR REPLACE FUNCTION debug_func(param1 text, param2 text) RETURNS text AS $$ SELECT 'param1 collation: ' || pg_collation_for(param1) || ', param2 collation: ' || pg_collation_for(param2); $$ LANGUAGE sql; CREATE FUNCTION postgres=3D# SELECT debug_func('=D1=82=D0=B5=D1=81=D1=82', user::text); debug_func ---------------------------------------------- param1 collation: "C", param2 collation: "C" (1 row) postgres=3D# CREATE OR REPLACE FUNCTION debug_func2(param1 text, param2 text) RETURNS text AS $$ SELECT 'param1 collation: ' || pg_collation_for(param1) || ', param2 collation: ' || pg_collation_for(param2); $$ LANGUAGE sql; CREATE FUNCTION postgres=3D# SELECT debug_func2('=D1=82=D0=B5=D1=81=D1=82'::text, user::tex= t); debug_func2 ---------------------------------------------- param1 collation: "C", param2 collation: "C" (1 row) postgres=3D# My observation is the user, current* functions collation is "C" collation and when a "C" collation is passed as a parameter, it converts all the parameters to use the "C" collation. I was looking at sql_fn_make_param() function and the comments over their say "/* * If we have a function input collation, allow it to override the * type-derived collation for parameter symbols. (XXX perhaps this should * not happen if the type collation is not default?) */ " From the above code comment it looks like the "C" collation is overriding the type-driven collation, and this might be causing the issue. I am currently using gdb to debug more and will work on a patch based on my findings. Regards, Surya Poondla --000000000000a18189064a7f4127 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Jian,

=
These current.* functions always use the "C" collation for their<= br> output, so in this case, they are not related to session variables, in
my view.

Thank you, I did some more testing and se= e the below.

postgres=3D# SELECT collation for (us= er);
=C2=A0pg_collation_for
------------------
=C2=A0"C"=
(1 row)

postgres=3D# SELECT collation for (current_user);
=C2= =A0pg_collation_for
------------------
=C2=A0"C"
(1 row)=

postgres=3D# =C2=A0 SELECT to_upper_varchar('=D1=82= =D0=B5=D1=81=D1=82'::varchar);
=C2=A0to_upper_varchar
-----------= -------
=C2=A0=D0=A2=D0=95=D0=A1=D0=A2
(1 row)

postgres=3D# = =C2=A0 SELECT collation for ('=D1=82=D0=B5=D1=81=D1=82');
=C2=A0= pg_collation_for
------------------

(1 row)

<= div>postgres=3D# =C2=A0 CREATE OR REPLACE FUNCTION debug_func(param1 text, = param2 text) RETURNS text AS $$ SELECT 'param1 collation: ' || pg_c= ollation_for(param1) || ', param2 collation: ' || pg_collation_for(= param2); $$ LANGUAGE sql;
CREATE FUNCTION
postgres=3D# =C2=A0 SELECT = debug_func('=D1=82=D0=B5=D1=81=D1=82', user::text);
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0debug_func
---------= -------------------------------------
=C2=A0param1 collation: "C&qu= ot;, param2 collation: "C"
(1 row)

postgres=3D# =C2=A0 = CREATE OR REPLACE FUNCTION debug_func2(param1 text, param2 text) RETURNS te= xt AS $$ SELECT 'param1 collation: ' || pg_collation_for(param1) ||= ', param2 collation: ' || pg_collation_for(param2); $$ LANGUAGE sq= l;
CREATE FUNCTION
postgres=3D# SELECT debug_func2('=D1=82=D0=B5= =D1=81=D1=82'::text, user::text);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 debug_func2
-------------------------------= ---------------
=C2=A0param1 collation: "C", param2 collation:= "C"
(1 row)

postgres=3D#

My o= bservation is the user, current* functions collation=C2=A0is "C" = collation and when a "C" collation is passed as a parameter, it c= onverts all the parameters to use the "C" collation.

I was= looking at=C2=A0sql_fn_make_param() function and the comments over their s= ay
"/*
* If we have a function input collation, allow it to = override the
* type-derived collation for parameter symbols. =C2=A0(XX= X perhaps this should
* not happen if the type collation is not defaul= t?)
*/
"
From the above code comment it looks like the &quo= t;C" collation is overriding the type-driven collation, and this might= be causing the issue.

I am currently using gdb to debug more and wi= ll work on a patch based on my findings.

Regards,
Surya Poondla
--000000000000a18189064a7f4127--