Re: psql: Add command to use extended query protocol

From: Simon Riggs <simon(dot)riggs(at)enterprisedb(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql: Add command to use extended query protocol
Date: 2022-11-01 22:58:52
Message-ID: CANbhV-Gv8s4n+hBMa++DmCeEuY30v0WbAzLcBTjYhK=47vvuDQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 1 Nov 2022 at 20:48, Peter Eisentraut
<peter(dot)eisentraut(at)enterprisedb(dot)com> wrote:
>
> On 01.11.22 10:10, Simon Riggs wrote:
> > On Fri, 28 Oct 2022 at 07:53, Peter Eisentraut
> > <peter(dot)eisentraut(at)enterprisedb(dot)com> wrote:
> >>
> >> This adds a new psql command \gp that works like \g (or semicolon) but
> >> uses the extended query protocol. Parameters can also be passed, like
> >>
> >> SELECT $1, $2 \gp 'foo' 'bar'
> >
> > +1 for the concept. The patch looks simple and complete.
> >
> > I find it strange to use it the way you have shown above, i.e. \gp on
> > same line after a query.
>
> That's how all the "\g" commands work.

Yes, I see that, but it also works exactly the way I said also.

i.e.
SELECT 'foo'
\g

is the same thing as

SELECT 'foo' \g

But there are no examples in the docs of the latter usage, and so it
is a surprise to me and probably to others also

> > ...since if we used this in a script, it would be used like this, I think...
> >
> > SELECT $1, $2
> > \gp 'foo' 'bar'
> > \gp 'bar' 'baz'
> > ...
>
> Interesting, but I think for that we should use named prepared
> statements, so that would be a separate "\gsomething" command in psql, like
>
> SELECT $1, $2 \gprep p1
> \grun p1 'foo' 'bar'
> \grun p1 'bar' 'baz'

Not sure I understand this... you seem to be arguing against your own
patch?? I quite liked the way you had it, I'm just asking for the docs
to put the \gp on the following line.

--
Simon Riggs http://www.EnterpriseDB.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jacob Champion 2022-11-01 23:02:21 Re: User functions for building SCRAM secrets
Previous Message Andres Freund 2022-11-01 22:54:02 Re: Direct I/O