Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 086EF37B9C5 for ; Tue, 7 Oct 2008 03:44:42 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 00420-08 for ; Tue, 7 Oct 2008 03:44:39 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.185]) by postgresql.org (Postfix) with ESMTP id EDE6E37B9AE for ; Tue, 7 Oct 2008 03:44:38 -0300 (ADT) Received: by nf-out-0910.google.com with SMTP id c7so1190646nfi.23 for ; Mon, 06 Oct 2008 23:44:37 -0700 (PDT) Received: by 10.210.18.8 with SMTP id 8mr7540336ebr.189.1223361876947; Mon, 06 Oct 2008 23:44:36 -0700 (PDT) Received: from ?80.222.33.27? (dsl-hkibrasgw2-fe21de00-27.dhcp.inet.fi [80.222.33.27]) by mx.google.com with ESMTPS id g12sm7402933nfb.28.2008.10.06.23.44.35 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 06 Oct 2008 23:44:36 -0700 (PDT) Message-ID: <48EB0551.50205@enterprisedb.com> Date: Tue, 07 Oct 2008 09:44:33 +0300 Organization: EnterpriseDB User-Agent: Mozilla-Thunderbird 2.0.0.16 (X11/20080724) MIME-Version: 1.0 To: Emmanuel Cecchet CC: pgsql-hackers@postgresql.org Subject: Re: Transactions and temp tables References: <48EA7B12.6050906@frogthinker.org> In-Reply-To: <48EA7B12.6050906@frogthinker.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit From: Heikki Linnakangas X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200810/244 X-Sequence-Number: 125261 Emmanuel Cecchet wrote: > Instead of relying on a boolean that tells if a temp table was accessed, > I keep a list of the Oid for the temp tables accessed in the transaction > and at prepare commit time, I check if the relations are still valid. I > also added a check to allow empty temp tables at prepare commit time > (this allows to use temp tables with 'on commit delete rows' options. > > I am attaching the patch and the use cases I have been using to test it. > The test cases try to compile the various use cases that I have seen > reported on the list. Thanks for looking into this. The patch allows preparing any transaction that has dropped the temp table, even if it wasn't created in the same transaction. Is that sane? 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. The fixed-size array of temp table oids is an unnecessary limitation. A list or hash table would be better. > Let me know what you think of the patch and if it > could be applied to 8.3 and 8.4? Not to 8.3. We only back-patch bug-fixes, and this isn't one. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com