pg.ddx.io pgsql-bugs@postgresql.org mailing list archivehelp / color / mirror / Atom feed
BUG #17565: Extended query protocol incorrectly sets TBLOCK_STARTED even though multiple queries can be executed 2+ messages / 2 participants [nested] [flat]
* BUG #17565: Extended query protocol incorrectly sets TBLOCK_STARTED even though multiple queries can be executed @ 2022-08-01 20:12 PG Bug reporting form <noreply@postgresql.org> 0 siblings, 1 reply; 2+ messages in thread From: PG Bug reporting form @ 2022-08-01 20:12 UTC (permalink / raw) To: pgsql-bugs@lists.postgresql.org; +Cc: matt.jibson@gmail.com 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. ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: BUG #17565: Extended query protocol incorrectly sets TBLOCK_STARTED even though multiple queries can be executed @ 2022-08-01 22:21 Tom Lane <tgl@sss.pgh.pa.us> parent: PG Bug reporting form <noreply@postgresql.org> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2022-08-01 22:21 UTC (permalink / raw) To: matt.jibson@gmail.com; +Cc: pgsql-bugs@lists.postgresql.org PG Bug reporting form <noreply@postgresql.org> writes: > 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. Hmmm ... I think this is a duplicate of a bug that we just fixed last week. Please see https://www.postgresql.org/message-id/flat/17434-d9f7a064ce2a88a3%40postgresql.org https://git.postgresql.org/gitweb/?p=postgresql.git&a=commitdiff&h=f92944137 and let us know (preferably on that thread) if you think there's still more to do. regards, tom lane ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2022-08-01 22:21 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2022-08-01 20:12 BUG #17565: Extended query protocol incorrectly sets TBLOCK_STARTED even though multiple queries can be executed PG Bug reporting form <noreply@postgresql.org> 2022-08-01 22:21 ` Tom Lane <tgl@sss.pgh.pa.us>
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