Re: Transactions and temp tables

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: Transactions and temp tables
Дата
Msg-id 490F804A.60108@enterprisedb.com
обсуждение исходный текст
Ответ на Re: Transactions and temp tables  (Emmanuel Cecchet <manu@frogthinker.org>)
Ответы Re: Transactions and temp tables  (Emmanuel Cecchet <manu@frogthinker.org>)
Список pgsql-hackers
Emmanuel Cecchet wrote:
> Here is the latest patch and the regression tests for the temp tables 
> and 2PC issue.

This fails:

postgres=# begin;
BEGIN
postgres=# CREATE TEMPORARY TABLE temp1 (id int4);
CREATE TABLE
postgres=# PREPARE TRANSACTION 'foo';
PREPARE TRANSACTION
postgres=# CREATE TEMPORARY TABLE temp2 (id int4);
ERROR:  cannot insert into frozen hashtable "accessed temp tables"

I don't understand the bookkeeping of accessed and prepared temp tables
in general. What's it for?

The comments on preparedTempRel says that it keeps track of "accessed
temporary relations that have been prepared commit but not committed
yet". That's never going to work as a backend-private hash table,
because there's no way to remove entries from it when the prepared
transaction is committed or rolled back from another backend.

What's the purpose of checking that a table is empty on prepare? I think
I'd feel more comfortable with the approach of only accepting PREPARE
TRANSACTIOn if the accessed temp tables have been created and destroyed
in the same transaction, to avoid possibly surprising behavior when a
temp table is kept locked by a prepared transaction and you try to drop
it later in the sesssion, but the patch allows more than that. I guess
accessing an existing ON COMMIT DELETE ROWS temp table would also be OK, but checking that there's no visible rows in
thetable doesn't achieve
 
that.

I don't think you can just ignore "prepared temp relations" in
findDependentObjects to avoid the lockup at backend exit. It's also used
for DROP CASCADE, for example.

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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Vladimir Sitnikov"
Дата:
Сообщение: Re: Bitmap Indexes patch (was Re: Bitmap Indexes: request for feedback)
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Enable pl/python to return records based on multiple OUT params