-
Notifications
You must be signed in to change notification settings - Fork 4.1k
sql: pg mandates multi-stmt batches to execute as single txn #44803
Description
As per pg's docs: https://www.postgresql.org/docs/12/protocol-flow.html#PROTOCOL-FLOW-MULTI-STATEMENT
When a simple Query message contains more than one SQL statement (separated by semicolons), those statements are executed as a single transaction, unless explicit transaction control commands are included to force a different behavior. For example, if the message contains
INSERT INTO mytable VALUES(1); SELECT 1/0; INSERT INTO mytable VALUES(2);then the divide-by-zero failure in the SELECT will force rollback of the first INSERT. Furthermore, because execution of the message is abandoned at the first error, the second INSERT is never attempted at all.
If a pg client that expects this behavior is ran against crdb, this will yield inconsistent data without any clear signal to the client.
(The current crdb behavior is a plain ACID violation when viewed through the lens of pg semantics.)
Epic CRDB-8948
Jira issue: CRDB-5201