Thread: [libpq] Async Queries and the Order of Execution

[libpq] Async Queries and the Order of Execution

From
Helmut Dittenwald
Date:
Hi everyone!

I have some very simple, single-threaded, client-side C code:

...
PQsendPrepare(...);
PQsetnonblocking(...);
while(1) {
  PQsendQueryPrepared(...); // [1]
  // Here I PQgetResult and PQclear it when done. Not shown to keep brevity.
}

Now I'm curious whether the queries [1] are executed in the same order as they are being sent..?
My experiments indicate that this is the case, but is it guaranteed?

Best Regards,
HD

Re: [libpq] Async Queries and the Order of Execution

From
Laurenz Albe
Date:
Helmut Dittenwald wrote:
> I have some very simple, single-threaded, client-side C code:
> 
> ...
> PQsendPrepare(...);
> PQsetnonblocking(...);
> while(1) {
>   PQsendQueryPrepared(...); // [1]
>   // Here I PQgetResult and PQclear it when done. Not shown to keep brevity.
> }
> 
> Now I'm curious whether the queries [1] are executed in the same order as they are being sent..?
> My experiments indicate that this is the case, but is it guaranteed?

Yes, they will be sent in the order you indicate, and they will be executed
in the order in which they were sent.

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com