List:Internals« Previous MessageNext Message »
From:pem Date:October 11 2005 1:37pm
Subject:bk commit into 5.0 tree (pem:1.2026) BUG#13510
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of pem. When pem 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
  1.2026 05/10/11 15:01:38 pem@stripped +4 -0
  Fixed BUG#13510: Setting password local variable changes current password
    Disallow conflicting use of variables named "password" and "names". If such
    a variable is declared, and "SET ... = ..." is used for them, an error is
    returned; the user must resolve the conflict by either using `var` (indicating
    that the local variable is set) or by renaming the variable.
    This is necessary since setting "password" and "names" are treated as special
    cases by the parser.

  sql/sql_yacc.yy
    1.432 05/10/11 15:01:31 pem@stripped +23 -0
    Check if "names" or "password" are used as local variable/parameter, in which
    case "set names" or "set password" will be parsed the wrong way. Give an error
    message instead.

  sql/share/errmsg.txt
    1.50 05/10/11 15:01:31 pem@stripped +2 -0
    New error message for when certain variable names are use which would be
    parsed the wrong way. (E.g. "password" and "names")

  mysql-test/t/sp-error.test
    1.90 05/10/11 15:01:31 pem@stripped +53 -0
    New test cases for BUG#13510

  mysql-test/r/sp-error.result
    1.86 05/10/11 15:01:31 pem@stripped +38 -0
    New test cases for BUG#13510

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	pem
# Host:	mysql.comhem.se
# Root:	/usr/home/pem/bug13510/mysql-5.0

--- 1.431/sql/sql_yacc.yy	2005-09-23 09:18:52 +02:00
+++ 1.432/sql/sql_yacc.yy	2005-10-11 15:01:31 +02:00
@@ -7992,6 +7992,18 @@
 	  $2= $2 ? $2: global_system_variables.character_set_client;
 	  lex->var_list.push_back(new set_var_collation_client($2,thd->variables.collation_database,$2));
 	}
+        | NAMES_SYM equal expr
+	  {
+	    LEX *lex= Lex;
+            sp_pcontext *spc= lex->spcont;
+	    LEX_STRING names;
+
+	    names.str= (char *)"names";
+	    names.length= 5;
+	    if (spc && spc->find_pvar(&names))
+              my_error(ER_SP_BAD_VAR_SHADOW, MYF(0), names.str);
+	    YYABORT;
+	  }
 	| NAMES_SYM charset_name_or_default opt_collate
 	{
 	  LEX *lex= Lex;
@@ -8009,6 +8021,17 @@
 	  {
 	    THD *thd=YYTHD;
 	    LEX_USER *user;
+	    LEX *lex= Lex;	    
+            sp_pcontext *spc= lex->spcont;
+	    LEX_STRING pw;
+
+	    pw.str= (char *)"password";
+	    pw.length= 8;
+	    if (spc && spc->find_pvar(&pw))
+	    {
+              my_error(ER_SP_BAD_VAR_SHADOW, MYF(0), pw.str);
+	      YYABORT;
+	    }
 	    if (!(user=(LEX_USER*) thd->alloc(sizeof(LEX_USER))))
 	      YYABORT;
 	    user->host=null_lex_str;

--- 1.49/sql/share/errmsg.txt	2005-10-05 19:58:04 +02:00
+++ 1.50/sql/share/errmsg.txt	2005-10-11 15:01:31 +02:00
@@ -5420,3 +5420,5 @@
 	eng "Cannot delete or update a parent row: a foreign key constraint fails (%.192s)"
 ER_NO_REFERENCED_ROW_2 23000
 	eng "Cannot add or update a child row: a foreign key constraint fails (%.192s)"
+ER_SP_BAD_VAR_SHADOW 42000
+	eng "Variable '%-.64s' must be quoted with `...`, or renamed"

--- 1.85/mysql-test/r/sp-error.result	2005-10-03 19:00:46 +02:00
+++ 1.86/mysql-test/r/sp-error.result	2005-10-11 15:01:31 +02:00
@@ -834,3 +834,41 @@
 create trigger bug12712
 before insert on t1 for each row set session autocommit = 0;
 ERROR HY000: Not allowed to set autocommit from a stored function or trigger
+drop procedure if exists bug13510_1|
+drop procedure if exists bug13510_2|
+drop procedure if exists bug13510_3|
+drop procedure if exists bug13510_4|
+create procedure bug13510_1()
+begin
+declare password varchar(10);
+set password = 'foo1';
+select password;
+end|
+ERROR 42000: Variable 'password' must be quoted with `...`, or renamed
+create procedure bug13510_2()
+begin
+declare names varchar(10);
+set names = 'foo2';
+select names;
+end|
+ERROR 42000: Variable 'names' must be quoted with `...`, or renamed
+create procedure bug13510_3()
+begin
+declare password varchar(10);
+set `password` = 'foo3';
+select password;
+end|
+create procedure bug13510_4()
+begin
+declare names varchar(10);
+set `names` = 'foo4';
+select names;
+end|
+call bug13510_3()|
+password
+foo3
+call bug13510_4()|
+names
+foo4
+drop procedure bug13510_3|
+drop procedure bug13510_4|

--- 1.89/mysql-test/t/sp-error.test	2005-10-03 19:00:49 +02:00
+++ 1.90/mysql-test/t/sp-error.test	2005-10-11 15:01:31 +02:00
@@ -1212,6 +1212,59 @@
 drop procedure bug9367;
 drop table t1;
 --enable_parsing
+
+#
+# BUG#13510: Setting password local variable changes current password
+#
+delimiter |;
+--disable_warnings
+drop procedure if exists bug13510_1|
+drop procedure if exists bug13510_2|
+drop procedure if exists bug13510_3|
+drop procedure if exists bug13510_4|
+--enable_warnings
+
+--error ER_SP_BAD_VAR_SHADOW
+create procedure bug13510_1()
+begin
+  declare password varchar(10);
+
+  set password = 'foo1';
+  select password;
+end|
+
+--error ER_SP_BAD_VAR_SHADOW
+create procedure bug13510_2()
+begin
+  declare names varchar(10);
+
+  set names = 'foo2';
+  select names;
+end|
+
+create procedure bug13510_3()
+begin
+  declare password varchar(10);
+
+  set `password` = 'foo3';
+  select password;
+end|
+
+create procedure bug13510_4()
+begin
+  declare names varchar(10);
+
+  set `names` = 'foo4';
+  select names;
+end|
+
+call bug13510_3()|
+call bug13510_4()|
+
+drop procedure bug13510_3|
+drop procedure bug13510_4|
+delimiter ;|
+
 #
 # BUG#NNNN: New bug synopsis
 #
Thread
bk commit into 5.0 tree (pem:1.2026) BUG#13510pem11 Oct