Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bNvRh-0005gN-5f for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Jul 2016 05:13:53 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bNvRf-0007M0-Oo for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Jul 2016 05:13:51 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bNvRf-0007Lu-7Q for pgsql-hackers@postgresql.org; Fri, 15 Jul 2016 05:13:51 +0000 Received: from jiboia.ensmp.fr ([194.214.158.137]) by makus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bNvRa-0005qj-U3 for pgsql-hackers@postgresql.org; Fri, 15 Jul 2016 05:13:48 +0000 Received: from cri.ensmp.fr (AGrenoble-653-1-69-83.w92-129.abo.wanadoo.fr [92.129.7.83]) (authenticated bits=0) by jiboia.ensmp.fr (8.15.2/8.15.1/JMMC-22/Oct/2013) with ESMTPSA id u6F5DYMO030549 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 15 Jul 2016 07:13:39 +0200 Date: Fri, 15 Jul 2016 07:13:33 +0200 (CEST) From: Fabien COELHO X-X-Sender: fabien@sto To: Tom Lane cc: Robert Haas , Pavel Stehule , PostgreSQL Developers Subject: Re: pgbench - allow to store select results into variables In-Reply-To: <32184.1468440143@sss.pgh.pa.us> Message-ID: References: <32184.1468440143@sss.pgh.pa.us> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-Miltered: at jiboia.ensmp.fr with ID 578870FE.000 by Joe's j-chkmail (http : // j-chkmail dot ensmp dot fr)! X-j-chkmail-Auth: USER-ID fabien.coelho X-j-chkmail-Enveloppe: 578870FE.000 from AGrenoble-653-1-69-83.w92-129.abo.wanadoo.fr/AGrenoble-653-1-69-83.w92-129.abo.wanadoo.fr/92.129.7.83/cri.ensmp.fr/ X-Pg-Spam-Score: -3.2 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Hello Tom, > Yeah, that's seriously nasty action-at-a-distance in my view. I'd be okay > with > > SELECT 1, 2 \into one two > SELECT 3 \into three After giving it some thoughts, it could work on compound commands if \into does not close the current sql command. Something like: SELECT 1, 2 ; \into one two SELECT 3 ; \into three => 2 SQL commands SELECT 1, 2 \; \into one two SELECT 3 ; \into three => 1 compound SQL command I'd like \; or ; to stay mandatory as separators, though. Or at least to be allowed. I'm not quite sure how it could be implemented, though. > And I'm with Pavel on this: it should work exactly like \gset. Hmmm. Maybe I'll do that thing in the end, but I really think than gset only makes sense in interactive context, and is pretty ugly for scripting. > Inventing \into to do almost the same thing in a randomly different way > exhibits a bad case of NIH syndrome. No, it is a question of design suitable to programming: > SELECT 1, 2 \gset v could not set variable "?column?" > Sure, you can argue about how it's not quite the same use-case Indeed, that is my point. > and so you could micro-optimize by doing it differently, No, the underlying implementation is basically the same. > but that's ignoring the cognitive load on users who have to remember two > different commands. I do not buy this argument: It is easier for me to remember that keyword INTO happens to do the same thing the same way in PL/pgSQL and ECPG, although with slightly different syntaxes, than to have to remember psql-specific "gset" which does the same thing but in quite a different way, because it means both another name and another concept. > Claiming that plpgsql's SELECT INTO is a closer analogy than psql's > \gset is quite bogus, too: I disagree. I mentionned ECPG as well. Both ECPG & PLpgSQL are "programming", psql is interactive. > the environment is different (client side vs server side, ECPG is client side. I think that the side does not matter. > declared vs undeclared target variables), Sure, the "gset" hack is only possible for a language without variable declarations... but that does not make it a good idea. > and the syntax is different (backslash or not, commas or not, just for > starters). Sure, different languages do not have the same syntax. -- Fabien. -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers