Skip to content

Commit

Permalink
schemadiff: explicit ALGORITHM=INSTANT counts as instant-able (#1…
Browse files Browse the repository at this point in the history
…7942)

Signed-off-by: Shlomi Noach <[email protected]>
  • Loading branch information
shlomi-noach authored Mar 10, 2025
1 parent 0515c0f commit 0bf4276
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions go/vt/schemadiff/capability.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ func alterOptionCapableOfInstantDDL(alterOption sqlparser.AlterOption, createTab
return capableOf(capabilities.InstantChangeColumnVisibilityCapability)
}
return false, nil
case sqlparser.AlgorithmValue:
// We accept an explicit ALGORITHM=INSTANT option.
return strings.EqualFold(string(opt), sqlparser.InstantStr), nil
default:
return false, nil
}
Expand Down
18 changes: 18 additions & 0 deletions go/vt/schemadiff/capability_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,24 @@ func TestAlterTableCapableOfInstantDDL(t *testing.T) {
alter: "alter table t1 alter column i1 drop default",
expectCapableOfInstantDDL: true,
},
{
name: "add column with explicit ALGORITHM=instant",
create: "create table t1 (id int, i1 int)",
alter: "alter table t1 add column i2 int, algorithm=instant",
expectCapableOfInstantDDL: true,
},
{
name: "add column with explicit ALGORITHM=INSTANT",
create: "create table t1 (id int, i1 int)",
alter: "alter table t1 add column i2 int, algorithm=INSTANT",
expectCapableOfInstantDDL: true,
},
{
name: "reject if ALGORITHM=COPY",
create: "create table t1 (id int, i1 int)",
alter: "alter table t1 add column i2 int, algorithm=COPY",
expectCapableOfInstantDDL: false,
},
}
for _, tcase := range tcases {
t.Run(tcase.name, func(t *testing.T) {
Expand Down

0 comments on commit 0bf4276

Please sign in to comment.