Re: Possibly a bug

From: surya poondla <suryapoondla4(at)gmail(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: Анатолий <anatoly(at)email(dot)su>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: Possibly a bug
Date: 2026-02-10 21:51:11
Message-ID: CAOVWO5oT0x9snrGFPgoWc+-2sBcYSgm+aU=DbiZHWM_HXTbfYg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2026-02-10 22:34:37 Re: Possibly a bug
Previous Message Andres Freund 2026-02-10 19:58:33 Re: BUG #19400: Memory leak in checkpointer and startup processes on PostgreSQL 18