Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id DE3A014D378 for ; Sun, 18 Mar 2012 15:29:50 -0300 (ADT) Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1S9KrW-0006K1-4a for pgsql-hackers@postgresql.org; Sun, 18 Mar 2012 18:29:50 +0000 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 q2IITUq4018354; Sun, 18 Mar 2012 14:29:30 -0400 (EDT) To: Andres Freund cc: pgsql-hackers@postgresql.org, Thom Brown , Dimitri Fontaine Subject: Re: Command Triggers, patch v11 In-reply-to: <201203172326.53461.andres@anarazel.de> References: <9503.1332006327@sss.pgh.pa.us> <24814.1332021870@sss.pgh.pa.us> <201203172326.53461.andres@anarazel.de> Comments: In-reply-to Andres Freund message dated "Sat, 17 Mar 2012 23:26:53 +0100" Date: Sun, 18 Mar 2012 14:29:30 -0400 Message-ID: <18353.1332095370@sss.pgh.pa.us> From: Tom Lane X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201203/1199 X-Sequence-Number: 205081 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?) 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.) 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. regards, tom lane