List:Commits« Previous MessageNext Message »
From:Alexander Nozdrin Date:November 30 2007 3:31pm
Subject:bk commit into 5.1 tree (anozdrin:1.2673) BUG#31947
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of alik. When alik does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-11-30 17:31:26+03:00, anozdrin@ibm. +3 -0
  A patch for BUG#31947: Declare with a reserved word succeeded.
  
  The problem here was that "read_only" was explicitly allowed
  as an indentifier. Probably that was done in order to allow
  "read_only" system variable name.
  
  The fix is to change parsing rules so that "read_only" can not
  be used as an identifier, but allowed as a system variable name.

  mysql-test/r/sp.result@stripped, 2007-11-30 17:31:22+03:00, anozdrin@ibm. +20 -0
    Update result file.

  mysql-test/t/sp.test@stripped, 2007-11-30 17:31:22+03:00, anozdrin@ibm. +35 -0
    Add a test case for BUG#31947: Declare with a reserved word succeeded.

  sql/sql_yacc.yy@stripped, 2007-11-30 17:31:22+03:00, anozdrin@ibm. +28 -15
    Introduce new rules for system and user variable names.
    Allow using "read_only" as a variable name;
    prohibit "read_only" as an identifier.

diff -Nrup a/mysql-test/r/sp.result b/mysql-test/r/sp.result
--- a/mysql-test/r/sp.result	2007-11-14 16:28:18 +03:00
+++ b/mysql-test/r/sp.result	2007-11-30 17:31:22 +03:00
@@ -6911,4 +6911,24 @@ END	latin1	latin1_swedish_ci	latin1_swed
 
 DROP FUNCTION f1;
 
+#
+# Bug#31947: Declare with a reserved word succeeded.
+#
+
+DROP PROCEDURE IF EXISTS p1;
+
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE read_only INT;
+END|
+ERROR 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 'read_only INT;
+END' at line 3
+
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE `read_only` INT;
+END|
+
+DROP PROCEDURE p1;
+
 End of 5.1 tests
diff -Nrup a/mysql-test/t/sp.test b/mysql-test/t/sp.test
--- a/mysql-test/t/sp.test	2007-10-29 17:37:17 +03:00
+++ b/mysql-test/t/sp.test	2007-11-30 17:31:22 +03:00
@@ -8054,6 +8054,41 @@ DROP FUNCTION f1;
 
 --echo
 
+
+--echo #
+--echo # Bug#31947: Declare with a reserved word succeeded.
+--echo #
+--echo
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS p1;
+--enable_warnings
+
+delimiter |;
+
+--echo
+
+--error ER_PARSE_ERROR
+CREATE PROCEDURE p1()
+BEGIN
+  DECLARE read_only INT;
+END|
+
+--echo
+
+CREATE PROCEDURE p1()
+BEGIN
+  DECLARE `read_only` INT;
+END|
+
+--echo
+
+delimiter ;|
+
+DROP PROCEDURE p1;
+
+--echo
+
 ###########################################################################
 
 --echo End of 5.1 tests
diff -Nrup a/sql/sql_yacc.yy b/sql/sql_yacc.yy
--- a/sql/sql_yacc.yy	2007-11-28 19:08:26 +03:00
+++ b/sql/sql_yacc.yy	2007-11-30 17:31:22 +03:00
@@ -1113,6 +1113,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
         IDENT_sys TEXT_STRING_sys TEXT_STRING_literal
         NCHAR_STRING opt_component key_cache_name
         sp_opt_label BIN_NUM label_ident TEXT_STRING_filesystem ident_or_empty
+        sys_var_name user_var_name
 
 %type <lex_str_ptr>
         opt_table_alias
@@ -1435,7 +1436,7 @@ prepare_src:
             lex->prepared_stmt_code= $1;
             lex->prepared_stmt_code_is_varref= FALSE;
           }
