From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: matt.jibson@gmail.com
Subject: BUG #17565: Extended query protocol incorrectly sets TBLOCK_STARTED even though multiple queries can be executed
Date: Mon, 01 Aug 2022 20:12:00 +0000
Message-ID: <17565-156f3bd8f262150f@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 17565
Logged by: Matt Jibson
Email address: matt.jibson@gmail.com
PostgreSQL version: 14.4
Operating system: linux
Description:
The extended query protocol is most often used with the 4 messages in the
sequence: Parse, Bind, Execute, Sync. Parse, Bind, and Execute all call
start_xact_command, which will change blockState to TBLOCK_STARTED. However
it is within the protocol spec to instead do: Parse, Bind, Execute, Parse,
Bind, Execute, Sync. That is: issue two query executions and then a Sync.
The Npgsql driver does exactly this at its startup.
The doc comment for TBLOCK_STARTED says "running single-query transaction",
but this is a case where a driver can escape that restriction which is
assumed by the rest of the code. For example, there are various things
differentiate between STARTED and INPROGRESS or IMPLICIT_INPROGRESS:
PreventInTransactionBlock, IsInTransactionBlock. Some statements (VACUUM,
DISCARD ALL) use those functions to prevent their execution in a multi
statement context, but those can be escaped using the extended protocol.
The protocol docs have an excellent section on how to handle multiple
statements in a simple query. Assuming that this is indeed a bug and is
fixed somehow, the extended protocol may need its docs changed to similarly
describe what happens in this case.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, matt.jibson@gmail.com
Subject: Re: BUG #17565: Extended query protocol incorrectly sets TBLOCK_STARTED even though multiple queries can be executed
In-Reply-To: <17565-156f3bd8f262150f@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox