Skip to content

Commit

Permalink
schemadiff: Online DDL support, declarative based (#16462)
Browse files Browse the repository at this point in the history
Signed-off-by: Shlomi Noach <[email protected]>
  • Loading branch information
shlomi-noach authored Jul 30, 2024
1 parent 67b5a6d commit ad27066
Show file tree
Hide file tree
Showing 36 changed files with 3,249 additions and 2,959 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const (
testFilterEnvVar = "ONLINEDDL_SUITE_TEST_FILTER"
)

// Use $VREPL_SUITE_TEST_FILTER environment variable to filter tests by name.
func TestMain(m *testing.M) {
defer cluster.PanicHandler(nil)
flag.Parse()
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Found no possible
found no possible
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Found no possible
found no possible
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
drop table if exists onlineddl_test;
create table onlineddl_test (
f float,
f float not null,
i int not null,
ts timestamp default current_timestamp,
dt datetime,
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Found no possible
found no possible
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Found no possible
found no possible
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add column v varchar(32)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
drop table if exists onlineddl_test;
create table onlineddl_test (
id int,
i int not null,
ts timestamp default current_timestamp,
dt datetime,
key i_idx(i),
unique key id_uidx(id)
) auto_increment=1;

drop event if exists onlineddl_test;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
found no possible
16 changes: 2 additions & 14 deletions go/vt/schemadiff/capability.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,6 @@ func alterOptionCapableOfInstantDDL(alterOption sqlparser.AlterOption, createTab
}
}

isGeneratedColumn := func(col *sqlparser.ColumnDefinition) (bool, sqlparser.ColumnStorage) {
if col == nil {
return false, 0
}
if col.Type.Options == nil {
return false, 0
}
if col.Type.Options.As == nil {
return false, 0
}
return true, col.Type.Options.Storage
}
colStringStrippedDown := func(col *sqlparser.ColumnDefinition, stripEnum bool) string {
strippedCol := sqlparser.Clone(col)
// strip `default`
Expand Down Expand Up @@ -153,7 +141,7 @@ func alterOptionCapableOfInstantDDL(alterOption sqlparser.AlterOption, createTab
return false, nil
}
for _, column := range opt.Columns {
if isGenerated, storage := isGeneratedColumn(column); isGenerated {
if isGenerated, storage := IsGeneratedColumn(column); isGenerated {
if storage == sqlparser.StoredStorage {
// Adding a generated "STORED" column is unsupported
return false, nil
Expand Down Expand Up @@ -188,7 +176,7 @@ func alterOptionCapableOfInstantDDL(alterOption sqlparser.AlterOption, createTab
// not supported if the column is part of an index
return false, nil
}
if isGenerated, _ := isGeneratedColumn(col); isGenerated {
if isGenerated, _ := IsGeneratedColumn(col); isGenerated {
// supported by all 8.0 versions
// Note: according to the docs dropping a STORED generated column is not INSTANT-able,
// but in practice this is supported. This is why we don't test for STORED here, like
Expand Down
Loading

0 comments on commit ad27066

Please sign in to comment.