Re: Add PQsendSyncMessage() to libpq - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: Add PQsendSyncMessage() to libpq
Date
Msg-id 20230504103642.sip34d7kszi6b4cd@alvherre.pgsql
Whole thread Raw
In response to Re: Add PQsendSyncMessage() to libpq  (Anton Kirilov <antonvkirilov@gmail.com>)
Responses Re: Add PQsendSyncMessage() to libpq
List pgsql-hackers
On 2023-May-04, Anton Kirilov wrote:

> Thank you all for the feedback! Do you have any thoughts on the other
> issue with PQpipelineSync() I have mentioned in my previous message?

Eh, I hadn't seen that one.

> Am I just misunderstanding what the code comment means and how the API
> is supposed to be used by any chance?

I think you have it right: it is possible that the buffer has not been
fully flushed by the time PQpipelineSync returns.

If you want to make sure it's fully flushed, your only option is to have
the call block.  That would make it no longer non-blocking, so it has to
be explicitly requested behavior.
I think this means to add yet another behavior flag for the new
function: have it block, waiting for the buffer to be flushed.

So your application can put several sync points in the queue, with no
flushing (and of course no blocking), and have it flush+block only on
the "last" one.  Of course, for other users, you want the current
behavior: have it flush opportunistically but not block.  So you can't
make it a single flag.

-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/



pgsql-hackers by date:

Previous
From: Anton Kirilov
Date:
Subject: Re: Add PQsendSyncMessage() to libpq
Next
From: Alvaro Herrera
Date:
Subject: Re: "variable not found in subplan target list"