From: | Alvaro Herrera <alvaro(dot)herrera(at)2ndquadrant(dot)com> |
---|---|
To: | Boris Kolpackov <boris(at)codesynthesis(dot)com> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Pipeline mode and PQpipelineSync() |
Date: | 2021-06-25 23:52:41 |
Message-ID: | 202106252352.5ca4byasfun5@alvherre.pgsql |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2021-Jun-25, Alvaro Herrera wrote:
> From 071757645ee0f9f15f57e43447d7c234deb062c0 Mon Sep 17 00:00:00 2001
> From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)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)
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2021-06-26 00:36:42 | Re: [PATCH] Make jsonapi usable from libpq |
Previous Message | Alvaro Herrera | 2021-06-25 23:50:10 | Re: Pipeline mode and PQpipelineSync() |