summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <aelkin@mysql.com>2006-05-07 20:03:08 +0300
committerunknown <aelkin@mysql.com>2006-05-07 20:03:08 +0300
commitc438e4903c144b52c0094eef194f821dc6cc8505 (patch)
tree2a052e5c29885380567a57c0a8ad0539c2930395
parent5b09d7a5e11470613d35808a89892262e1c8951c (diff)
parenta910a0bf6938beaf39d3b1ef8af61195894ab908 (diff)
downloadmariadb-git-c438e4903c144b52c0094eef194f821dc6cc8505.tar.gz
Merge aelkin@bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/usr_rh9/home/elkin.rh9/MySQL/Merge/5.0-bug19136 sql/sql_select.cc: Auto merged
-rw-r--r--mysql-test/r/rpl_user_variables.result1
-rw-r--r--mysql-test/t/rpl_user_variables.test6
-rw-r--r--sql/item_func.cc10
3 files changed, 17 insertions, 0 deletions
diff --git a/mysql-test/r/rpl_user_variables.result b/mysql-test/r/rpl_user_variables.result
index 4198bbcc154..45618688a33 100644
--- a/mysql-test/r/rpl_user_variables.result
+++ b/mysql-test/r/rpl_user_variables.result
@@ -106,5 +106,6 @@ slave-bin.000001 # User var 2 # @`a`=5
slave-bin.000001 # Query 1 # use `test`; insert into t1 values (@a),(@a)
slave-bin.000001 # User var 2 # @`a`=NULL
slave-bin.000001 # Query 1 # 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;
diff --git a/mysql-test/t/rpl_user_variables.test b/mysql-test/t/rpl_user_variables.test
index e8985397703..dbe75a15038 100644
--- a/mysql-test/t/rpl_user_variables.test
+++ b/mysql-test/t/rpl_user_variables.test
@@ -48,9 +48,15 @@ sync_with_master;
select * from t1;
--replace_column 2 # 5 #
show binlog events from 98;
+#
+# 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;
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 3359c632aff..21aa7ed2a1b 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -3946,14 +3946,24 @@ int get_var_with_binlog(THD *thd, enum_sql_command sql_command,
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;
}