1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-12 21:01:52 +03:00

Remove PQsendQuery support in pipeline mode

The extended query protocol implementation I added in commit
acb7e4eb6b has bugs when used in pipeline mode.  Rather than spend
more time trying to fix it, remove that code and make the function rely
on simple query protocol only, meaning it can no longer be used in
pipeline mode.

Users can easily change their applications to use PQsendQueryParams
instead.  We leave PQsendQuery in place for Postgres 14, just in case
somebody is using it and has not hit the mentioned bugs; but we should
recommend that it not be used.

Backpatch to 15.

Per bug report from Gabriele Varrazzo.
Discussion: https://postgr.es/m/CA+mi_8ZGSQNmW6-mk_iSR4JZB_LJ4ww3suOF+1vGNs3MrLsv4g@mail.gmail.com
This commit is contained in:
Alvaro Herrera
2022-09-23 18:21:22 +02:00
parent 27e04412c9
commit bd8ac900df
4 changed files with 41 additions and 115 deletions

View File

@ -4599,8 +4599,7 @@ int PQsendQuery(PGconn *conn, const char *command);
</para>
<para>
In pipeline mode, command strings containing more than one SQL command
are disallowed.
In pipeline mode, this function is disallowed.
</para>
</listitem>
</varlistentry>
@ -5054,6 +5053,7 @@ int PQflush(PGconn *conn);
<xref linkend="libpq-PQpipelineStatus"/> can be used
to test whether pipeline mode is active.
In pipeline mode, only <link linkend="libpq-async">asynchronous operations</link>
that utilize the extended query protocol
are permitted, command strings containing multiple SQL commands are
disallowed, and so is <literal>COPY</literal>.
Using synchronous command execution functions
@ -5065,6 +5065,8 @@ int PQflush(PGconn *conn);
<function>PQdescribePrepared</function>,
<function>PQdescribePortal</function>,
is an error condition.
<function>PQsendQuery</function> is
also disallowed, because it uses the simple query protocol.
Once all dispatched commands have had their results processed, and
the end pipeline result has been consumed, the application may return
to non-pipelined mode with <xref linkend="libpq-PQexitPipelineMode"/>.
@ -5093,8 +5095,7 @@ int PQflush(PGconn *conn);
<para>
After entering pipeline mode, the application dispatches requests using
<xref linkend="libpq-PQsendQuery"/>,
<xref linkend="libpq-PQsendQueryParams"/>,
<xref linkend="libpq-PQsendQueryParams"/>
or its prepared-query sibling
<xref linkend="libpq-PQsendQueryPrepared"/>.
These requests are queued on the client-side until flushed to the server;