## Code Analysis ### Simple-query batches are intended to be implicit transactions `server/connection_simple.go:52-76` ```go // resumeSimpleQuery executes statements until they finish or COPY FROM STDIN needs client data. func (h *ConnectionHandler) resumeSimpleQuery(execution *simpleQueryExecution) (endOfMessages bool, err error) { // Multiple statements in one Query message run in an implicit transaction block. Transaction-control statements // may promote or end that block through handleTransactionStatement. implicitTransactionControl := len(execution.statements) > 1 for execution.nextStatement < len(execution.statements) { ... if err = h.query(query); err != nil { return true, err } } } ``` The handler identifies a multi-statement Query message as an implicit transaction and returns immediately when a statement errors. Error completion then routes through `endOfMessages` and `handleOperationError` (`server/connection_errors.go:43-47`). ### Error handling has a rollback path `server/connection_transaction.go:178-185` ```go // failActiveTransaction applies PostgreSQL statement-error semantics to the active transaction. func (h *ConnectionHandler) failActiveTransaction() { switch h.state.txState { case implicitTransactionState: h.rollbackImplicitTransaction() case explicitTransactionState: h.state.txState = failedTransactionState } } ``` For an implicit transaction error, the source calls `rollbackImplicitTransaction`; that function issues `ROLLBACK` before returning the session to idle (`server/connection_transaction.go:165-175`). ### Existing regression test defines the expected result `testing/go/implicit_transaction_test.go:90-112` ```go Name: "error rolls back the entire implicit transaction", Query: "INSERT INTO mytable VALUES (1); SELECT 1/0; INSERT INTO mytable VALUES (2);", ExpectedErr: "division by zero", Query: "SELECT count(*) FROM mytable;", Expected: [][]string{{"0"}}, Query: "INSERT INTO mytable VALUES (3);", Query: "SELECT * FROM mytable ORDER BY i;", Expected: [][]string{{"3"}}, ``` The repository test explicitly requires the first insert to be rolled back, the statement after the error not to execute, and a later query to recover with only row `3`. ### Observed execution ### reproduction request ```sql DROP TABLE IF EXISTS mytable; CREATE TABLE mytable (i BIGINT PRIMARY KEY); INSERT INTO mytable VALUES (1); SELECT 1/0; INSERT INTO mytable VALUES (2); INSERT INTO mytable VALUES (3); SELECT i FROM mytable ORDER BY i; ``` ### error response ```text ERROR: division by zero ``` ### cross-connection state readback ```text 2 ``` ### recovered-session state readback ```text 1 2 3 ``` # final result: REV-4 failed - the batch reported division by zero but the second connection counted two persisted rows, and the original session later returned rows 1, 2, and 3 instead of only row 3. # setup context: The recorded evidence uses a persistent simple-query session and a second connection; no stubs, mocks, or bypasses were reported.