Re: Pipeline mode and PQpipelineSync()
Alvaro Herrera <alvaro.herrera@2ndquadrant.com>
From: Alvaro Herrera <alvaro.herrera@2ndquadrant.com>
To: Boris Kolpackov <boris@codesynthesis.com>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2021-06-25T23:52:41Z
Lists: pgsql-hackers
On 2021-Jun-25, Alvaro Herrera wrote:
> From 071757645ee0f9f15f57e43447d7c234deb062c0 Mon Sep 17 00:00:00 2001
> From: Alvaro Herrera <alvherre@alvh.no-ip.org>
> Date: Fri, 25 Jun 2021 16:02:00 -0400
> Subject: [PATCH v2 2/4] Add PQrequestFlush()
I forgot to mention:
> +/*
> + * Send request for server to flush its buffer
> + */
> +int
> +PQrequestFlush(PGconn *conn)
> +{
> + if (!conn)
> + return 0;
> +
> + /* Don't try to send if we know there's no live connection. */
> + if (conn->status != CONNECTION_OK)
> + {
> + appendPQExpBufferStr(&conn->errorMessage,
> + libpq_gettext("no connection to the server\n"));
> + return 0;
> + }
> +
> + /* Can't send while already busy, either, unless enqueuing for later */
> + if (conn->asyncStatus != PGASYNC_IDLE &&
> + conn->pipelineStatus == PQ_PIPELINE_OFF)
> + {
> + appendPQExpBufferStr(&conn->errorMessage,
> + libpq_gettext("another command is already in progress\n"));
> + return false;
> + }
> +
> + if (pqPutMsgStart('H', conn) < 0 ||
> + pqPutMsgEnd(conn) < 0)
> + {
> + return 0;
> + }
> + /* XXX useless without a flush ...? */
> + pqFlush(conn);
> +
> + return 1;
> +}
I'm not sure if it's a good idea for PQrequestFlush to itself flush
libpq's buffer. We can just document that PQflush is required ...
opinions?
(I didn't try PQrequestFlush in any scenarios other than the test case I
added.)
--
Álvaro Herrera Valdivia, Chile
Voy a acabar con todos los humanos / con los humanos yo acabaré
voy a acabar con todos (bis) / con todos los humanos acabaré ¡acabaré! (Bender)
Commits
-
libpq: Fix sending queries in pipeline aborted state
- ab0967942900 15.0 landed
- 1beaa654da61 14.0 landed
-
Fix libpq state machine in pipeline mode
- b71a9cb31e46 15.0 landed
- 690339fcd587 14.0 landed
-
Add PQsendFlushRequest to libpq
- a7192326c74d 15.0 landed
- 69cf1d5429d4 14.0 landed