-        | '@' ident_or_text
+        | '@' user_var_name
           {
             THD *thd= YYTHD;
             LEX *lex= thd->lex;
@@ -1467,7 +1468,7 @@ execute_var_list:
         ;
 
 execute_var_ident:
-          '@' ident_or_text
+          '@' user_var_name
           {
             LEX *lex=Lex;
             LEX_STRING *lexstr= (LEX_STRING*)sql_memdup(&$2, sizeof(LEX_STRING));
@@ -7271,19 +7272,19 @@ variable:
         ;
 
 variable_aux:
-          ident_or_text SET_VAR expr
+          user_var_name SET_VAR expr
           {
             $$= new Item_func_set_user_var($1, $3);
             LEX *lex= Lex;
             lex->uncacheable(UNCACHEABLE_RAND);
           }
-        | ident_or_text
+        | user_var_name
           {
             $$= new Item_func_get_user_var($1);
             LEX *lex= Lex;
             lex->uncacheable(UNCACHEABLE_RAND);
           }
-        | '@' opt_var_ident_type ident_or_text opt_component
+        | '@' opt_var_ident_type user_var_name opt_component
           {
             if ($3.str && $4.str && check_reserved_words(&$3))
             {
@@ -8254,7 +8255,7 @@ select_var_list:
         ;
 
 select_var_ident:  
-          '@' ident_or_text
+          '@' user_var_name
           {
             LEX *lex=Lex;
             if (lex->result) 
@@ -9618,7 +9619,7 @@ fields_or_vars:
 
 field_or_var:
           simple_ident_nospvar {$$= $1;}
-        | '@' ident_or_text
+        | '@' user_var_name
           { $$= new Item_user_var_as_out_param($2); }
         ;
 
@@ -10130,19 +10131,31 @@ TEXT_STRING_filesystem:
 
 ident:
           IDENT_sys    { $$=$1; }
+        | keyword
+          {
+            THD *thd= YYTHD;
+            $$.str= thd->strmake($1.str, $1.length);
+            $$.length= $1.length;
+          }
+        ;
+
+sys_var_name:
+          ident
         | READ_ONLY_SYM
           {
             THD *thd= YYTHD;
             $$.str= thd->strmake("read_only",9);
             $$.length= 9;
           }
-        | keyword
+
+user_var_name:
+          ident_or_text
+        | READ_ONLY_SYM
           {
             THD *thd= YYTHD;
-            $$.str= thd->strmake($1.str, $1.length);
-            $$.length= $1.length;
+            $$.str= thd->strmake("read_only",9);
+            $$.length= 9;
           }
-        ;
 
 label_ident:
           IDENT_sys    { $$=$1; }
@@ -10745,7 +10758,7 @@ sys_option_value:
         ;
 
 option_value:
-          '@' ident_or_text equal expr
+          '@' user_var_name equal expr
           {
             Lex->var_list.push_back(new set_var_user(new
Item_func_set_user_var($2,$4)));
           }
@@ -10823,7 +10836,7 @@ option_value:
         ;
 
 internal_variable_name:
-          ident
+          sys_var_name
           {
             THD *thd= YYTHD;
             LEX *lex= thd->lex;
@@ -10855,7 +10868,7 @@ internal_variable_name:
               $$.base_name= $1;
             }
           }
-        | ident '.' ident
+        | sys_var_name '.' sys_var_name
           {
             LEX *lex= Lex;
             if (check_reserved_words(&$1))
@@ -10898,7 +10911,7 @@ internal_variable_name:
               $$.base_name= $1;
             }
           }
-        | DEFAULT '.' ident
+        | DEFAULT '.' sys_var_name
           {
             sys_var *tmp=find_sys_var(YYTHD, $3.str, $3.length);
             if (!tmp)
Thread
bk commit into 5.1 tree (anozdrin:1.2673) BUG#31947Alexander Nozdrin30 Nov
  • Re: bk commit into 5.1 tree (anozdrin:1.2673) BUG#31947Sergei Golubchik30 Nov