Re: has_table/schema_privilige() returns incorrect info on temp tables - Mailing list pgsql-bugs

From Tom Lane
Subject Re: has_table/schema_privilige() returns incorrect info on temp tables
Date
Msg-id 22201.1141075161@sss.pgh.pa.us
Whole thread Raw
In response to has_table/schema_privilige() returns incorrect info on temp tables  (Frank van Vugt <ftm.van.vugt@foxi.nl>)
List pgsql-bugs
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

pgsql-bugs by date:

Previous
From: Frank van Vugt
Date:
Subject: has_table/schema_privilige() returns incorrect info on temp tables
Next
From: Frank van Vugt
Date:
Subject: Re: has_table/schema_privilige() returns incorrect info on temp tables