public inbox for [email protected]
help / color / mirror / Atom feedRe: Using PQsocketPoll() for PIPELINE mode
2+ messages / 1 participants
[nested] [flat]
* Re: Using PQsocketPoll() for PIPELINE mode
@ 2024-08-27 10:23 Dominique Devienne <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: Dominique Devienne @ 2024-08-27 10:23 UTC (permalink / raw)
To: [email protected]
On Wed, Aug 14, 2024 at 2:50 PM Dominique Devienne <[email protected]> wrote:
> Hi. I've now used successfully the new PQsocketPoll() API
> in the context of waiting for notifications, using beta2 and 3.
>
> But now I'm looking into using it in the context of PIPELINE mode.
> Where I suppose both forRead and forWrite are 1, but the return
> code only indicates whether the condition is met. The doc says nothing
> about OR or AND semantic, when both forRead and forWrite are true.
>
> Perhaps it's deemed obvious from the use of select() or poll()?
> Or is one supposed to call it once with forRead=forWrite=1 and
> a timeout, then call it again twice with just one forFlag set and
> a 0 timeout, to know the "details" about which "side" is ready?
>
> Or hasn't this use case been considered for PQsocketPoll(),
> and thus the current return code isn't has precise as it could be?
>
> Thanks for any precisions, --DD
Hi. No answers. Was it wrong timing (vacations) or
is something wrong with my questions? Thanks, --DD
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Using PQsocketPoll() for PIPELINE mode
@ 2024-08-27 13:20 Dominique Devienne <[email protected]>
parent: Dominique Devienne <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Dominique Devienne @ 2024-08-27 13:20 UTC (permalink / raw)
To: [email protected]
On Tue, Aug 27, 2024 at 12:23 PM Dominique Devienne <[email protected]> wrote:
> On Wed, Aug 14, 2024 at 2:50 PM Dominique Devienne <[email protected]> wrote:
> > Hi. I've now used successfully the new PQsocketPoll() API
> > in the context of waiting for notifications, using beta2 and 3.
> >
> > But now I'm looking into using it in the context of PIPELINE mode.
> > Where I suppose both forRead and forWrite are 1, but the return
> > code only indicates whether the condition is met. The doc says nothing
> > about OR or AND semantic, when both forRead and forWrite are true.
> >
> > Perhaps it's deemed obvious from the use of select() or poll()?
> > Or is one supposed to call it once with forRead=forWrite=1 and
> > a timeout, then call it again twice with just one forFlag set and
> > a 0 timeout, to know the "details" about which "side" is ready?
> >
> > Or hasn't this use case been considered for PQsocketPoll(),
> > and thus the current return code isn't has precise as it could be?
> >
> > Thanks for any precisions, --DD
>
> Hi. No answers. Was it wrong timing (vacations) or
> is something wrong with my questions? Thanks, --DD
Looking at https://doxygen.postgresql.org/libpq__pipeline_8c_source.html,
it does indeed seem like `select()` can inform about ready forRead and forWrite
independently, and thus that the current signature of PQsocketPoll()
is not ideal
to be used in the context of pipeline mode, which would be a pity, for
a new API.
I get that the original thinking about PQsocketPoll() was neither for
notifications,
not for pipeline mode, but shouldn't it be? That same example should ideally be
writable in terms of PQsocketPoll(), using a few syscalls, no?
Once again, this is late, although my original questions are now 2 weeks old.
After all, PQsocketPoll() has not been released yet officially. Thanks, --DD
```
fd_set input_mask;
fd_set output_mask;
int sock = PQsocket(conn); [...]
if (select(sock + 1, &input_mask, &output_mask, NULL, NULL) < 0) { error }
// Process any results, so we keep the server's output buffer free
// flowing and it can continue to process input
if (FD_ISSET(sock, &input_mask)) {
PQconsumeInput(conn); [...]
}
// Write more rows and/or the end pipeline message, if needed
if (FD_ISSET(sock, &output_mask)) {
PQflush(conn); [...]
}
```
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2024-08-27 13:20 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-08-27 10:23 Re: Using PQsocketPoll() for PIPELINE mode Dominique Devienne <[email protected]>
2024-08-27 13:20 ` Dominique Devienne <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox