Re: pgbench - allow to store select results into variables

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: 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-13 20:16:25
Message-ID: alpine.DEB.2.20.1607132140100.26777@sto
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hello Robert,

> I agree: I like \into.

Great!

> But:
>
>> SELECT 1, 2 \; SELECT 3;
>> \into one two three
>
> I think that's pretty weird.

I agree that it is weird, but I do not think that it is bad.

Sending a batch of requests is a feature of libpq which is accessible
through pgbench by using "\;", although the fact is not documented. It
makes sense for a client to send independent queries together so as to
reduce latency.

From pgbench perspective, I would find it pretty weird as well that one
can send several queries together but could only read the answer from...
say the first one, and the others would be lost.

From an implementation perspective doing it is straightforward, and
rejecting it would require some more logic.

An obvious nicer feature would be to allow intermixing \into & \; but ISTM
that it would require to rethink deeply pgbench lexing/parsing which has
just been merged with psql by Tom and others...

If I had not pointed out the fact that it works, maybe no one would have
noticed... so a compromise could be not to advertise the fact that it
works (as the \; feature is not advertised anyway), but letting the
implementation do it because it is simple and may be useful, and rephrase
the documentation so that it is just about the previous select and not
previous select*S*?

--
Fabien.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-07-13 20:16:32 Re: sslmode=require fallback
Previous Message Tom Lane 2016-07-13 20:13:43 Re: pgbench - allow to store select results into variables