From: | Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Robert Haas <robertmhaas(at)gmail(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: pgbench - allow to store select results into variables |
Date: | 2016-07-15 16:33:33 |
Message-ID: | alpine.DEB.2.20.1607151820160.7291@sto |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello again,
> I'd be okay with
>
> SELECT 1, 2 \into one two
> SELECT 3 \into three
Here is a v2 with more or less this approach, although \into does not end
the query, but applies to the current or last sql command. A query is
still terminated with a ";".
Now it handles things like :
-- standard sql command
SELECT balance FROM bank WHERE id=1;
\into balance
-- compound sql command, three == 3.
SELECT 1, 2 \; SELECT 3 ;
\into three
-- compound query with 2 selects & 3 variables
SELECT i \into one
FROM generate_series(1, 1) AS i \;
SELECT i+1, i+2 \into two three
FROM generate_series(1, 1) AS i ;
I had to add a few lines in psql scanner to count "\;", so the parsing
logic is a little more complicated than before.
--
Fabien.
Attachment | Content-Type | Size |
---|---|---|
pgbench-into-2.patch | text/x-diff | 16.2 KB |
into.sql | application/x-sql | 295 bytes |
into2.sql | application/x-sql | 733 bytes |
into-err-1.sql | application/x-sql | 31 bytes |
into-err-2.sql | application/x-sql | 47 bytes |
into-err-3.sql | application/x-sql | 76 bytes |
into-err-4.sql | application/x-sql | 42 bytes |
into-err-5.sql | application/x-sql | 75 bytes |
into-err-6.sql | application/x-sql | 88 bytes |
into-err-7.sql | application/x-sql | 46 bytes |
into-err-8.sql | application/x-sql | 56 bytes |
into-err-9.sql | application/x-sql | 37 bytes |
into-err-10.sql | application/x-sql | 35 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | james | 2016-07-15 16:43:22 | Re: One process per session lack of sharing |
Previous Message | Teodor Sigaev | 2016-07-15 16:27:23 | Re: BUG #14245: Segfault on weird to_tsquery |