Re: Using current_user as an argument of pl/pgsql function affects collation of other arguments

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Using current_user as an argument of pl/pgsql function affects collation of other arguments
Дата
Msg-id 613285.1723753952@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Using current_user as an argument of pl/pgsql function affects collation of other arguments  (Dmytro Astapov <dastapov@gmail.com>)
Список pgsql-bugs
Dmytro Astapov <dastapov@gmail.com> writes:
> As the subject implies, I am observing that
> current_user/session_user/current_database/current_schema, when used as an
> argument for pl/pgsql function, could affect execution plans of unrelated
> queries inside that pl/pgsql function -- because they seemingly affect
> collation for other arguments (I am not 100% sure about this last claim,
> but the observed effects suggest that this might be the case).

This is expected behavior.  Those functions return type "name" not
"text", and "name" is considered to have C collation.  Then, in
a call such as

    select_test('1',current_user);

that is the only source of collation in the expression and so
select_test is invoked with an input collation of "C", rather
than whatever the database's default is.

The most robust solution probably is to write

       explain select *
         from tbl
         where id = id_to_update COLLATE "default"

            regards, tom lane



В списке pgsql-bugs по дате отправления: