Skip to content

Commit

Permalink
sql: make RETURNING NOTHING statements not cause FirstBatch->Open tra…
Browse files Browse the repository at this point in the history
…nsition

The parallelized statements don't return results to the client, by
definition. This commit adds them to the list of statements that don't
transition the session from the FirstBatch to Open, so that the next
batch of statements can be auto-retried.
  • Loading branch information
andreimatei committed Jul 3, 2017
1 parent 488a1ec commit 5dd7451
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/sql/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2015,6 +2015,8 @@ func canStayInFirstBatchState(stmt Statement) bool {
return isBegin(stmt) ||
isSavepoint(stmt) ||
isSetTransaction(stmt) ||
// Parallelized statements don't return results to clients, by definition.
IsStmtParallelized(stmt) ||
// ROLLBACK TO SAVEPOINT does its own state transitions; if it leave the
// transaction in the FirstBatch state, don't mess with it.
isRollbackToSavepoint(stmt)
Expand Down
12 changes: 12 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/txn
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,18 @@ statement ok
ROLLBACK


# Parallelized statements doesn't prevent automatic retries of the first batch.
# Restore when #16827 is fixed.
# statement ok
# BEGIN TRANSACTION; INSERT INTO kv (k,v) VALUES ('x', 'b') RETURNING NOTHING;
#
# statement ok
# SELECT 1; SELECT CRDB_INTERNAL.FORCE_RETRY('100ms':::INTERVAL)
#
# statement ok
# ROLLBACK


# General savepoints
statement ok
BEGIN TRANSACTION
Expand Down

0 comments on commit 5dd7451

Please sign in to comment.