Re: psql: Add command to use extended query protocol

From: Corey Huinker <corey(dot)huinker(at)gmail(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-21 22:02:08
Message-ID: CADkLM=ePHZzMcJwbmzGFB7tvm7tm4Fx-_yx-o+wvwwUAvN0E5Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Nov 15, 2022 at 8:29 AM Peter Eisentraut <
peter(dot)eisentraut(at)enterprisedb(dot)com> wrote:

> On 09.11.22 00:12, Corey Huinker wrote:
> > As for the docs, they're very clear and probably sufficient as-is, but I
> > wonder if we should we explicitly state that the bind-state and bind
> > parameters do not "stay around" after the query is executed? Suggestions
> > in bold:
> >
> > This command causes the extended query protocol (see <xref
> > linkend="protocol-query-concepts"/>) to be used, unlike normal
> > <application>psql</application> operation, which uses the
> simple
> > query protocol. *Extended query protocol will be used* *even
> > if no parameters are specified, s*o this command can be useful to test
> > the extended
> > query protocol from psql. *This command affects only the next
> > query executed, all subsequent queries will use the regular query
> > protocol by default.*
> >
> > Tests seem comprehensive. I went looking for the TAP test that this
> > would have replaced, but found none, and it seems the only test where we
> > exercise PQsendQueryParams is libpq_pipeline.c, so these tests are a
> > welcome addition.
> >
> > Aside from the possible doc change, it looks ready to go.
>
> Committed with those doc changes. Thanks.
>
>
I got thinking about this, and while things may be fine as-is, I would like
to hear some opinions as to whether this behavior is correct:

String literals can include spaces

[16:51:35 EST] corey=# select $1, $2 \bind 'abc def' gee \g
?column? | ?column?
----------+----------
abc def | gee
(1 row)

String literal includes spaces, but also includes quotes:

Time: 0.363 ms
[16:51:44 EST] corey=# select $1, $2 \bind "abc def" gee \g
?column? | ?column?
-----------+----------
"abc def" | gee
(1 row)

Semi-colon does not terminate an EQP statement, ';' is seen as a parameter:

[16:51:47 EST] corey=# select $1, $2 \bind "abc def" gee ;
corey-# \g
ERROR: bind message supplies 3 parameters, but prepared statement ""
requires 2

Confirming that slash-commands must be unquoted

[16:52:23 EST] corey=# select $1, $2 \bind "abc def" '\\g' \g
?column? | ?column?
-----------+----------
"abc def" | \g
(1 row)

[16:59:00 EST] corey=# select $1, $2 \bind "abc def" '\watch' \g
?column? | ?column?
-----------+----------
"abc def" | watch
(1 row)

Confirming that any slash command terminates the bind list, but ';' does not

[16:59:54 EST] corey=# select $1, $2 \bind "abc def" gee \watch 5
Mon 21 Nov 2022 05:00:07 PM EST (every 5s)

?column? | ?column?
-----------+----------
"abc def" | gee
(1 row)

Time: 0.422 ms
Mon 21 Nov 2022 05:00:12 PM EST (every 5s)

?column? | ?column?
-----------+----------
"abc def" | gee
(1 row)

Is this all working as expected?

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2022-11-21 22:06:32 Re: HOT chain validation in verify_heapam()
Previous Message Andres Freund 2022-11-21 21:53:52 Re: Damage control for planner's get_actual_variable_endpoint() runaway