Re: Transactions and temp tables

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Emmanuel Cecchet <manu(at)frogthinker(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Transactions and temp tables
Date: 2008-10-08 09:34:45
Message-ID: 48EC7EB5.5020001@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2008-10-08 10:33:54 problem with compilation on fedora core 10 64 bit
Previous Message Simon Riggs 2008-10-08 09:10:26 Re: Reducing some DDL Locks to ShareLock