Unique namespace per session for temp tables?

Started by Emmanuel Cecchetover 16 years ago2 messages
#1Emmanuel Cecchet
manu@asterdata.com

Hi all,

Following the issue with temp tables and 2PC, we thought that each
session in Postgres was supposed to generate a unique namespace for its
temporary tables.
But if we execute the following scenario:
*
First session*.
BEGIN;
CREATE TEMP TABLE foo (x int) ON COMMIT DROP;
PREPARE TRANSACTION 't1';
*Disconnect*.
*Wait* (at least until backend process for first session exits).
*Reconnect new session*.
CREATE TEMP TABLE foo (x int); <-- blocks until t1 commits

The issue we see is that a totally unrelated session (which should have
a unique temporary schema), reuses the temporary schema that is locked
away in the prepared transaction. Isn't that breaking the assumption
that each session should have a unique schema for its temp tables?

Thanks in advance for your insights.
Emmanuel

--
Emmanuel Cecchet
Aster Data Systems
Web: http://www.asterdata.com

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Emmanuel Cecchet (#1)
Re: Unique namespace per session for temp tables?

Emmanuel Cecchet <manu@asterdata.com> writes:

Following the issue with temp tables and 2PC, we thought that each
session in Postgres was supposed to generate a unique namespace for its
temporary tables.

You made that up out of sheer wishful thinking. There is one pg_temp
schema per backendid slot.

regards, tom lane