Re: Temporary tables - Mailing list pgsql-sql

From Tom Lane
Subject Re: Temporary tables
Date
Msg-id 6294.1064682565@sss.pgh.pa.us
Whole thread Raw
In response to Temporary tables  ("George A.J" <jinujosein@yahoo.com>)
List pgsql-sql
"George A.J" <jinujosein@yahoo.com> writes:
> When i searched the pg_class i found the temp table name more than once. 
> ie, a temporary table is created for each connection.I cannot distingush 
> the temp tables. But the tables are in different schema.
> Is there a method to get the current temporary schema?

Not directly, but you could try something like
perform * from pg_class where  relname = 'mytable' and pg_table_is_visible(oid);if not found then ...  -- create the
table

The visibility test would not succeed for temp tables belonging to other
backends.  (If 'mytable' is also used as the name of a regular table
then this isn't quite good enough, but I think just avoiding such a name
collision is easier than extending the check to reject non-temp tables.)
        regards, tom lane


pgsql-sql by date:

Previous
From: Richard Huxton
Date:
Subject: Re: Temporary tables
Next
From: Bertrand Petit
Date:
Subject: pg_class.relpages