Skip site navigation (1) Skip section navigation (2)

has_table/schema_privilige() returns incorrect info on temp tables

From: Frank van Vugt <ftm(dot)van(dot)vugt(at)foxi(dot)nl>
To: pgsql-bugs(at)postgresql(dot)org
Subject: has_table/schema_privilige() returns incorrect info on temp tables
Date: 2006-02-27 21:01:17
Message-ID: 200602272201.17363.ftm.van.vugt@foxi.nl (view raw or flat)
Thread:
Lists: pgsql-bugs
Hi,

While running 2 sessions in different terminals for the same user, what 
happens in the second session here looks a bit weird:

=========
<session 1>
=========
db=# create temp table t_test (id int);
CREATE TABLE

db=# select table_schema from information_schema.tables 
	where table_name = 't_test';
 table_schema
--------------
 pg_temp_2
(1 row)

db=# select has_schema_privilege('pg_temp_2', 'usage');
 has_schema_privilege
----------------------
 t
(1 row)

db=# select has_table_privilege('pg_temp_2.t_test', 'insert');
 has_table_privilege
---------------------
 t
(1 row)

db=# select has_table_privilege('t_test', 'insert');
 has_table_privilege
---------------------
 t
(1 row)

db=# insert into t_test values (1);
INSERT 0 1

=========
<session 2>
=========

db=# select table_schema from information_schema.tables 
	where table_name = 't_test';
 table_schema
--------------
 pg_temp_2
(1 row)

db=# select has_schema_privilege('pg_temp_2', 'usage');
 has_schema_privilege
----------------------
 t
(1 row)

db=# select has_table_privilege('pg_temp_2.t_test', 'insert');
 has_table_privilege
---------------------
 t
(1 row)

db=# select has_table_privilege('t_test', 'insert');
ERROR:  relation "t_test" does not exist

db=# insert into t_test values (1);
ERROR:  relation "t_test" does not exist



db=# select version();
                                version
------------------------------------------------------------------------
 PostgreSQL 8.1.3 on i586-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2.3
(1 row)



In this light, is there a possibility to find out what schema will be used for 
temporary tables created during the current session? I need to find out 
whether a specific temporary table exists and is accessible for the current 
user in the current session.



-- 
Best,




Frank.

Responses

pgsql-bugs by date

Next:From: Tom LaneDate: 2006-02-27 21:19:21
Subject: Re: has_table/schema_privilige() returns incorrect info on temp tables
Previous:From: Tanguy MOALDate: 2006-02-27 18:41:54
Subject: BUG #2287: Probably a translation error

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group