agora inbox for [email protected]  
help / color / mirror / Atom feed
From: Heikki Linnakangas <[email protected]>
To: Emmanuel Cecchet <[email protected]>
Cc: [email protected]
Subject: Re: Transactions and temp tables
Date: Wed, 08 Oct 2008 12:34:45 +0300
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<[email protected]>
	<[email protected]>

Emmanuel Cecchet wrote:
>> Also, even if the table is created and dropped in the same 
>> transaction, a subsequent transaction that tries to create and drop 
>> the table gets blocked on the lock. I suppose we could just say that 
>> that's the way it works, but I'm afraid it will come as a nasty 
>> surprise, making the feature a lot less useful.
> I do not get that one, if the table is dropped in the transaction the 
> lock is released. Why would another transaction be blocked when trying 
> to create/drop another temp table?

I was thinking of a transaction that's just prepared (1st phase), but 
not committed or rolled back:

postgres=# CREATE TEMP TABLE foo (bar int);
CREATE TABLE
postgres=# BEGIN;
BEGIN
postgres=# DROP TABLE foo;
DROP TABLE
postgres=# PREPARE TRANSACTION '2pc';
PREPARE TRANSACTION
postgres=# SELECT * FROM foo;
<blocks>

Furthermore, it looks like the backend refuses to shut down, even if you 
end the psql session, because RemoveTempRelations() is called on backend 
shutdown and it gets blocked on that lock.

-- 
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com



view thread (37+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: Transactions and temp tables
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox