-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix panic inside schema tracker (#17659)
- Loading branch information
1 parent
2bdbb94
commit 77d58fa
Showing
4 changed files
with
31 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -202,6 +202,9 @@ func TestTableTracking(t *testing.T) { | |
tables( | ||
tbl("t4", "create table t4(name varchar(50) primary key)"), | ||
), | ||
tables( | ||
tbl("t5", "create table t5(name varchar(50) primary key with broken syntax)"), | ||
), | ||
} | ||
|
||
testcases := []testCases{{ | ||
|
@@ -234,6 +237,15 @@ func TestTableTracking(t *testing.T) { | |
"t3": {{Name: sqlparser.NewIdentifierCI("id"), Type: querypb.Type_DATETIME, CollationName: "binary", Size: 0, Nullable: true}}, | ||
"t4": {{Name: sqlparser.NewIdentifierCI("name"), Type: querypb.Type_VARCHAR, Size: 50, Nullable: true}}, | ||
}, | ||
}, { | ||
testName: "new broken table", | ||
updTbl: []string{"t5"}, | ||
expTbl: map[string][]vindexes.Column{ | ||
"t1": {{Name: sqlparser.NewIdentifierCI("id"), Type: querypb.Type_INT64, CollationName: "binary", Nullable: true}, {Name: sqlparser.NewIdentifierCI("name"), Type: querypb.Type_VARCHAR, Size: 50, Nullable: true}, {Name: sqlparser.NewIdentifierCI("email"), Type: querypb.Type_VARCHAR, Size: 50, Nullable: false, Default: &sqlparser.Literal{Val: "[email protected]"}}}, | ||
"T1": {{Name: sqlparser.NewIdentifierCI("id"), Type: querypb.Type_VARCHAR, Size: 50, Nullable: true}, {Name: sqlparser.NewIdentifierCI("name"), Type: querypb.Type_VARCHAR, Size: 50, Nullable: true}}, | ||
"t3": {{Name: sqlparser.NewIdentifierCI("id"), Type: querypb.Type_DATETIME, CollationName: "binary", Size: 0, Nullable: true}}, | ||
"t4": {{Name: sqlparser.NewIdentifierCI("name"), Type: querypb.Type_VARCHAR, Size: 50, Nullable: true}}, | ||
}, | ||
}} | ||
|
||
testTracker(t, false, schemaResponse, testcases) | ||
|
@@ -253,6 +265,7 @@ func TestViewsTracking(t *testing.T) { | |
tbl("t3", "create view t3 as select 1 from tbl3"), | ||
), | ||
tables(tbl("t4", "create view t4 as select 1 from tbl4")), | ||
tables(tbl("t4", "create view t5 as select 1 from tbl4 with broken syntax")), | ||
} | ||
|
||
testcases := []testCases{{ | ||
|
@@ -281,6 +294,14 @@ func TestViewsTracking(t *testing.T) { | |
"V1": "select 1, 2 from tbl2", | ||
"t3": "select 1 from tbl3", | ||
"t4": "select 1 from tbl4"}, | ||
}, { | ||
testName: "new broken t5", | ||
updView: []string{"t5"}, | ||
expView: map[string]string{ | ||
"t1": "select 1 from tbl1", | ||
"V1": "select 1, 2 from tbl2", | ||
"t3": "select 1 from tbl3", | ||
"t4": "select 1 from tbl4"}, | ||
}} | ||
|
||
testTracker(t, false, schemaDefResult, testcases) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters