-
-
Notifications
You must be signed in to change notification settings - Fork 2k
MDEV-17677: Fix keyword parsing that treated as identifier when immediately followed by dot #4713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 12.3
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2114,3 +2114,24 @@ DELIMITER ;$$ | |
| --echo # | ||
| --echo # End of 11.7 tests | ||
| --echo # | ||
|
|
||
| --echo # | ||
| --echo # MDEV-17677 : Keywords are parsed as identifiers when followed by a dot | ||
| --echo # | ||
|
|
||
| --echo : dot after SELECT | ||
| SELECT.1; | ||
| SELECT .1; | ||
| SELECT-.1; | ||
| --error ER_PARSE_ERROR | ||
| SELECT.abc; | ||
|
|
||
| --echo : expressions | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please also consider testing for the other classes of symbols in |
||
| SELECT.123+0; | ||
| SELECT.5 * 2; | ||
|
|
||
| --echo : still work as identifier | ||
| CREATE TABLE `SELECT` (a INT); | ||
| INSERT INTO `SELECT` VALUES (5); | ||
| SELECT `SELECT`.a FROM `SELECT`; | ||
| DROP TABLE `SELECT`; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2899,16 +2899,26 @@ int Lex_input_stream::scan_ident_middle(THD *thd, Lex_ident_cli_st *str, | |
| yylineno++; | ||
| } | ||
| } | ||
| // here we check if the current token is a keyword followed by a dot and then digit | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not an expert, so please consider this optional until the final review: Before your change this is what it looked like: This is basically saying the following: Therein lies the issue. According to the SQL standard: An identifier is defined as: This means that a valid identifier cannot start with a digit! However, ident_map[] is true for the standard's This is how the extra between Here, in this if() the last condition should be extended to exclude This has nothing to do with the leading identifier being a keyword or not. This will be handled by the grammar, according to the context. |
||
| // if it's the case, we want to return it as keyword not identifier | ||
| int tokval= find_keyword(str, length, false); | ||
| if (tokval && c == '.' && my_isdigit(cs, yyPeek())) | ||
| { | ||
| yyUnget(); | ||
| return tokval; | ||
| } | ||
| if (start == get_ptr() && c == '.' && ident_map[(uchar) yyPeek()]) | ||
| { | ||
| next_state= MY_LEX_IDENT_SEP; | ||
| } | ||
| else | ||
| { // '(' must follow directly if function | ||
| int tokval; | ||
| int tokval2; | ||
| yyUnget(); | ||
| if ((tokval= find_keyword(str, length, c == '('))) | ||
| if ((tokval2= find_keyword(str, length, c == '('))) | ||
| { | ||
| next_state= MY_LEX_START; // Allow signed numbers | ||
| return(tokval); // Was keyword | ||
| return(tokval2); // Was keyword | ||
| } | ||
| yySkip(); // next state does a unget | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please re-base to 10.11. This is a bug in MDEV-16020 that was pushed to 10.3.7.