Skip to content

Commit

Permalink
scbuildstmt: fix ADD COLUMN minimal supported version
Browse files Browse the repository at this point in the history
Previously, the minimal supported version for stmt `ADD COLUMN` in the
new schema changer was incorrectly labeled as v22.1, but this stmt was
not fully supported and we added much functionality to it in v22.2.
It was incompatible with the version gating elements commit (e.g.
in a mixed version state, if we want to use new schema changer for an
`ADD COLUMN` but the element `IndexColumn` was excluded due to the
gating, then we will run into issues). This PR changes the minimal
supported version of `ADD COLUMN` to v22.2.

Release justification: bug fix

Release note: None
  • Loading branch information
Xiang-Gu committed Sep 8, 2022
1 parent d33e93f commit 1133a0e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ statement ok
SET use_declarative_schema_changer = unsafe_always;

# Verify that DDL stmts only supported in v22.2 will cause a panic.
statement error pq: \*tree\.AlterTable not implemented in the new schema changer
ALTER TABLE testdb.testsc.t ADD COLUMN j INT NOT NULL DEFAULT 30;

statement error pq: \*tree\.AlterTable not implemented in the new schema changer
ALTER TABLE testdb.testsc.t DROP COLUMN j;

Expand Down Expand Up @@ -61,9 +64,6 @@ statement error pq: \*tree\.DropIndex not implemented in the new schema changer
DROP INDEX testdb.testsc.t@idx

# Verify that DDL stmts supported in v22.1 will succeed.
statement ok
ALTER TABLE testdb.testsc.t ADD COLUMN j INT NOT NULL DEFAULT 30;

statement ok
DROP TYPE testdb.testsc.typ;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type supportedAlterTableCommand struct {
// declarative schema changer. Operations marked as non-fully supported can
// only be with the use_declarative_schema_changer session variable.
var supportedAlterTableStatements = map[reflect.Type]supportedAlterTableCommand{
reflect.TypeOf((*tree.AlterTableAddColumn)(nil)): {fn: alterTableAddColumn, on: true, minSupportedClusterVersion: clusterversion.V22_1},
reflect.TypeOf((*tree.AlterTableAddColumn)(nil)): {fn: alterTableAddColumn, on: true, minSupportedClusterVersion: clusterversion.Start22_2},
reflect.TypeOf((*tree.AlterTableDropColumn)(nil)): {fn: alterTableDropColumn, on: true, minSupportedClusterVersion: clusterversion.Start22_2},
reflect.TypeOf((*tree.AlterTableAlterPrimaryKey)(nil)): {fn: alterTableAlterPrimaryKey, on: true, minSupportedClusterVersion: clusterversion.Start22_2},
reflect.TypeOf((*tree.AlterTableAddConstraint)(nil)): {fn: alterTableAddConstraint, on: true, extraChecks: func(
Expand Down

0 comments on commit 1133a0e

Please sign in to comment.