From c40d85c634a4946d3501b542148d4353fc04fbb4 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 25 Jun 2009 01:22:20 +0300 Subject: [PATCH] Fix of BUG#45632 (http://bugs.mysql.com/bug.php?id=45632) - sharing non default debug settings between sessions. This bugfix proposed by Monty. mysql-test/r/variables_debug.result: Test that sessions do not share the same session debug variable. mysql-test/t/variables_debug.test: Test that sessions do not share the same session debug variable. sql/set_var.cc: As soon as default setting are shared between sessions we should push dbug state before changing debug setting first time. --- mysql-test/r/variables_debug.result | 15 +++++++++++++++ mysql-test/t/variables_debug.test | 28 ++++++++++++++++++++++++++++ sql/set_var.cc | 25 +++++++++++++++++++++---- 3 files changed, 64 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/variables_debug.result b/mysql-test/r/variables_debug.result index 9cd133dddb1..3e2764ef06e 100644 --- a/mysql-test/r/variables_debug.result +++ b/mysql-test/r/variables_debug.result @@ -10,3 +10,18 @@ set debug= '-P'; select @@debug; @@debug T +set session debug="t"; +show session variables like 'debug'; +Variable_name Value +debug t +set session debug="t"; +show session variables like 'debug'; +Variable_name Value +debug t +set session debug="d:t"; +show session variables like 'debug'; +Variable_name Value +debug d:t +show session variables like 'debug'; +Variable_name Value +debug t diff --git a/mysql-test/t/variables_debug.test b/mysql-test/t/variables_debug.test index 7dcaf246803..8ba79f3fc54 100644 --- a/mysql-test/t/variables_debug.test +++ b/mysql-test/t/variables_debug.test @@ -10,3 +10,31 @@ set debug= '+P'; select @@debug; set debug= '-P'; select @@debug; + +# +# Checks that assigning variable 'debug' in one session has no influence on +# other session. (BUG#45632 of bugs.mysql.com) +# +connect(con1,localhost,root,,test,,); +connect(con2,localhost,root,,test,,); + +# makes output independant of current debug status +connection con1; +set session debug="t"; +show session variables like 'debug'; +connection con2; +set session debug="t"; +show session variables like 'debug'; + +# checks influence one session debug variable on another +connection con1; +set session debug="d:t"; +show session variables like 'debug'; +connection con2; +show session variables like 'debug'; + +disconnect con1; +disconnect con2; + +connection default; + diff --git a/sql/set_var.cc b/sql/set_var.cc index a3ea5fa8029..395725a3afc 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -4231,11 +4231,28 @@ bool sys_var_thd_dbug::check(THD *thd, set_var *var) bool sys_var_thd_dbug::update(THD *thd, set_var *var) { - if (var->type == OPT_GLOBAL) - DBUG_SET_INITIAL(var ? var->value->str_value.c_ptr() : ""); - else - DBUG_SET(var ? var->value->str_value.c_ptr() : ""); +#ifndef DBUG_OFF + const char *command= var ? var->value->str_value.c_ptr() : ""; + if (var->type == OPT_GLOBAL) + DBUG_SET_INITIAL(command); + else + { + if (_db_is_pushed_()) + { + /* We have already a local state done with DBUG_PUSH; Modify the state */ + DBUG_SET(command); + } + else + { + /* + We are sharing the state with the global state; + Create a local state for this thread. + */ + DBUG_PUSH(command); + } + } +#endif return 0; }