MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:gluh Date:May 18 2005 7:47am
Subject:bk commit into 5.0 tree (gluh:1.1844) BUG#9286
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of gluh. When gluh 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.1844 05/05/18 12:47:45 gluh@stripped +4 -0
  Fix for bug #9286: SESSION/GLOBAL should be disallowed for user variables(for 5.0)

  sql/sql_yacc.yy
    1.377 05/05/18 12:46:45 gluh@stripped +104 -79
    Fix for bug #9286: SESSION/GLOBAL should be disallowed for user variables(for 5.0)

  sql/set_var.h
    1.65 05/05/18 12:46:45 gluh@stripped +1 -1
    Fix for bug #9286: SESSION/GLOBAL should be disallowed for user variables(for 5.0)

  mysql-test/t/user_var.test
    1.29 05/05/18 12:46:45 gluh@stripped +1 -0
    Fix for bug #9286: SESSION/GLOBAL should be disallowed for user variables(for 5.0)

  mysql-test/r/user_var.result
    1.34 05/05/18 12:46:45 gluh@stripped +1 -0
    Fix for bug #9286: SESSION/GLOBAL should be disallowed for user variables(for 5.0)

# 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:	gluh
# Host:	eagle.intranet.mysql.r18.ru
# Root:	/home/gluh/MySQL/Bugs/5.0.9286

--- 1.376/sql/sql_yacc.yy	Tue May 17 23:57:22 2005
+++ 1.377/sql/sql_yacc.yy	Wed May 18 12:46:45 2005
@@ -698,7 +698,7 @@
         opt_var_ident_type delete_option opt_temporary all_or_any opt_distinct
         opt_ignore_leaves fulltext_options spatial_type union_option
         start_transaction_opts opt_chain opt_release
-        union_opt select_derived_init
+        union_opt select_derived_init option_type option_type2
 
 %type <ulong_num>
 	ulong_num raid_types merge_insert_types
@@ -7475,7 +7475,7 @@
 	    lex->sphead->m_tmp_query= lex->tok_start;
           }
         }
-	option_type option_value
+	ext_option_value
         {
           LEX *lex= Lex;
 
@@ -7516,11 +7516,15 @@
         };
 
 option_type:
-	/* empty */	{}
-	| GLOBAL_SYM	{ Lex->option_type= OPT_GLOBAL; }
-	| LOCAL_SYM	{ Lex->option_type= OPT_SESSION; }
-	| SESSION_SYM	{ Lex->option_type= OPT_SESSION; }
-	| ONE_SHOT_SYM	{ Lex->option_type= OPT_SESSION; Lex->one_shot_set= 1; }
+        option_type2    {}
+	| GLOBAL_SYM	{ $$=OPT_GLOBAL; }
+	| LOCAL_SYM	{ $$=OPT_SESSION; }
+	| SESSION_SYM	{ $$=OPT_SESSION; }
+	;
+
+option_type2:
+	/* empty */	{ $$= OPT_DEFAULT; }
+	| ONE_SHOT_SYM	{ Lex->one_shot_set= 1; $$= OPT_SESSION; }
 	;
 
 opt_var_type:
@@ -7537,88 +7541,109 @@
 	| SESSION_SYM '.'	{ $$=OPT_SESSION; }
 	;
 
