Skip to content

Commit 03b669b

Browse files
shlomi-noachclaude
andcommitted
sqlparser: reject empty migration context at parse time for all CONTEXT variants
All CONTEXT grammar rules now call yylex.Error + return 1 when the context string is empty, matching the behaviour added for CANCEL CONTEXT in the base branch. Empty-context round-trip tests are removed from the valid-SQL table and replaced with entries in invalidSQL that assert the exact error message. Executor doc comments no longer mention the "empty context is equivalent to ALL" caveat that is now impossible to reach. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
1 parent 7ddb783 commit 03b669b

4 files changed

Lines changed: 1203 additions & 1156 deletions

File tree

go/vt/sqlparser/parse_test.go

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2660,9 +2660,6 @@ var validSQL = []struct {
26602660
input: "alter vitess_migration cleanup all",
26612661
}, {
26622662
input: "alter vitess_migration cleanup context 'some-context'",
2663-
}, {
2664-
input: "alter vitess_migration cleanup context ''",
2665-
output: "alter vitess_migration cleanup all",
26662663
}, {
26672664
input: "alter vitess_migration '9748c3b7_7fdb_11eb_ac2c_f875a4d24e90' launch",
26682665
}, {
@@ -2673,9 +2670,6 @@ var validSQL = []struct {
26732670
input: "alter vitess_migration launch all",
26742671
}, {
26752672
input: "alter vitess_migration launch context 'some-context'",
2676-
}, {
2677-
input: "alter vitess_migration launch context ''",
2678-
output: "alter vitess_migration launch all",
26792673
}, {
26802674
input: "alter vitess_migration '9748c3b7_7fdb_11eb_ac2c_f875a4d24e90' complete",
26812675
}, {
@@ -2686,27 +2680,18 @@ var validSQL = []struct {
26862680
input: "alter vitess_migration complete all",
26872681
}, {
26882682
input: "alter vitess_migration complete context 'some-context'",
2689-
}, {
2690-
input: "alter vitess_migration complete context ''",
2691-
output: "alter vitess_migration complete all",
26922683
}, {
26932684
input: "alter vitess_migration '9748c3b7_7fdb_11eb_ac2c_f875a4d24e90' postpone complete",
26942685
}, {
26952686
input: "alter vitess_migration postpone complete all",
26962687
}, {
26972688
input: "alter vitess_migration postpone complete context 'some-context'",
2698-
}, {
2699-
input: "alter vitess_migration postpone complete context ''",
2700-
output: "alter vitess_migration postpone complete all",
27012689
}, {
27022690
input: "alter vitess_migration '9748c3b7_7fdb_11eb_ac2c_f875a4d24e90' cancel",
27032691
}, {
27042692
input: "alter vitess_migration force_cutover all",
27052693
}, {
27062694
input: "alter vitess_migration force_cutover context 'some-context'",
2707-
}, {
2708-
input: "alter vitess_migration force_cutover context ''",
2709-
output: "alter vitess_migration force_cutover all",
27102695
}, {
27112696
input: "alter vitess_migration '9748c3b7_7fdb_11eb_ac2c_f875a4d24e90' force_cutover",
27122697
}, {
@@ -2738,19 +2723,10 @@ var validSQL = []struct {
27382723
input: "alter vitess_migration throttle context 'some-context' ratio 0.7",
27392724
}, {
27402725
input: "alter vitess_migration throttle context 'some-context' expire '1h' ratio 0.7",
2741-
}, {
2742-
input: "alter vitess_migration throttle context ''",
2743-
output: "alter vitess_migration throttle all",
2744-
}, {
2745-
input: "alter vitess_migration throttle context '' expire '1h' ratio 0.7",
2746-
output: "alter vitess_migration throttle all expire '1h' ratio 0.7",
27472726
}, {
27482727
input: "alter vitess_migration unthrottle all",
27492728
}, {
27502729
input: "alter vitess_migration unthrottle context 'some-context'",
2751-
}, {
2752-
input: "alter vitess_migration unthrottle context ''",
2753-
output: "alter vitess_migration unthrottle all",
27542730
}, {
27552731
input: "alter vitess_migration throttle all expire '1h'",
27562732
}, {
@@ -6536,6 +6512,30 @@ var invalidSQL = []struct {
65366512
}{{
65376513
input: "alter vitess_migration cancel context ''",
65386514
output: "migration context cannot be empty at position 41",
6515+
}, {
6516+
input: "alter vitess_migration cleanup context ''",
6517+
output: "migration context cannot be empty at position 42",
6518+
}, {
6519+
input: "alter vitess_migration launch context ''",
6520+
output: "migration context cannot be empty at position 41",
6521+
}, {
6522+
input: "alter vitess_migration complete context ''",
6523+
output: "migration context cannot be empty at position 43",
6524+
}, {
6525+
input: "alter vitess_migration postpone complete context ''",
6526+
output: "migration context cannot be empty at position 52",
6527+
}, {
6528+
input: "alter vitess_migration force_cutover context ''",
6529+
output: "migration context cannot be empty at position 48",
6530+
}, {
6531+
input: "alter vitess_migration throttle context ''",
6532+
output: "migration context cannot be empty at position 43",
6533+
}, {
6534+
input: "alter vitess_migration throttle context '' expire '1h' ratio 0.7",
6535+
output: "migration context cannot be empty at position 65 near '0.7'",
6536+
}, {
6537+
input: "alter vitess_migration unthrottle context ''",
6538+
output: "migration context cannot be empty at position 45",
65396539
}, {
65406540
input: "select : from t",
65416541
output: "syntax error at position 9 near ':'",

0 commit comments

Comments
 (0)