> 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."
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)