Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions go/vt/vttablet/onlineddl/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ var (
)

var vexecUpdateTemplates = []string{
`update _vt.schema_migrations set migration_status='val' where mysql_schema='val'`,
`update _vt.schema_migrations set migration_status='val' where migration_uuid='val' and mysql_schema='val'`,
`update _vt.schema_migrations set migration_status='val' where migration_uuid='val' and mysql_schema='val' and shard='val'`,
`update _vt.schema_migrations set migration_status='val1' where mysql_schema='val2'`,
`update _vt.schema_migrations set migration_status='val1' where migration_uuid='val2' and mysql_schema='val3'`,
`update _vt.schema_migrations set migration_status='val1' where migration_uuid='val2' and mysql_schema='val3' and shard='val4'`,
}

var vexecInsertTemplates = []string{
Expand All @@ -98,7 +98,7 @@ var vexecInsertTemplates = []string{
migration_context,
migration_status
) VALUES (
'val', 'val', 'val', 'val', 'val', 'val', 'val', 'val', 'val', FROM_UNIXTIME(0), 'val', 'val'
'val1', 'val2', 'val3', 'val4', 'val5', 'val6', 'val7', 'val8', 'val9', FROM_UNIXTIME(0), 'vala', 'valb'
)`,
}

Expand Down
20 changes: 20 additions & 0 deletions go/vt/vttablet/onlineddl/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@ import (
"vitess.io/vitess/go/vt/sqlparser"
)

func TestVexecUpdateTemplates(t *testing.T) {
{
match, err := sqlparser.QueryMatchesTemplates("select 1 from dual", vexecUpdateTemplates)
assert.NoError(t, err)
assert.False(t, match)
}
queries := []string{
`update _vt.schema_migrations set migration_status='cancel-all' where mysql_schema='vt_commerce'`,
`update _vt.schema_migrations set migration_status = 'cancel-all' where migration_uuid='a5a563da_dc1a_11ec_a416_0a43f95f28a3' and mysql_schema = 'vt_commerce'`,
`update _vt.schema_migrations set migration_status = 'cancel-all' where migration_uuid='a5a563da_dc1a_11ec_a416_0a43f95f28a3' and mysql_schema = 'vt_commerce' and shard='0'`,
}
for _, query := range queries {
t.Run(query, func(t *testing.T) {
match, err := sqlparser.QueryMatchesTemplates(query, vexecUpdateTemplates)
assert.NoError(t, err)
assert.True(t, match)
})
}
}

func TestValidateAndEditCreateTableStatement(t *testing.T) {
e := Executor{}
tt := []struct {
Expand Down