Skip to content

Commit

Permalink
Merge #58182
Browse files Browse the repository at this point in the history
58182: sql: fix DDL after write error message r=lucy-zhang a=jayshrivastava

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

Co-authored-by: Jayant Shrivastava <[email protected]>
  • Loading branch information
craig[bot] and jayshrivastava committed Dec 23, 2020
2 parents ba6feb8 + da4b129 commit 7f0b87f
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 7f0b87f

Please sign in to comment.