Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id A36FD176E18D for ; Sat, 17 Mar 2012 19:27:19 -0300 (ADT) Received: from mail.anarazel.de ([217.115.131.40]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1S925i-0000Cx-Ih for pgsql-hackers@postgresql.org; Sat, 17 Mar 2012 22:27:18 +0000 Received: by mail.anarazel.de (Postfix, from userid 108) id 83035450008; Sat, 17 Mar 2012 23:27:00 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on mail X-Spam-Level: X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.2.5 Received: from anarazel.de (brln-4d0cdc97.pool.mediaWays.net [77.12.220.151]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id 4CB57450006; Sat, 17 Mar 2012 23:26:54 +0100 (CET) Received: by anarazel.de (Postfix, from userid 1000) id 9E3691C00AB; Sat, 17 Mar 2012 23:26:53 +0100 (CET) From: Andres Freund To: Tom Lane Subject: Re: Command Triggers, patch v11 Date: Sat, 17 Mar 2012 23:26:53 +0100 User-Agent: KMail/1.13.7 (Linux/3.3.0-rc3-andres-00278-g4903062; KDE/4.6.5; x86_64; ; ) Cc: pgsql-hackers@postgresql.org, Thom Brown , Dimitri Fontaine References: <9503.1332006327@sss.pgh.pa.us> <24814.1332021870@sss.pgh.pa.us> In-Reply-To: <24814.1332021870@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201203172326.53461.andres@anarazel.de> X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201203/1169 X-Sequence-Number: 205051 On Saturday, March 17, 2012 11:04:30 PM Tom Lane wrote: > I've found a couple more issues in the CTAS patch: > > 1. Previous versions delivered a "SELECT n" command tag for either > spelling of the command: > > regression=# select * into t1 from int8_tbl; > SELECT 6 > regression=# create table t2 as select * from int8_tbl; > SELECT 6 > > With the patch I get > > regression=# select * into t1 from int8_tbl; > SELECT 0 0 hm. Stupid me. > regression=# create table t2 as select * from int8_tbl; > CREATE TABLE AS > > The first of these is particularly unfortunate since it's outright lying > as to the number of rows processed. > I'm not sure what we should do instead. We have gotten push-back before > anytime we changed the command tag for an existing command (and in fact > it seems that we intentionally added the rowcount display in 9.0, which > means there are people out there who care about that functionality). > On the other hand, the traditional output for CREATE TABLE AS doesn't > seem to satisfy the principle of least astonishment. A third > consideration is that if we are pushing CREATE TABLE AS as the preferred > spelling, people will probably complain if it omits functionality that > SELECT INTO provides; so I'm not sure that "SELECT n" in one case and > "CREATE TABLE AS" in the other would be a good idea either. Any > opinions what to do here? I would prefer both returning CREATE TABLE AS since thats what actually happens. We already document that SELECT INTO is kinda deprecated: "The PostgreSQL usage of SELECT INTO to represent table creation is historical. It is best to use CREATE TABLE AS for this purpose in new code." I have seen code that uses the command code for selecting the, app level, logging. Its kinda hard to do that if a CREATE TABLE AS/SELECT INTO returns SELECT. Does CTAS ommit any functionality currently? I don't see any reason not to support stuff there thats supported in SELECT INTO. > 2. Historically, CREATE RULE has allowed a rule action to be SELECT INTO > (though not CREATE TABLE AS). Currently the patch is throwing an error > for that. This seems like something that might not be worth fixing, > though. It's fairly hard to conceive of a use-case for such a rule, > since it would work only once before starting to throw "table already > exists" errors. How much do we care about preserving backward > compatibility here? I vote for not supporting that anymore. That being possible looks more like an implementation detail to me. Thanks for looking at this! Andres