Re: Transactions and temp tables - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Transactions and temp tables
Date
Msg-id 29132.1223475486@sss.pgh.pa.us
Whole thread Raw
In response to Re: Transactions and temp tables  (Emmanuel Cecchet <manu@frogthinker.org>)
Responses Re: Transactions and temp tables
Re: Transactions and temp tables
List pgsql-hackers
Emmanuel Cecchet <manu@frogthinker.org> writes:
> Ok, so actually I don't see any different behavior between a temp table 
> or a regular table. The locking happens the same way and as long as the 
> commit prepared happens (potentially in another session), the lock is 
> released at commit time which seems to make sense.

Right, the problem is that you can't shut down the original backend
because it'll try to drop the temp table at exit, and then block on
the lock that the prepared xact is holding.  From a database management
standpoint that is unacceptable --- it means for instance that you can't
shut down the database cleanly while such a prepared transaction is
pending.  The difference from a regular table is that no such automatic
action is taken at backend exit for regular tables.

The whole business of having restrictions on temp table access is
annoying; I wish we could get rid of them not add complexity to
enforcing them.  The local-buffer-management end of the issue seems
readily solvable: we need only decree that PREPARE has to flush out any
dirty local buffers (and maybe discard local buffers altogether, not
sure).  But I've not been able to see a decent solution to the lock
behavior.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Chris Mayfield
Date:
Subject: Re: Building Postgres in Eclipse
Next
From: Alvaro Herrera
Date:
Subject: autovacuum and reloptions