Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lwvcv-00054y-FD for pgsql-hackers@arkaria.postgresql.org; Fri, 25 Jun 2021 23:52:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lwvcu-0004gy-6N for pgsql-hackers@arkaria.postgresql.org; Fri, 25 Jun 2021 23:52:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lwvct-0004gp-Ur for pgsql-hackers@lists.postgresql.org; Fri, 25 Jun 2021 23:52:47 +0000 Received: from mail-qv1-xf2f.google.com ([2607:f8b0:4864:20::f2f]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lwvcr-0007wG-BP for pgsql-hackers@lists.postgresql.org; Fri, 25 Jun 2021 23:52:47 +0000 Received: by mail-qv1-xf2f.google.com with SMTP id u8so2807600qvg.0 for ; Fri, 25 Jun 2021 16:52:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to; bh=jXkXYHXiPtRHgY9D0G898YaYdLLfrZiWRzjr5bda9Hc=; b=RvNL1/U2uy2pSTCOtW40LATf6TVaQN6zFVlJ0SKLdKShLKyuroJrhbaeKJifWxA9v2 wbtpeX6sThWC8pn2/Qj0KosLyTQjxe+LhoqAA/RqavaAWVK1lLEQmgyCZYrrE4U+Y++r D2AFTGhzFj6rPPpNFpNSDbJSX9rmhZStY5KW7r7lN6uzlQLtMaCkd412FKnqHte7ssPR JCwj8bItLLw2Kr7vAHw/FTs1RBlGuRgU6qgalYyiF+yy42M6TrAVg9undptKglsgcSND ktLWBHxnAf+Ph9RywSVWYrnjYMu6SHlqMIvDwV3kQn2NODv2rJcROmudEnaXekpOfL12 HEaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=jXkXYHXiPtRHgY9D0G898YaYdLLfrZiWRzjr5bda9Hc=; b=ITrQhQuf8Cxcpfgc+8baLfIVSLvmMoH3fdeFkHF8W6VMApplshfeXzMBGKnBtwZ3d+ 2VVWwJQ1bswleFVxIyEpaidyiiPDraQaxBYOSrLpaE5CpQgCEmDKU5JXnOF0bkccRpQx C7OZHB+WkJlem1m9JftJphrC6UOV/bbfwZWDZYolZnnvHj5npu6Tt2EUkjt2BLEyT+hV I3QuQ8oddkhnL5r2pRMU+M/a7Nf8Cg8h2Zd2kMSe6PCjBBEMmp7ujwDP1lK59LNXCeM6 dJ6iL8KYiqbXmh0DxeMdWfmbjEHB0UuwhF7kJT2NkJBatBCDdIIkqr2kEzi1riEUrGkj yIcA== X-Gm-Message-State: AOAM530WVARv++7gsTmnFpfOygNSwtFa0AJGV+wD7/BHmDTPYoBseGNJ vTIVn3LlhT74cj1Y+Pak8DQz+A== X-Google-Smtp-Source: ABdhPJybwXvDqcUkgQkLRf3VOQEROTRxA/JkuJSSS46Kwz4GTbD9MYDJsnZRRO/iSUdkSAUDcuwHJg== X-Received: by 2002:ad4:54f0:: with SMTP id k16mr13845933qvx.62.1624665163654; Fri, 25 Jun 2021 16:52:43 -0700 (PDT) Received: from perhan.alvh.no-ip.org ([190.95.19.95]) by smtp.gmail.com with ESMTPSA id g15sm4867571qtq.70.2021.06.25.16.52.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 16:52:43 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 7A5B82A0ADC; Fri, 25 Jun 2021 19:52:41 -0400 (-04) Date: Fri, 25 Jun 2021 19:52:41 -0400 From: Alvaro Herrera To: Boris Kolpackov Cc: pgsql-hackers@lists.postgresql.org Subject: Re: Pipeline mode and PQpipelineSync() Message-ID: <202106252352.5ca4byasfun5@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <202106252350.t76x73nt643j@alvherre.pgsql> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021-Jun-25, Alvaro Herrera wrote: > From 071757645ee0f9f15f57e43447d7c234deb062c0 Mon Sep 17 00:00:00 2001 > From: Alvaro Herrera > 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)