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.96) (envelope-from ) id 1wKAWE-000gKR-1S for pgsql-hackers@arkaria.postgresql.org; Tue, 05 May 2026 07:48:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wKAWC-00Ajqe-0q for pgsql-hackers@arkaria.postgresql.org; Tue, 05 May 2026 07:48:36 +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.96) (envelope-from ) id 1wKAWB-00AjqW-2e for pgsql-hackers@lists.postgresql.org; Tue, 05 May 2026 07:48:35 +0000 Received: from mail.postgrespro.ru ([93.174.132.70]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wKAW9-00000000b8O-1yej for pgsql-hackers@lists.postgresql.org; Tue, 05 May 2026 07:48:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1777967311; bh=n5Gv7QUqRdPYImqwe34uiSW0CFEgHQpvOfnsQ1Nq3JA=; h=Message-ID:Date:User-Agent:Subject:To:Cc:References:From: In-Reply-To:From; b=dnmMXzdFQdu7/VA1Xmepxz4zIk9kuE+RZaiwjGwzNzUQkdAI6tG/LUFz00xu2A0vb Ddvc5pEr1b1Rnt3l5+8P9ooNHllxp6HVT/D+2ReOyNHYcatLjnSfRXVPwByVJSKY6y TZyb+Gl6Bi5Guq6UGyf2INVJ85G7QyVee7C2kIjpn+jEGFmu4ayRKtslazkfv2RkN6 +4pCglCK1stJEk2xj+hL1RMk/0F18TCrPmQueWUTuBkBzwe025vkrgV7BJJGrRsnHM 8iKscC34hrFBEUik1SYERJXyY7a/WEzvfXR24mRX6p4z8lY2UvLxLv51Sr4zEuZv8G LHVQukig1LOxw== Received: from [172.30.48.114] (debian11-template.l.postgrespro.ru [192.168.2.254]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: d.bondar@postgrespro.ru) by mail.postgrespro.ru (Postfix/465) with ESMTPSA id 32ABB60841; Tue, 5 May 2026 10:48:31 +0300 (MSK) Content-Type: multipart/alternative; boundary="------------S6TLy9CsYWECxjhB7x23UQCP" Message-ID: <6cf1ae29-0992-4a14-a52f-b769b560b92a@postgrespro.ru> Date: Tue, 5 May 2026 14:48:30 +0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Pgbench: remove synchronous prepare To: Robert Haas Cc: pgsql-hackers@lists.postgresql.org References: <2da56b59-acb6-4ee3-af6b-6e800115dc7f@postgrespro.ru> <6e161344-d26a-4e3d-aa12-83a05a3ca8dc@postgrespro.ru> Content-Language: en-US From: Dmitrii Bondar In-Reply-To: X-KSMG-AntiPhishing: NotDetected X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 3.0.0.9059, bases: 2026/05/05 05:33:00 #28497249 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: not scanned, disabled by settings X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------S6TLy9CsYWECxjhB7x23UQCP Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 4/30/26 4:46 AM, Robert Haas wrote: > Why isn't the solution to use the existing PQsendPrepare function > instead of adding a new libpq entrypoint? pgbench is not designed to process a response to a Parse message alone, because of meta-commands. For example, the \gset command requires a tuple to be stored, but a response to a Parse message does not provide one. This leads to the error: pgbench: error: client 0 script 0 command 0 query 0: expected one row, got 0. Sending all additional messages with PQsendQueryPrepared may look like the exact solution, but it is not. PQsendQueryStart does not allow more than one command to be sent unless pipeline mode is enabled. This could be fixed in two ways: either by allowing libpq to send more than one command when pipeline is disabled, or by adding a new state-machine state to pgbench. Both options seem more invasive than the current solution. Adding a new libpq function just for pgbench (at least for now) does not seem ideal either, but it may be simpler and safer. > I don't think we > can add a function with a name like PQsendPBES, and I think we need to I have other suggestions: "PQsendQueryPrepare" but it is too close to the existing name "PQsendQueryPrepared". "PQsendPrepareQuery" similar to "PQsendPrepare" but it also executes the query. "PQsendPrepareExecute" is not especially well aligned with the existing naming scheme, but it may describe the intent quite well. --------------S6TLy9CsYWECxjhB7x23UQCP Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit


On 4/30/26 4:46 AM, Robert Haas wrote:
Why isn't the solution to use the existing PQsendPrepare function
instead of adding a new libpq entrypoint?

pgbench is not designed to process a response to a Parse message alone, because of meta-commands. For example, the \gset command requires a tuple to be stored, but a response to a Parse message does not provide one. This leads to the error: pgbench: error: client 0 script 0 command 0 query 0: expected one row, got 0. Sending all additional messages with PQsendQueryPrepared may look like the exact solution, but it is not. PQsendQueryStart does not allow more than one command to be sent unless pipeline mode is enabled. This could be fixed in two ways: either by allowing libpq to send more than one command when pipeline is disabled, or by adding a new state-machine state to pgbench. Both options seem more invasive than the current solution. Adding a new libpq function just for pgbench (at least for now) does not seem ideal either, but it may be simpler and safer.

I don't think we
can add a function with a name like PQsendPBES, and I think we need to

I have other suggestions:
"PQsendQueryPrepare" but it is too close to the existing name "PQsendQueryPrepared".
"PQsendPrepareQuery" similar to "PQsendPrepare" but it also executes the query. 
"PQsendPrepareExecute" is not especially well aligned with the existing naming scheme, but it may describe the intent quite well.


    


--------------S6TLy9CsYWECxjhB7x23UQCP--