Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bNQNw-0007hA-M6 for pgsql-hackers@arkaria.postgresql.org; Wed, 13 Jul 2016 20:03:56 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bNQNw-0004Tw-98 for pgsql-hackers@arkaria.postgresql.org; Wed, 13 Jul 2016 20:03:56 +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 1bNQMZ-0002vt-Q0 for pgsql-hackers@postgresql.org; Wed, 13 Jul 2016 20:02:31 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bNQMW-0005lv-GN for pgsql-hackers@postgresql.org; Wed, 13 Jul 2016 20:02:30 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u6DK2N6R032185; Wed, 13 Jul 2016 16:02:23 -0400 From: Tom Lane To: Robert Haas cc: Fabien COELHO , Pavel Stehule , PostgreSQL Developers Subject: Re: pgbench - allow to store select results into variables In-reply-to: References: Comments: In-reply-to Robert Haas message dated "Wed, 13 Jul 2016 14:34:24 -0500" Date: Wed, 13 Jul 2016 16:02:23 -0400 Message-ID: <32184.1468440143@sss.pgh.pa.us> 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 Robert Haas writes: > On Sat, Jul 9, 2016 at 7:52 AM, Fabien COELHO wrote: >> If someone thinks that "gset" is a good idea for pgbench, which I don't, it >> could be implemented. I think that an "into" feature, like PL/pgSQL & ECPG, >> makes more sense for scripting. > I agree: I like \into. > But: >> SELECT 1, 2 \; SELECT 3; >> \into one two three > I think that's pretty weird. 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 but I do not think that a metacommand on a following line should retroactively affect the execution of a prior command, much less commands before the last one. Even if this happens to be easy to do in pgbench's existing over-contorted logic, it's tremendously confusing to the user; and it might be much less easy if we try to refactor that logic. And I'm with Pavel on this: it should work exactly like \gset. Inventing \into to do almost the same thing in a randomly different way exhibits a bad case of NIH syndrome. Sure, you can argue about how it's not quite the same use-case and so you could micro-optimize by doing it differently, but that's ignoring the cognitive load on users who have to remember two different commands. Claiming that plpgsql's SELECT INTO is a closer analogy than psql's \gset is quite bogus, too: the environment is different (client side vs server side, declared vs undeclared target variables), and the syntax is different (backslash or not, commas or not, just for starters). I note also that we were talking a couple months ago about trying to align psql and pgbench backslash commands more closely. This would not be a good step in that direction. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers