The scenario
CREATE SCHEMA testschema;
CREATE ROLE testrole LOGIN;
GRANT ALL ON SCHEMA testschema TO testrole;
ALTER ROLE testrole SET search_path = testschema;
Now if I initiate the connection (log in) as testrole then:
SHOW search_path;
Gives the desired result:
search_path
-------------
testschema
(1 row)
However, if I initiate connection (log in) as a superuser and do:
SET SESSION AUTHORIZATION testrole;
SHOW search_path;
Results in:
search_path
----------------
"$user",public
(1 row)
(or whatever the search path of the superuser is)
My question is, why does SET SESSION AUTHORIZATION not affect the current search_path?
Is it a bug, by design or am I simply doinitwrong?
From the little I’ve found, the workaround of SET SEARCH path = schemaname after SET SESSION... seems to be the only solution, but that kind of defeats the purpose of having persistent search paths assigned to roles.
This is by design. I quote the manual on
ALTER ROLE