Frank van Vugt <ftm.van.vugt@foxi.nl> writes:
> While running 2 sessions in different terminals for the same user, what
> happens in the second session here looks a bit weird:
In the first place, you are evidently running as superuser, which means
that has_foo_privilege will ALWAYS say 't' (except possibly if the
target object doesn't exist, in which case I think you get an error).
In the second place, trying to access another session's temp table is
unsupported.
> In this light, is there a possibility to find out what schema will be used for
> temporary tables created during the current session?
After you've created at least one temp table, you can look at the result
of "current_schemas(true)". There's no guarantee that the schema even
exists before you've created something...
regression=# select current_schemas(true);
current_schemas
---------------------
{pg_catalog,public}
(1 row)
regression=# create temp table t(f1 int);
CREATE TABLE
regression=# select current_schemas(true);
current_schemas
-------------------------------
{pg_temp_1,pg_catalog,public}
(1 row)
regression=# select (current_schemas(true))[1];
current_schemas
-----------------
pg_temp_1
(1 row)
regression=#
regards, tom lane