public inbox for [email protected]  
help / color / mirror / Atom feed
From: surya poondla <[email protected]>
To: jian he <[email protected]>
Cc: Анатолий <[email protected]>
Cc: [email protected]
Subject: Re: Possibly a bug
Date: Tue, 10 Feb 2026 13:51:11 -0800
Message-ID: <CAOVWO5oT0x9snrGFPgoWc+-2sBcYSgm+aU=DbiZHWM_HXTbfYg@mail.gmail.com> (raw)
In-Reply-To: <CACJufxEQNSkZWRoTUGX+y9xBUJZyxrFkoxdeHR7siaPL_LLh1Q@mail.gmail.com>
References: <[email protected]>
	<CAOVWO5osy_PbZnbdGH0QZgL0LpkrhrQ475MJLX80ioASBBhOkw@mail.gmail.com>
	<CACJufxEQNSkZWRoTUGX+y9xBUJZyxrFkoxdeHR7siaPL_LLh1Q@mail.gmail.com>

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=# SELECT collation for (user);
 pg_collation_for
------------------
 "C"
(1 row)

postgres=# SELECT collation for (current_user);
 pg_collation_for
------------------
 "C"
(1 row)

postgres=#   SELECT to_upper_varchar('тест'::varchar);
 to_upper_varchar
------------------
 ТЕСТ
(1 row)

postgres=#   SELECT collation for ('тест');
 pg_collation_for
------------------

(1 row)

postgres=#   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=#   SELECT debug_func('тест', user::text);
                 debug_func
----------------------------------------------
 param1 collation: "C", param2 collation: "C"
(1 row)

postgres=#   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=# SELECT debug_func2('тест'::text, user::text);
                  debug_func2
----------------------------------------------
 param1 collation: "C", param2 collation: "C"
(1 row)

postgres=#

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


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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Possibly a bug
  In-Reply-To: <CAOVWO5oT0x9snrGFPgoWc+-2sBcYSgm+aU=DbiZHWM_HXTbfYg@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox