Skip to content

Commit

Permalink
sql: fix DDL after write error message
Browse files Browse the repository at this point in the history
Previously, the error message said "schema change statement
cannot follow a statement that has written in the same
transaction". This message is incorrect because DDLs after
writes are allowed if the first schema change in a txn occurs
before the first write. This change updates the error message
to reflect the latter.

Release note: None
  • Loading branch information
jayshrivastava committed Dec 23, 2020
1 parent d2740b1 commit da4b129
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/sql/opt/exec/execbuilder/relational.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (b *Builder) buildRelational(e memo.RelExpr) (execPlan, error) {
if err := b.evalCtx.Txn.SetSystemConfigTrigger(b.evalCtx.Codec.ForSystemTenant()); err != nil {
return execPlan{}, errors.WithSecondaryError(
unimplemented.NewWithIssuef(26508,
"schema change statement cannot follow a statement that has written in the same transaction"),
"the first schema change statement in a transaction must precede any writes"),
err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/schema_changer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3579,7 +3579,7 @@ INSERT INTO t.kv VALUES ('a', 'b');
name: `insert-create`,
firstStmt: `INSERT INTO t.kv VALUES ('e', 'f')`,
secondStmt: `CREATE INDEX foo2 ON t.kv (v)`,
expectedErr: `schema change statement cannot follow a statement that has written in the same transaction`,
expectedErr: `the first schema change statement in a transaction must precede any writes`,
},
// schema change at the end of a read only transaction.
{
Expand Down

0 comments on commit da4b129

Please sign in to comment.