Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 3E99414D378 for ; Sun, 18 Mar 2012 16:12:30 -0300 (ADT) Received: from acidenitrix.villemain.org ([91.121.90.165]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1S9LWm-00057P-29 for pgsql-hackers@postgresql.org; Sun, 18 Mar 2012 19:12:29 +0000 Received: from 89-158-241-83.rev.dartybox.com ([89.158.241.83] helo=DimIMac.local) by acidenitrix.villemain.org with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1S9LWW-0002fu-3s; Sun, 18 Mar 2012 20:12:12 +0100 Received: by DimIMac.local (Postfix, from userid 501) id 516593D78639; Sun, 18 Mar 2012 20:12:04 +0100 (CET) From: Dimitri Fontaine To: Tom Lane Cc: Andres Freund , pgsql-hackers@postgresql.org, Thom Brown , Dimitri Fontaine Subject: Re: Command Triggers, patch v11 Organization: 2ndQuadrant References: <9503.1332006327@sss.pgh.pa.us> <24814.1332021870@sss.pgh.pa.us> <201203172326.53461.andres@anarazel.de> <18353.1332095370@sss.pgh.pa.us> User-Mail-Address: dimitri@2ndQuadrant.fr Date: Sun, 18 Mar 2012 20:12:03 +0100 In-Reply-To: <18353.1332095370@sss.pgh.pa.us> (Tom Lane's message of "Sun, 18 Mar 2012 14:29:30 -0400") Message-ID: User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.94 (darwin) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201203/1200 X-Sequence-Number: 205082 Tom Lane writes: > 1. ExecuteQuery still has to know that's a CREATE TABLE AS operation so > that it can enforce that the prepared query is a SELECT. (BTW, maybe > this should be weakened to "something that returns tuples", in view of > RETURNING?) That lights a bulb: what about rewriting CREATE TABLE AS as two commands, internally: 1. CREATE TABLE =E2=80=A6 2. WITH x ( ) INSERT INTO =E2=80=A6 SELECT * FROM x; It seems like not solving much from a practical point of view though as you need to be able to parse the output of the subquery before you can do the first step, but on the other hand it might be that you already have the pieces to just do that. Well, I had to share that though, somehow. Regards, -- Dimitri Fontaine http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support