From bd8ac900df4d2824f50ce4b1674754685aeaed56 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Fri, 23 Sep 2022 18:21:22 +0200 Subject: Remove PQsendQuery support in pipeline mode The extended query protocol implementation I added in commit acb7e4eb6b1c 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 --- src/test/modules/libpq_pipeline/libpq_pipeline.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/test/modules/libpq_pipeline/libpq_pipeline.c') diff --git a/src/test/modules/libpq_pipeline/libpq_pipeline.c b/src/test/modules/libpq_pipeline/libpq_pipeline.c index ac62d475b91..bff7d4b90cc 100644 --- a/src/test/modules/libpq_pipeline/libpq_pipeline.c +++ b/src/test/modules/libpq_pipeline/libpq_pipeline.c @@ -108,6 +108,18 @@ test_disallowed_in_pipeline(PGconn *conn) res = PQexec(conn, "SELECT 1"); if (PQresultStatus(res) != PGRES_FATAL_ERROR) pg_fatal("PQexec should fail in pipeline mode but succeeded"); + if (strcmp(PQerrorMessage(conn), + "synchronous command execution functions are not allowed in pipeline mode\n") != 0) + pg_fatal("did not get expected error message; got: \"%s\"", + PQerrorMessage(conn)); + + /* PQsendQuery should fail in pipeline mode */ + if (PQsendQuery(conn, "SELECT 1") != 0) + pg_fatal("PQsendQuery should fail in pipeline mode but succeeded"); + if (strcmp(PQerrorMessage(conn), + "PQsendQuery not allowed in pipeline mode\n") != 0) + pg_fatal("did not get expected error message; got: \"%s\"", + PQerrorMessage(conn)); /* Entering pipeline mode when already in pipeline mode is OK */ if (PQenterPipelineMode(conn) != 1) -- cgit v1.2.3