Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 9BA51632A8F for ; Sat, 24 Apr 2010 00:29:00 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 04216-02 for ; Sat, 24 Apr 2010 03:28:50 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 197A0632210 for ; Sat, 24 Apr 2010 00:28:50 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o3O3Smdr024899; Fri, 23 Apr 2010 23:28:48 -0400 (EDT) To: Robert Haas cc: pgsql-hackers@postgresql.org Subject: Re: global temporary tables In-reply-to: References: <24194.1272078682@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Fri, 23 Apr 2010 23:18:29 -0400" Date: Fri, 23 Apr 2010 23:28:48 -0400 Message-ID: <24898.1272079728@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201004/1102 X-Sequence-Number: 161214 Robert Haas writes: > On Fri, Apr 23, 2010 at 11:11 PM, Tom Lane wrote: >> I also kind of wonder what is supposed to happen if someone DROPs or >> ALTERs the temp table definition ... > ...not so much. Here you REALLY want a DROP attempt to acquire an > AccessExclusiveLock that will conflict with any outstanding > AccessShareLocks. Similarly, you're only going to be able to modify > the schema for the relation if it's not otherwise in use. I think you're presuming the answer to the question. We could also view the desired behavior as being that each session clones the temp table definition at some instant (eg, first use). The approach that you're assuming seems fraught with large downsides: in particular, implementing ALTER TABLE would be a mess. The would-be alterer would need access to the physical copies of all sessions, which throws out not only the assumption that the relmapper entries can be private data, but all of the access optimizations we currently have in the local buffer manager. Not to mention the coding mess of having to repeat the ALTER operation for each of N copies, some of which might disappear while we're trying to do it (or if they don't, we're blocking backends from exiting). I don't even know how you'd do the ALTER over again N times if you only have one set of catalog entries describing the N copies. regards, tom lane