Skip to content

Commit

Permalink
parser: Update TestCompareReservedWordsWithMySQL (pingcap#48857)
Browse files Browse the repository at this point in the history
  • Loading branch information
dveeden authored Jan 22, 2024
1 parent 301d1d2 commit 8e1f5e4
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions pkg/parser/reserved_words_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,14 @@ func TestCompareReservedWordsWithMySQL(t *testing.T) {

for _, kw := range reservedKeywords {
switch kw {
case "CURRENT_ROLE", "INTERSECT", "STATS_EXTENDED", "TABLESAMPLE":
// special case: we do reserve these words but MySQL didn't,
case "CURRENT_ROLE", // Present in both, reserved only in TiDB
"STATS_EXTENDED", // Only in TiDB
"TABLESAMPLE", // Only in TiDB
"ARRAY", // added in 8.0.17 (reserved); became nonreserved in 8.0.19
"ILIKE", // Only in TiDB
"TiDB_CURRENT_TSO", // Only in TiDB
"UNTIL": // Present in both, reserved only in TiDB
// special cases: we do reserve these words but MySQL didn't,
// and unreservering it causes legit parser conflict.
continue
}
Expand All @@ -83,15 +89,18 @@ func TestCompareReservedWordsWithMySQL(t *testing.T) {
requires.Regexp(t, errRegexp, err.Error())
}
_, err = db.Exec(query)
requires.Error(t, err)
requires.Error(t, err, query)
requires.Regexp(t, errRegexp, err.Error(), "MySQL suggests that '%s' should *not* be reserved!", kw)
}

for _, kws := range [][]string{unreservedKeywords, notKeywordTokens, tidbKeywords} {
for _, kw := range kws {
switch kw {
case "FUNCTION", // reserved in 8.0.1
"PURGE", "SYSTEM", "SEPARATOR": // ?
case "FUNCTION", // Reserved in MySQL 8.0.1
"PURGE", // Reserved in MySQL
"SYSTEM", // Reserved in MySQL 8.0.3
"SEPARATOR", // Reserved in MySQL
"DECLARE": // Reserved in MySQL
continue
}

Expand All @@ -103,7 +112,6 @@ func TestCompareReservedWordsWithMySQL(t *testing.T) {
requires.IsType(t, &ast.DoStmt{}, stmts[0])

_, err = db.Exec(query)
println(query)
requires.NoErrorf(t, err, "MySQL suggests that '%s' should be reserved!", kw)
}
}
Expand Down

0 comments on commit 8e1f5e4

Please sign in to comment.