current_user -------------- sfrost (1 row) role ------ none (1 row) temp_tablespaces ------------------ rn_temp_01 (1 row) List of tablespaces Name | Owner | Location | Access privileges | Description ------------+--------+-------------------------------------------+-------------------+------------- rn_temp_01 | sfrost | /var/lib/postgresql/rn_tblspcs/rn_temp_01 | | (1 row) create function test_func () returns int language plpgsql security definer as begin create temporary table test2 (a int); return 1; end;; CREATE FUNCTION List of functions Schema | Name | Result data type | Argument data types | Type | Volatility | Owner | Language | Source code | Description --------+-----------+------------------+---------------------+--------+------------+--------+----------+------------------------------------------------------------+------------- public | test_func | integer | | normal | volatile | sfrost | plpgsql | begin create temporary table test2 (a int); return 1; end; | (1 row) drop role if exists test_role; DROP ROLE create role test_role; CREATE ROLE set role test_role; SET create temporary table test (a int); CREATE TABLE relname | reltablespace ---------+--------------- test | 0 (1 row) test_func ----------- 1 (1 row) relname | reltablespace ---------+--------------- test2 | 0 (1 row)