Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id A05E2C7DB10 for ; Mon, 19 Mar 2012 10:13:48 -0300 (ADT) Received: from mail.anarazel.de ([217.115.131.40]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1S9cPA-0007pG-LD for pgsql-hackers@postgresql.org; Mon, 19 Mar 2012 13:13:47 +0000 Received: from intern.anarazel.de (host90-152-20-147.ipv4.regusnet.com [90.152.20.147]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPA id 974C4480004; Mon, 19 Mar 2012 14:13:30 +0100 (CET) From: Andres Freund To: Tom Lane Subject: Re: Command Triggers, patch v11 Date: Mon, 19 Mar 2012 14:13:26 +0100 User-Agent: KMail/1.13.7 (Linux/3.3.0-rc5-andres-00066-g500dd23; KDE/4.6.5; x86_64; ; ) Cc: pgsql-hackers@postgresql.org, Thom Brown , Dimitri Fontaine References: <201203172326.53461.andres@anarazel.de> <18353.1332095370@sss.pgh.pa.us> In-Reply-To: <18353.1332095370@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201203191413.26729.andres@anarazel.de> X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201203/1219 X-Sequence-Number: 205101 On Sunday, March 18, 2012 07:29:30 PM Tom Lane wrote: > BTW, I've been looking through how to do what I suggested earlier to get > rid of the coziness and code duplication between CreateTableAs and the > prepare.c code; namely, let CreateTableAs create a DestReceiver and then > call ExecuteQuery with that receiver. It appears that we still need at > least two bits of added complexity with that approach: > > 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?) I don't really see the use case but given the amount of work it probably takes it seems reasonable to allow that. > 2. Since ExecuteQuery goes through the Portal machinery, there's no way > for it to pass in eflags to control the table OIDs setup. This is > easily solved by adding an eflags parameter to PortalStart, which > doesn't seem too awful to me, since the typical caller would just pass > zero. (ExecuteQuery would also have to know about testing > interpretOidsOption to compute the eflags to use, unless we add an > eflags parameter to it, which might be the cleaner option.) If we go down this route I think adding an eflag is the better choice. Thinking of it - my patch already added that ;) > In short I'm thinking: add an eflags parameter to PortalStart, and add > both an eflags parameter and a "bool mustReturnTuples" parameter to > ExecuteQuery. This definitely seems cleaner than the current > duplication of code. Hm. I am not *that* convinced anymore. It wasn't that much duplication in the end... Andres