List:Commits« Previous MessageNext Message »
From:Andrei Elkin Date:May 5 2006 10:21am
Subject:bk commit into 4.1 tree (aelkin:1.2480) BUG#19136
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of elkin. When elkin 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.2480 06/05/05 11:21:21 aelkin@stripped +3 -0
  Bug#19136: Crashing log-bin and uninitialized user variables in a derived table
  
  The reason of the bug is in that `get_var_with_binlog' performs missed
  assingment of
  the variables as side-effect. Doing that it eventually calls
  `free_underlaid_joins' to pass as an argument `thd->lex->select_lex' of the lex
  which belongs to the user query, not 
  to one which is emulated i.e SET @var1:=NULL.
  
  
  `get_var_with_binlog' is refined to supply a temporary lex to sql_set_variables's stack.

  sql/item_func.cc
    1.260 06/05/05 11:21:18 aelkin@stripped +10 -0
    BUG#19136: Crashing log-bin and uninitialized user variables
    
    The reason of the bug is in that how `get_var_with_binlog' performs missed
    assingment of the variables: `free_underlaid_joins' gets as an argument
`thd->lex->select_lex'
    which belongs to the user query, not to one which is emulated i.e SET @var1:=NULL.
    
    `get_var_with_binlog' is refined to supply a temporary lex to sql_set_variables's
stack.
    

  mysql-test/t/rpl_user_variables.test
    1.8 06/05/05 11:21:17 aelkin@stripped +6 -0
    a problematic query to be binlogged is added

  mysql-test/r/rpl_user_variables.result
    1.11 06/05/05 11:21:17 aelkin@stripped +1 -0
    results changed

# 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:	aelkin
# Host:	dsl-hkigw8-feb0de00-199.dhcp.inet.fi
# Root:	/usr_rh9/home/elkin.rh9/MySQL/FIXES/4.1-bug19136_unass_user_var

--- 1.259/sql/item_func.cc	2006-04-12 22:02:02 +03:00
+++ 1.260/sql/item_func.cc	2006-05-05 11:21:18 +03:00
@@ -2733,14 +2733,24 @@
       sql_set_variables(), we could instead manually call check() and update();
       this would save memory and time; but calling sql_set_variables() makes
       one unique place to maintain (sql_set_variables()). 
+
+      Manipulation with lex is necessary since free_underlaid_joins
+      is going to release memory belonging to the main query.
     */
 
     List<set_var_base> tmp_var_list;
+    LEX *sav_lex= thd->lex, lex_tmp;
+    thd->lex= &lex_tmp;
+    lex_start(thd, NULL, 0);
     tmp_var_list.push_back(new set_var_user(new Item_func_set_user_var(name,
                                                                        new
Item_null())));
     /* Create the variable */
     if (sql_set_variables(thd, &tmp_var_list))
+    {
+      thd->lex= sav_lex;
       goto err;
+    }
+    thd->lex= sav_lex;
     if (!(var_entry= get_variable(&thd->user_vars, name, 0)))
       goto err;
   }

--- 1.10/mysql-test/r/rpl_user_variables.result	2004-06-23 13:36:02 +03:00
+++ 1.11/mysql-test/r/rpl_user_variables.result	2006-05-05 11:21:17 +03:00
@@ -105,5 +105,6 @@
 slave-bin.000001	1412	Query	1	1412	use `test`; insert into t1 values (@a),(@a)
 slave-bin.000001	1478	User var	2	1478	@`a`=NULL
 slave-bin.000001	1503	Query	1	1503	use `test`; insert into t1 values (@a),(@a),(@a*5)
+insert into t1 select * FROM (select @var1 union  select @var2) AS t2;
 drop table t1;
 stop slave;

--- 1.7/mysql-test/t/rpl_user_variables.test	2005-07-28 03:21:49 +03:00
+++ 1.8/mysql-test/t/rpl_user_variables.test	2006-05-05 11:21:17 +03:00
@@ -47,9 +47,15 @@
 sync_with_master;
 select * from t1;
 show binlog events from 141;
+
+#
+# BUG19136: Crashing log-bin and uninitialized user variables in a derived table
+# just to check nothing bad happens anymore
 connection master;
+insert into t1 select * FROM (select @var1 union  select @var2) AS t2;
 drop table t1;
 save_master_pos;
+
 connection slave;
 sync_with_master;
 stop slave;
Thread
bk commit into 4.1 tree (aelkin:1.2480) BUG#19136Andrei Elkin5 May