Re: psql: Add command to use extended query protocol
От | Corey Huinker |
---|---|
Тема | Re: psql: Add command to use extended query protocol |
Дата | |
Msg-id | CADkLM=ePHZzMcJwbmzGFB7tvm7tm4Fx-_yx-o+wvwwUAvN0E5Q@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: psql: Add command to use extended query protocol (Peter Eisentraut <peter.eisentraut@enterprisedb.com>) |
Ответы |
Re: psql: Add command to use extended query protocol
|
Список | pgsql-hackers |
On Tue, Nov 15, 2022 at 8:29 AM Peter Eisentraut <peter.eisentraut@enterprisedb.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?
В списке pgsql-hackers по дате отправления: