Bug #76943 PARSE_GCOL_EXPR should be a kind of reserved word, not a keyword
Submitted: 5 May 2015 18:48 Modified: 16 May 2015 13:36
Reporter: Gleb Shchepa Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Parser Severity:S3 (Non-critical)
Version:5.7 OS:Any
Assigned to: CPU Architecture:Any

[5 May 2015 18:48] Gleb Shchepa
Description:
WL#411 introduces an internal PARSE_GCOL_EXPR keyword: we use it to simulate multiple grammars in sql_yacc.yy, especially a sub-grammar to parse generated column expressions from .frm.

The new PARSE_GCOL_EXPR_SYM token behaves as a keyword in the main grammar: we can't use the "PARSE_GCOL_EXPR" name for plain table/column names, user variable/function/procedure etc. names. Such a new limitation is not necessary and unwanted.

How to repeat:
mysql> CREATE TABLE parse_gcol_expr (i INT);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'parse_gcol_expr' at line 1

Suggested fix:
Add the PARSE_GCOL_EXPR_SYM token to the "keyword" grammar rule's right hand side list:

diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 0fd4313..5604da6 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -13173,6 +13173,7 @@ keyword:
         | OPTIONS_SYM           {}
         | OWNER_SYM             {}
         | PARSER_SYM            {}
+        | PARSE_GCOL_EXPR_SYM   {}
         | PORT_SYM              {}
         | PRECEDES_SYM          {}
         | PREPARE_SYM           {}

mysql> CREATE TABLE parse_gcol_expr (i INT);
Query OK, 0 rows affected (0,31 sec)

Note: it would be nice to insert that new token into the "keyword_sp" rule instead of "keyword", however we can't -- it will introduce a lot of new grammar conflicts, since PARSE_GCOL_EXPR_SYM is the 1st token of the pseudo-statement.
Thus, after the fix we'll can use the PARSE_GCOL_EXPR string for table/column/variable/function etc names, but still can't use it for SP/SF labels.
[16 May 2015 13:36] Paul DuBois
Noted in 5.7.8, 5.8.0 changelogs.

The PARSE_GCOL_EXPR keyword used internally by the parser was treated
as a reserved word and thus could not be used as an identifier
without quoting it.