Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1siw7k-00BLGE-Tc for pgsql-general@arkaria.postgresql.org; Tue, 27 Aug 2024 13:20:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1siw7i-007NEJ-Kp for pgsql-general@arkaria.postgresql.org; Tue, 27 Aug 2024 13:20:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1siw7i-007NDP-A0 for pgsql-general@lists.postgresql.org; Tue, 27 Aug 2024 13:20:38 +0000 Received: from mail-oi1-x22a.google.com ([2607:f8b0:4864:20::22a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1siw7e-001lGH-Rp for pgsql-general@lists.postgresql.org; Tue, 27 Aug 2024 13:20:38 +0000 Received: by mail-oi1-x22a.google.com with SMTP id 5614622812f47-3db23a6085aso314062b6e.1 for ; Tue, 27 Aug 2024 06:20:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724764834; x=1725369634; darn=lists.postgresql.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=/r3fYsExqxTU+8qeumzq1Xoksbq5pu1+lZxrQ12avTM=; b=ZDLly+TmXqGZ2zFT9lky0ZbCyO0buTUDDN9n3EdOwGDMcgZDKb/Cjp+SX4RXyJtuax Qql6KlzftyvI5vSkg7xuXMv8s68we0InrD2hOpf5rarjvDYtbKqyEeDqqsr9dmVZj/Iw /SIKZKdfx41AIinAnFlN1l3orq+y6cmG8/u8M6375xyuXgvLfESEHxgmZ4Cv49QCI9fU S5nQ3EFrYuadJ+VgwOQuHTLb8porNih9mm/tt2/0MH+Bv+IbPOfQtybxBSHfFRNnPo1V ECN23+MU/gVk2Mlp2PK69u5GfttZogvgjF+AZCEOqSWkK1g8OnqtxCWT6QDiVnbYcfpC pu5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724764834; x=1725369634; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/r3fYsExqxTU+8qeumzq1Xoksbq5pu1+lZxrQ12avTM=; b=SFA0HijQox2nd/h4KjV0dzeJ1u9N/M+UMkVLHo2NbBVuEONy6Kq4YdbM5fr4RLY950 uEZ1NSE6kcaSBbANhOENmmkMkTeqmj44PGi+BhzI5afHx8h/AZ06vggaO28w2UspWTCe adtJsIY02v6R13fgxM0qCZHN3POcAPLsta9AVHHBwVpew6RmDV2n350s6kaooKe5Lhjn AS7YyrgzZB3k9ljEEG4fATBZudwxIQGyP3bPGDBFIDeI380/zdkQDRthVVqA5oo1H0YU tqDv8dV08IA+GjvPEh6g0kYE3+/ZbEq75e0NxcyDWjtswZP/qAps306haqtyiyIBAuMx I5gw== X-Gm-Message-State: AOJu0YyzNHTTJ53WrBCDJDCAxVVAcY6f/gKibnM9Hu392ZNeCtCMGR47 H3fA45FSKq+IG44jgi3qTKxE2716QMxRD+koSaoPjyTIiv2Gttdp8226itXan5Re/GfXgYo1h2W GVnarMcRsvwUgdIbzHND2OprRaK7WPnOu X-Google-Smtp-Source: AGHT+IGlnZIzEkHkXceGOOiFNHYOTfnelJdDall/Ace7pW97wul7D8fN4IHUblyqrH9ZM5gXBFJAxX4m1j8oOuvnn2w= X-Received: by 2002:a05:6808:191a:b0:3db:199e:bdf2 with SMTP id 5614622812f47-3def3c616d8mr1131929b6e.17.1724764834032; Tue, 27 Aug 2024 06:20:34 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Dominique Devienne Date: Tue, 27 Aug 2024 15:20:22 +0200 Message-ID: Subject: Re: Using PQsocketPoll() for PIPELINE mode To: pgsql-general@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Aug 27, 2024 at 12:23=E2=80=AFPM Dominique Devienne wrote: > On Wed, Aug 14, 2024 at 2:50=E2=80=AFPM Dominique Devienne 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=3DforWrite=3D1 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 forW= rite 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 ideall= y be writable in terms of PQsocketPoll(), using a few syscalls, no? Once again, this is late, although my original questions are now 2 weeks ol= d. After all, PQsocketPoll() has not been released yet officially. Thanks, --D= D ``` fd_set input_mask; fd_set output_mask; int sock =3D 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); [...] } ```