Re: BUG #17235: PQsendQuery (with two sql) after PQenterPipelineMode cause ERROR

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: BUG #17235: PQsendQuery (with two sql) after PQenterPipelineMode cause ERROR
Дата
Msg-id CAKFQuwYrAoY6oF2j8Xc40o4x9v8fBTEet7stTpi_AWeVuBJHNA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: BUG #17235: PQsendQuery (with two sql) after PQenterPipelineMode cause ERROR  ("Daniel Verite" <daniel@manitou-mail.org>)
Ответы Re: BUG #17235: PQsendQuery (with two sql) after PQenterPipelineMode cause ERROR  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Список pgsql-bugs
On Wed, Oct 20, 2021 at 2:21 AM Daniel Verite <daniel@manitou-mail.org> wrote:
        PG Bug reporting form wrote:

> I use libpq in C.
> I call PQsendQuery(conn, "select * from cats; select * from cats") after
> PQenterPipelineMode.
> This cause ERROR
> cannot insert multiple commands into a prepared statement.
> postgresql client 14
> postgresql server 13.4


In pipeline mode, queries are handled with the extended query protocol

This fact is only indirectly mentioned in the documentation:

"While the pipeline API was introduced in PostgreSQL 14, it is a client-side feature which doesn't require special server support and works on any server that supports the v3 extended query protocol."


which does not support multiple commands per query.

This is mentioned in this note in the documentation
(see
https://www.postgresql.org/docs/current/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY):

It seems desirable to talk about the multi-command limitation directly in the libpq chapter of the documentation and only refer to the protocol documentation for "additional reading".  We should not assume the reader of this material knows that extended protocol implies single command.

More specifically, PQsendQuery is not documented to have the single-command limitation, nor from what I understand, can a user explicitly make things such that when used outside of Pipeline mode that the extended query protocol is used.

It is too late to change now but why did we feel the need to make PQsendQuery work in Pipeline mode at all?  Lacking a decent answer it is probably worth saying that while PQsendQuery works it behaves like PQsendQueryParams without any parameters specified.  In particular, it does not allow for multiple commands to be specified in the query.

Combine that with a mention that all interactions with the server are done using v3 of the extended protocol.  Maybe by rewriting the above as:

"While in pipeline mode, communication with the server is done using v3 of the extended query protocol.  This means that the pipeline API can be used to communicate with all servers that support the protocol.  It also means that it is not possible to include multiple commands in a single query (see the note in Protocol XRef for details)."

(I don't think the mentioning of v14 adds enough info to keep when we generally avoid trying to mention versions in our documentation)
David J.

В списке pgsql-bugs по дате отправления:

Предыдущее
От: "Daniel Verite"
Дата:
Сообщение: Re: BUG #17235: PQsendQuery (with two sql) after PQenterPipelineMode cause ERROR
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: BUG #17235: PQsendQuery (with two sql) after PQenterPipelineMode cause ERROR