-option_value:
-	  '@' ident_or_text equal expr
-	  {
-            Lex->var_list.push_back(new set_var_user(new Item_func_set_user_var($2,$4)));
-	  }
-	| internal_variable_name equal set_expr_or_default
-	  {
-	    LEX *lex=Lex;
+ext_option_value:
+        sys_option_value
+        | option_type2 option_value;
 
-            if ($1.var == &trg_new_row_fake_var)
+sys_option_value:
+        option_type internal_variable_name equal set_expr_or_default
+        {
+          LEX *lex=Lex;
+
+          if ($2.var == &trg_new_row_fake_var)
+          {
+            /* We are in trigger and assigning value to field of new row */
+            Item *it;
+            sp_instr_set_trigger_field *i;
+            if ($1)
             {
-              /* We are in trigger and assigning value to field of new row */
-              Item *it;
-              sp_instr_set_trigger_field *i;
-              if (lex->query_tables)
-              {
-                my_message(ER_SP_SUBSELECT_NYI, ER(ER_SP_SUBSELECT_NYI),
-                           MYF(0));
-                YYABORT;
-              }
-              if ($3)
-                it= $3;
-              else
-              {
-                /* QQ: Shouldn't this be field's default value ? */
-                it= new Item_null();
-              }
-              
-              if (!(i= new sp_instr_set_trigger_field(
-                             lex->sphead->instructions(), lex->spcont,
-                             $1.base_name, it)))
-                YYABORT;
-              
-              /*
-                Let us add this item to list of all Item_trigger_field
-                objects in trigger.
-              */
-              lex->trg_table_fields.link_in_list((byte *)&i->trigger_field,
-                     (byte **)&i->trigger_field.next_trg_field);
+              yyerror(ER(ER_SYNTAX_ERROR));
+              YYABORT;
+            }
+            if (lex->query_tables)
+            {
+              my_message(ER_SP_SUBSELECT_NYI, ER(ER_SP_SUBSELECT_NYI),
+              MYF(0));
+              YYABORT;
+            }
+            if ($4)
+              it= $4;
+            else
+            {
+              /* QQ: Shouldn't this be field's default value ? */
+              it= new Item_null();
+            }
 
-              lex->sphead->add_instr(i);
+            if (!(i= new sp_instr_set_trigger_field(
+                lex->sphead->instructions(), lex->spcont,
+                $2.base_name, it)))
+              YYABORT;
+
+            /*
+              Let us add this item to list of all Item_trigger_field
+              objects in trigger.
+            */
+            lex->trg_table_fields.link_in_list((byte *)&i->trigger_field,
+            (byte **)&i->trigger_field.next_trg_field);
+
+            lex->sphead->add_instr(i);
+          }
+          else if ($2.var)
+          { /* System variable */
+            if ($1)
+              lex->option_type= (enum_var_type)$1;
+            lex->var_list.push_back(new set_var(lex->option_type, $2.var,
+                                    &$2.base_name, $4));
+          }
+          else
+          {
+            /* An SP local variable */
+            sp_pcontext *ctx= lex->spcont;
+            sp_pvar_t *spv;
+            sp_instr_set *i;
+            Item *it;
+            if ($1)
+            {
+              yyerror(ER(ER_SYNTAX_ERROR));
+              YYABORT;
             }
-            else if ($1.var)
-	    { /* System variable */
-	      lex->var_list.push_back(new set_var(lex->option_type, $1.var,
-						  &$1.base_name, $3));
-	    }
+
+            spv= ctx->find_pvar(&$2.base_name);
+
+            if ($4)
+              it= $4;
+            else if (spv->dflt)
+              it= spv->dflt;
             else
-	    {
-	      /* An SP local variable */
-	      sp_pcontext *ctx= lex->spcont;
-	      sp_pvar_t *spv;
-              sp_instr_set *i;
-	      Item *it;
-
-	      spv= ctx->find_pvar(&$1.base_name);
-
-	      if ($3)
-	        it= $3;
-	      else if (spv->dflt)
-	        it= spv->dflt;
-	      else
-	        it= new Item_null();
-              i= new sp_instr_set(lex->sphead->instructions(), ctx,
-	                          spv->offset, it, spv->type, lex, TRUE);
-	      lex->sphead->add_instr(i);
-	      spv->isset= TRUE;
-	    }
-	  }
+              it= new Item_null();
+            i= new sp_instr_set(lex->sphead->instructions(), ctx,
+                                spv->offset, it, spv->type, lex, TRUE);
+            lex->sphead->add_instr(i);
+            spv->isset= TRUE;
+          }
+        }
+        | option_type TRANSACTION_SYM ISOLATION LEVEL_SYM isolation_types
+	{
+	  LEX *lex=Lex;
+          if (!$1)
+            lex->option_type= (enum_var_type)$1;
+	  lex->var_list.push_back(new set_var(lex->option_type,
+                                              find_sys_var("tx_isolation"),
+                                              &null_lex_str,
+                                              new Item_int((int32) $5)));
+	}
+        ;
+
+option_value:
+	'@' ident_or_text equal expr
+	{
+          Lex->var_list.push_back(new set_var_user(new Item_func_set_user_var($2,$4)));
+	}
 	| '@' '@' opt_var_ident_type internal_variable_name equal set_expr_or_default
 	  {
 	    LEX *lex=Lex;
 	    lex->var_list.push_back(new set_var((enum_var_type) $3, $4.var,
 						&$4.base_name, $6));
-	  }
-	| TRANSACTION_SYM ISOLATION LEVEL_SYM isolation_types
-	  {
-	    LEX *lex=Lex;
-	    lex->var_list.push_back(new set_var(lex->option_type,
-						find_sys_var("tx_isolation"),
-						&null_lex_str,
-						new Item_int((int32) $4)));
 	  }
 	| charset old_or_new_charset_name_or_default
 	{

--- 1.64/sql/set_var.h	Mon May  9 14:26:47 2005
+++ 1.65/sql/set_var.h	Wed May 18 12:46:45 2005
@@ -32,7 +32,7 @@
 
 enum enum_var_type
 {
-  OPT_DEFAULT, OPT_SESSION, OPT_GLOBAL
+  OPT_DEFAULT= 0, OPT_SESSION, OPT_GLOBAL
 };
 
 typedef int (*sys_check_func)(THD *,  set_var *);

--- 1.33/mysql-test/r/user_var.result	Sat Apr 30 05:14:38 2005
+++ 1.34/mysql-test/r/user_var.result	Wed May 18 12:46:45 2005
@@ -180,6 +180,7 @@
 coercibility(@v1)	coercibility(@v2)	coercibility(@v3)	coercibility(@v4)
 2	2	2	2
 set session @honk=99;
+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 '@honk=99' at line 1
 set one_shot @honk=99;
 ERROR HY000: The 'SET ONE_SHOT' syntax is reserved for purposes internal to the MySQL server
 set @first_var= NULL;

--- 1.28/mysql-test/t/user_var.test	Sat Apr 30 05:14:38 2005
+++ 1.29/mysql-test/t/user_var.test	Wed May 18 12:46:45 2005
@@ -116,6 +116,7 @@
 #
 # Bug #9286  SESSION/GLOBAL should be disallowed for user variables
 #
+--error 1064
 set session @honk=99;
 --error 1382
 set one_shot @honk=99;
Thread
bk commit into 5.0 tree (gluh:1.1844) BUG#9286gluh18 May