Re: search_path and SET ROLE

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: search_path and SET ROLE
Дата
Msg-id 4165841.1716397819@sss.pgh.pa.us
обсуждение исходный текст
Ответ на search_path and SET ROLE  (Ron Johnson <ronljohnsonjr@gmail.com>)
Ответы Re: search_path and SET ROLE
Список pgsql-general
Ron Johnson <ronljohnsonjr@gmail.com> writes:
> It seems that the search_path of the role that you SET ROLE to does not
> become the new search_path.

It does for me:

regression=# create role r1;
CREATE ROLE
regression=# create schema r1 authorization r1;
CREATE SCHEMA
regression=# select current_schemas(true), current_user;
   current_schemas   | current_user 
---------------------+--------------
 {pg_catalog,public} | postgres
(1 row)

regression=# set role r1;
SET
regression=> select current_schemas(true), current_user;
    current_schemas     | current_user 
------------------------+--------------
 {pg_catalog,r1,public} | r1
(1 row)

regression=> show search_path ;
   search_path   
-----------------
 "$user", public
(1 row)

The fine manual says that $user tracks the result of
CURRENT_USER, and at least in this example it's doing that.
(I hasten to add that I would not swear there are no
bugs in this area.)

> Am I missing something, or is that PG's behavior?

I bet what you missed is granting (at least) USAGE on the
schema to that role.  PG will silently ignore unreadable
schemas when computing the effective search path.

            regards, tom lane



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Missed compiler optimization issue in function select_rtable_names_for_explain
Следующее
От: Ron Johnson
Дата:
Сообщение: Re: search_path and SET ROLE