[fix](compatibility) add some keywords (#29251)
1. Add `BINARY` keywords
`BINARY` is used for tell MySQL to treat a String(or String column) as case sensitive.
eg: `"abc" = "ABC"` is true, but `BINARY "abc" = "ABC"` is false.
But in Doris, `"abc" = "ABC"` is false by default.
I add this `BINARY` keyword just for compatibility, it will take no effect.
2. Add `PARTITIONS` and `AUTO_INCREMENT` as reserved words.
`PARTITIONS` is the table name in `information_schema` database.
`AUTO_INCREMENT` is a column name of a table in `information_schema`
This commit is contained in:
@ -121,6 +121,7 @@ BEGIN: 'BEGIN';
|
||||
BETWEEN: 'BETWEEN';
|
||||
BIGINT: 'BIGINT';
|
||||
BIN: 'BIN';
|
||||
BINARY: 'BINARY';
|
||||
BINLOG: 'BINLOG';
|
||||
BITAND: 'BITAND';
|
||||
BITMAP: 'BITMAP';
|
||||
|
||||
@ -678,7 +678,7 @@ primaryExpression
|
||||
| LEFT_PAREN query RIGHT_PAREN #subqueryExpression
|
||||
| ATSIGN identifierOrText #userVariable
|
||||
| DOUBLEATSIGN (kind=(GLOBAL | SESSION) DOT)? identifier #systemVariable
|
||||
| identifier #columnReference
|
||||
| BINARY? identifier #columnReference
|
||||
| base=primaryExpression DOT fieldName=identifier #dereference
|
||||
| LEFT_PAREN expression RIGHT_PAREN #parenthesizedExpression
|
||||
| KEY (dbName=identifier DOT)? keyName=identifier #encryptKey
|
||||
@ -760,7 +760,7 @@ constant
|
||||
| type=(DATE | DATEV1 | DATEV2 | TIMESTAMP) STRING_LITERAL #typeConstructor
|
||||
| number #numericLiteral
|
||||
| booleanValue #booleanLiteral
|
||||
| STRING_LITERAL #stringLiteral
|
||||
| BINARY? STRING_LITERAL #stringLiteral
|
||||
| LEFT_BRACKET (items+=constant)? (COMMA items+=constant)* RIGHT_BRACKET #arrayLiteral
|
||||
| LEFT_BRACE (items+=constant COLON items+=constant)?
|
||||
(COMMA items+=constant COLON items+=constant)* RIGHT_BRACE #mapLiteral
|
||||
@ -898,6 +898,7 @@ nonReserved
|
||||
| ARRAY
|
||||
| AT
|
||||
| AUTHORS
|
||||
| AUTO_INCREMENT
|
||||
| BACKENDS
|
||||
| BACKUP
|
||||
| BEGIN
|
||||
@ -1067,6 +1068,7 @@ nonReserved
|
||||
| PASSWORD_HISTORY
|
||||
| PASSWORD_LOCK_TIME
|
||||
| PASSWORD_REUSE
|
||||
| PARTITIONS
|
||||
| PATH
|
||||
| PAUSE
|
||||
| PERCENT
|
||||
|
||||
@ -7557,6 +7557,8 @@ keyword ::=
|
||||
{: RESULT = id; :}
|
||||
| KW_ARRAY:id
|
||||
{: RESULT = id; :}
|
||||
| KW_AUTO_INCREMENT:id
|
||||
{: RESULT = id; :}
|
||||
| KW_BACKUP:id
|
||||
{: RESULT = id; :}
|
||||
| KW_BEGIN:id
|
||||
@ -7783,6 +7785,8 @@ keyword ::=
|
||||
{: RESULT = id; :}
|
||||
| KW_PARAMETER:id
|
||||
{: RESULT = id; :}
|
||||
| KW_PARTITIONS:id
|
||||
{: RESULT = id; :}
|
||||
| KW_PASSWORD:id
|
||||
{: RESULT = id; :}
|
||||
| KW_PASSWORD_EXPIRE:id
|
||||
|
||||
@ -457,4 +457,19 @@ public class NereidsParserTest extends ParserTestBase {
|
||||
NereidsParser nereidsParser = new NereidsParser();
|
||||
nereidsParser.parseSingle(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseBinaryKeyword() {
|
||||
String sql = "SELECT BINARY 'abc' FROM t";
|
||||
NereidsParser nereidsParser = new NereidsParser();
|
||||
nereidsParser.parseSingle(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseReserveKeyword() {
|
||||
// partitions and auto_increment are reserve keywords
|
||||
String sql = "SELECT BINARY 'abc' FROM information_schema.partitions order by AUTO_INCREMENT";
|
||||
NereidsParser nereidsParser = new NereidsParser();
|
||||
nereidsParser.parseSingle(sql);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user