[Commits] 83659a6: MDEV-7006 MDEV-7007: SET STATEMENT and slow log

sanja at mariadb.com sanja at mariadb.com
Tue Feb 17 13:54:56 EET 2015


revision-id: 83659a68642da2eb6e9327f17a0ef730f512aa96
parent(s): 3e2849d2a01b06a61407b00989c3f981e62dd183
committer: Oleksandr Byelkin
branch nick: server
timestamp: 2015-02-17 12:54:51 +0100
message:

MDEV-7006 MDEV-7007: SET STATEMENT and slow log
fixed embedded server tests
MDEV-7009: SET STATEMENT min_examined_row_limit has no effect
MDEV-6948:SET STATEMENT gtid_domain_id = ... FOR has no effect (same for gtid_seq_no and server_id)

old values of SET STATENENT variables now saved in its own Query_arena and restored later

---
 mysql-test/r/set_statement.result                  | 98 ++++++++++++++++++----
 .../r/set_statement_notembedded_binlog.result      | 19 +++++
 mysql-test/t/set_statement.test                    | 69 +++++++++++----
 mysql-test/t/set_statement_notembedded_binlog.test | 22 +++++
 sql/log_event.cc                                   |  1 +
 sql/sp_head.cc                                     |  1 +
 sql/sql_class.cc                                   |  2 +-
 sql/sql_class.h                                    |  1 +
 sql/sql_cursor.cc                                  |  1 +
 sql/sql_lex.cc                                     | 55 +++++++++++-
 sql/sql_lex.h                                      | 23 +++++
 sql/sql_parse.cc                                   | 13 ++-
 sql/sql_prepare.cc                                 |  4 +-
 sql/sys_vars.cc                                    | 14 ++--
 14 files changed, 284 insertions(+), 39 deletions(-)

diff --git a/mysql-test/r/set_statement.result b/mysql-test/r/set_statement.result
index 51687ca..89840ce 100644
--- a/mysql-test/r/set_statement.result
+++ b/mysql-test/r/set_statement.result
@@ -1034,10 +1034,92 @@ set statement lock_wait_timeout=1 for select @@lock_wait_timeout;
 @@lock_wait_timeout
 1
 set global general_log=@save_general_log;
+# MDEV-7006 MDEV-7007: SET statement and slow log
+set @save_long_query_time= @@long_query_time;
+set @save_slow_query_log= @@slow_query_log;
+set @save_log_output= @@log_output;
+set statement long_query_time=default for select @@long_query_time;
+@@long_query_time
+10.000000
+set statement log_slow_filter=default for select @@log_slow_filter;
+@@log_slow_filter
+admin,filesort,filesort_on_disk,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk
+set statement log_slow_verbosity=default for select @@log_slow_verbosity;
+@@log_slow_verbosity
+
+set statement log_slow_rate_limit=default for select @@log_slow_rate_limit;
+@@log_slow_rate_limit
+1
+set statement slow_query_log=default for select @@slow_query_log;
+@@slow_query_log
+1
+truncate table mysql.slow_log;
+set slow_query_log= 1;
+set global log_output='TABLE';
+select sql_text from mysql.slow_log;
+sql_text
+set @@long_query_time=0.01;
+#should be written
+select sleep(0.1);
+sleep(0.1)
+0
+set @@long_query_time=@save_long_query_time;
+select sql_text from mysql.slow_log;
+sql_text
+select sleep(0.1)
+#---
+#should be written
+set statement long_query_time=0.01 for select sleep(0.1);
+sleep(0.1)
+0
+select sql_text from mysql.slow_log;
+sql_text
+select sleep(0.1)
+set statement long_query_time=0.01 for select sleep(0.1)
+#---
+set @@long_query_time=0.01;
+#should NOT be written
+set statement slow_query_log=0 for select sleep(0.1);
+sleep(0.1)
+0
+set @@long_query_time=@save_long_query_time;
+select sql_text from mysql.slow_log;
+sql_text
+select sleep(0.1)
+set statement long_query_time=0.01 for select sleep(0.1)
+#---
+#should NOT be written
+set statement long_query_time=0.01,log_slow_filter='full_scan' for select sleep(0.1);
+sleep(0.1)
+0
+select sql_text from mysql.slow_log;
+sql_text
+select sleep(0.1)
+set statement long_query_time=0.01 for select sleep(0.1)
+#---
+#should NOT be written
+set statement long_query_time=0.01,log_slow_rate_limit=9999 for select sleep(0.1);
+sleep(0.1)
+0
+select sql_text from mysql.slow_log;
+sql_text
+select sleep(0.1)
+set statement long_query_time=0.01 for select sleep(0.1)
+#---
+#should NOT be written
+set statement long_query_time=0.01,min_examined_row_limit=50 for select sleep(0.1);
+sleep(0.1)
+0
+select sql_text from mysql.slow_log;
+sql_text
+select sleep(0.1)
+set statement long_query_time=0.01 for select sleep(0.1)
+#---
+set global log_output= @save_log_output;
+set @@slow_query_log= @save_slow_query_log;
+set @@long_query_time= @save_long_query_time;
 set statement autocommit=default for select 1;
 ERROR 42000: The system variable autocommit cannot be set in SET STATEMENT.
-set statement gtid_domain_id=default for select 1;
-ERROR 42000: The system variable gtid_domain_id cannot be set in SET STATEMENT.
 set statement tx_isolation=default for select 1;
 ERROR 42000: The system variable tx_isolation cannot be set in SET STATEMENT.
 set statement rand_seed1=default for select 1;
@@ -1050,18 +1132,6 @@ set statement last_insert_id=1 for select 1;
 ERROR 42000: The system variable last_insert_id cannot be set in SET STATEMENT.
 set statement sql_log_off=default for select 1;
 ERROR 42000: The system variable sql_log_off cannot be set in SET STATEMENT.
-set statement long_query_time=default for select 1;
-ERROR 42000: The system variable long_query_time cannot be set in SET STATEMENT.
-set statement log_slow_filter=default for select 1;
-ERROR 42000: The system variable log_slow_filter cannot be set in SET STATEMENT.
-set statement log_slow_verbosity=default for select 1;
-ERROR 42000: The system variable log_slow_verbosity cannot be set in SET STATEMENT.
-set statement log_slow_rate_limit=default for select 1;
-ERROR 42000: The system variable log_slow_rate_limit cannot be set in SET STATEMENT.
-set statement slow_query_log=default for select 1;
-ERROR 42000: The system variable slow_query_log cannot be set in SET STATEMENT.
-set statement min_examined_row_limit=default for select 1;
-ERROR 42000: The system variable min_examined_row_limit cannot be set in SET STATEMENT.
 set statement character_set_client=default for select 1;
 ERROR 42000: The system variable character_set_client cannot be set in SET STATEMENT.
 set statement character_set_connection=default for select 1;
diff --git a/mysql-test/r/set_statement_notembedded_binlog.result b/mysql-test/r/set_statement_notembedded_binlog.result
new file mode 100644
index 0000000..9d201b7
--- /dev/null
+++ b/mysql-test/r/set_statement_notembedded_binlog.result
@@ -0,0 +1,19 @@
+drop table if exists t1;
+drop view if exists t1;
+#
+# MDEV-6948: SET STATEMENT gtid_domain_id = ... FOR has no effect
+# (same for gtid_seq_no and server_id)
+#
+reset master;
+create table t1 (i int);
+set gtid_domain_id = 10;
+insert into t1 values (1),(2);
+set statement gtid_domain_id = 20 for insert into t1 values (3),(4);
+show binlog events limit 5,5;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+x	x	x	x	x	BEGIN GTID 10-1-1
+x	x	x	x	x	use `test`; insert into t1 values (1),(2)
+x	x	x	x	x	COMMIT
+x	x	x	x	x	BEGIN GTID 20-1-1
+x	x	x	x	x	use `test`; set statement gtid_domain_id = 20 for insert into t1 values (3),(4)
+drop table t1;
diff --git a/mysql-test/t/set_statement.test b/mysql-test/t/set_statement.test
index 6421317..d34e31c 100644
--- a/mysql-test/t/set_statement.test
+++ b/mysql-test/t/set_statement.test
@@ -987,14 +987,67 @@ set global general_log=0;
 set statement lock_wait_timeout=1 for select @@lock_wait_timeout;
 set global general_log=@save_general_log;
 
+--echo # MDEV-7006 MDEV-7007: SET statement and slow log
+
+set @save_long_query_time= @@long_query_time;
+set @save_slow_query_log= @@slow_query_log;
+set @save_log_output= @@log_output;
+
+set statement long_query_time=default for select @@long_query_time;
+set statement log_slow_filter=default for select @@log_slow_filter;
+set statement log_slow_verbosity=default for select @@log_slow_verbosity;
+set statement log_slow_rate_limit=default for select @@log_slow_rate_limit;
+set statement slow_query_log=default for select @@slow_query_log;
+
+truncate table mysql.slow_log;
+set slow_query_log= 1;
+set global log_output='TABLE';
+
+select sql_text from mysql.slow_log;
+set @@long_query_time=0.01;
+--echo #should be written
+select sleep(0.1);
+set @@long_query_time=@save_long_query_time;
+select sql_text from mysql.slow_log;
+--echo #---
+--echo #should be written
+set statement long_query_time=0.01 for select sleep(0.1);
+select sql_text from mysql.slow_log;
+--echo #---
+set @@long_query_time=0.01;
+--echo #should NOT be written
+set statement slow_query_log=0 for select sleep(0.1);
+set @@long_query_time=@save_long_query_time;
+select sql_text from mysql.slow_log;
+--echo #---
+--echo #should NOT be written
+set statement long_query_time=0.01,log_slow_filter='full_scan' for select sleep(0.1);
+select sql_text from mysql.slow_log;
+--echo #---
+--echo #should NOT be written
+set statement long_query_time=0.01,log_slow_rate_limit=9999 for select sleep(0.1);
+select sql_text from mysql.slow_log;
+--echo #---
+--echo #should NOT be written
+set statement long_query_time=0.01,min_examined_row_limit=50 for select sleep(0.1);
+select sql_text from mysql.slow_log;
+--echo #---
+#
+# log_slow_verbosity is impossible to check because results are not written
+# in TABLE mode
+#
+
+set global log_output= @save_log_output;
+set @@slow_query_log= @save_slow_query_log;
+set @@long_query_time= @save_long_query_time;
+
+
 #
 # Prohibited Variables
 #
 --error ER_SET_STATEMENT_NOT_SUPPORTED
 set statement autocommit=default for select 1;
 --error ER_SET_STATEMENT_NOT_SUPPORTED
-set statement gtid_domain_id=default for select 1;
---error ER_SET_STATEMENT_NOT_SUPPORTED
 set statement tx_isolation=default for select 1;
 --error ER_SET_STATEMENT_NOT_SUPPORTED
 set statement rand_seed1=default for select 1;
@@ -1007,18 +1060,6 @@ set statement last_insert_id=1 for select 1;
 --error ER_SET_STATEMENT_NOT_SUPPORTED
 set statement sql_log_off=default for select 1;
 --error ER_SET_STATEMENT_NOT_SUPPORTED
-set statement long_query_time=default for select 1;
---error ER_SET_STATEMENT_NOT_SUPPORTED
-set statement log_slow_filter=default for select 1;
---error ER_SET_STATEMENT_NOT_SUPPORTED
-set statement log_slow_verbosity=default for select 1;
---error ER_SET_STATEMENT_NOT_SUPPORTED
-set statement log_slow_rate_limit=default for select 1;
---error ER_SET_STATEMENT_NOT_SUPPORTED
-set statement slow_query_log=default for select 1;
---error ER_SET_STATEMENT_NOT_SUPPORTED
-set statement min_examined_row_limit=default for select 1;
---error ER_SET_STATEMENT_NOT_SUPPORTED
 set statement character_set_client=default for select 1;
 --error ER_SET_STATEMENT_NOT_SUPPORTED
 set statement character_set_connection=default for select 1;
diff --git a/mysql-test/t/set_statement_notembedded_binlog.test b/mysql-test/t/set_statement_notembedded_binlog.test
new file mode 100644
index 0000000..c9c2334
--- /dev/null
+++ b/mysql-test/t/set_statement_notembedded_binlog.test
@@ -0,0 +1,22 @@
+--source include/have_log_bin.inc
+--source include/not_embedded.inc
+
+--disable_warnings
+drop table if exists t1;
+drop view if exists t1;
+--enable_warnings
+
+--echo #
+--echo # MDEV-6948: SET STATEMENT gtid_domain_id = ... FOR has no effect
+--echo # (same for gtid_seq_no and server_id)
+--echo #
+reset master;
+create table t1 (i int);
+set gtid_domain_id = 10;
+insert into t1 values (1),(2);
+set statement gtid_domain_id = 20 for insert into t1 values (3),(4);
+
+--replace_column 1 x 2 x 3 x 4 x 5 x
+show binlog events limit 5,5;
+
+drop table t1;
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 4a7b1e2..622dc6e 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -4280,6 +4280,7 @@ int Query_log_event::do_apply_event(rpl_group_info *rgi,
         /* Finalize server status flags after executing a statement. */
         thd->update_server_status();
         log_slow_statement(thd);
+        thd->lex->restore_set_statement_var();
       }
 
       thd->variables.option_bits&= ~OPTION_MASTER_SQL_ERROR;
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index c0b1b99..e564627 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -2975,6 +2975,7 @@ void sp_head::add_mark_lead(uint ip, List<sp_instr> *leads)
 
     cleanup_items() is called in sp_head::execute()
   */
+  thd->lex->restore_set_statement_var();
   DBUG_RETURN(res || thd->is_error());
 }
 
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 9c45755..764860a 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -1699,7 +1699,7 @@ void THD::cleanup(void)
   if (rgi_slave)
     rgi_slave->cleanup_after_session();
 #endif
-
+  main_lex.free_set_stmt_mem_root();
   free_root(&main_mem_root, MYF(0));
   main_da.free_memory();
   if (tdc_hash_pins)
diff --git a/sql/sql_class.h b/sql/sql_class.h
index bd145bd..e784300 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -3674,6 +3674,7 @@ class THD :public Statement,
     return backup;
   }
 
+
   void clear_wakeup_ready() { wakeup_ready= false; }
   /*
     Sleep waiting for others to wake us up with signal_wakeup_ready().
diff --git a/sql/sql_cursor.cc b/sql/sql_cursor.cc
index 99b7b1e..a7dcc77 100644
--- a/sql/sql_cursor.cc
+++ b/sql/sql_cursor.cc
@@ -122,6 +122,7 @@ int mysql_open_cursor(THD *thd, select_result *result,
   /* Mark that we can't use query cache with cursors */
   thd->query_cache_is_applicable= 0;
   rc= mysql_execute_command(thd);
+  thd->lex->restore_set_statement_var();
   thd->m_statement_psi= parent_locker;
   MYSQL_QUERY_EXEC_DONE(rc);
 
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 0c1c3b3..ee956ed 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -2628,7 +2628,8 @@ void Query_tables_list::destroy_query_tables_list()
 
 LEX::LEX()
   : explain(NULL),
-    result(0), option_type(OPT_DEFAULT), sphead(0),
+    result(0), arena_for_set_stmt(0), mem_root_for_set_stmt(0),
+    option_type(OPT_DEFAULT), sphead(0),
     is_lex_started(0), limit_rows_examined_cnt(ULONGLONG_MAX)
 {
 
@@ -4223,6 +4224,56 @@ int LEX::print_explain(select_result_sink *output, uint8 explain_flags,
   return res;
 }
 
+void LEX::set_arena_for_set_stmt(Query_arena *backup)
+{
+  DBUG_ENTER("LEX::set_arena_for_set_stmt");
+  DBUG_ASSERT(arena_for_set_stmt== 0);
+  if (!mem_root_for_set_stmt)
+  {
+    mem_root_for_set_stmt= new MEM_ROOT();
+    if (!(mem_root_for_set_stmt))
+      DBUG_VOID_RETURN;
+    init_sql_alloc(mem_root_for_set_stmt, ALLOC_ROOT_SET, ALLOC_ROOT_SET,
+                   MYF(MY_THREAD_SPECIFIC));
+  }
+  if (!(arena_for_set_stmt= new Query_arena(mem_root_for_set_stmt,
+                                            Query_arena::STMT_INITIALIZED)))
+    DBUG_VOID_RETURN;
+  DBUG_PRINT("info", ("mem_root: 0x%lx  arena: 0x%lx",
+                      (ulong) mem_root_for_set_stmt,
+                      (ulong) arena_for_set_stmt));
+  thd->set_n_backup_active_arena(arena_for_set_stmt, backup);
+  DBUG_VOID_RETURN;
+}
+
+
+void LEX::reset_arena_for_set_stmt(Query_arena *backup)
+{
+  DBUG_ENTER("LEX::reset_arena_for_set_stmt");
+  DBUG_ASSERT(arena_for_set_stmt);
+  thd->restore_active_arena(arena_for_set_stmt, backup);
+  DBUG_PRINT("info", ("mem_root: 0x%lx  arena: 0x%lx",
+                      (ulong) arena_for_set_stmt->mem_root,
+                      (ulong) arena_for_set_stmt));
+  DBUG_VOID_RETURN;
+}
+
+
+void LEX::free_arena_for_set_stmt()
+{
+  DBUG_ENTER("LEX::free_arena_for_set_stmt");
+  if (!arena_for_set_stmt)
+    return;
+  DBUG_PRINT("info", ("mem_root: 0x%lx  arena: 0x%lx",
+                      (ulong) arena_for_set_stmt->mem_root,
+                      (ulong) arena_for_set_stmt));
+  arena_for_set_stmt->free_items();
+  delete(arena_for_set_stmt);
+  free_root(mem_root_for_set_stmt, MYF(MY_KEEP_PREALLOC));
+  arena_for_set_stmt= 0;
+  DBUG_VOID_RETURN;
+}
+
 void LEX::restore_set_statement_var()
 {
   DBUG_ENTER("LEX::restore_set_statement_var");
@@ -4231,7 +4282,9 @@ void LEX::restore_set_statement_var()
     DBUG_PRINT("info", ("vars: %d", old_var_list.elements));
     sql_set_variables(thd, &old_var_list, false);
     old_var_list.empty();
+    free_arena_for_set_stmt();
   }
+  DBUG_ASSERT(!is_arena_for_set_stmt());
   DBUG_VOID_RETURN;
 }
 
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 46d667c..ed3c4a0 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -48,6 +48,8 @@
 class File_parser;
 class Key_part_spec;
 
+#define ALLOC_ROOT_SET 1024
+
 #ifdef MYSQL_SERVER
 /*
   There are 8 different type of table access so there is no more than
@@ -2430,6 +2432,15 @@ struct LEX: public Query_tables_list
   List<set_var_base>  var_list;
   List<set_var_base>  stmt_var_list; //SET_STATEMENT values
   List<set_var_base>  old_var_list; // SET STATEMENT old values
+private:
+  Query_arena *arena_for_set_stmt;
+  MEM_ROOT *mem_root_for_set_stmt;
+public:
+  inline bool is_arena_for_set_stmt() {return arena_for_set_stmt != 0;}
+  void set_arena_for_set_stmt(Query_arena *backup);
+  void reset_arena_for_set_stmt(Query_arena *backup);
+  void free_arena_for_set_stmt();
+
   List<Item_func_set_user_var> set_var_list; // in-query assignment list
   List<Item_param>    param_list;
   List<LEX_STRING>    view_list; // view list (list of field names in view)
@@ -2677,10 +2688,22 @@ struct LEX: public Query_tables_list
       limit_rows_examined_cnt= ULONGLONG_MAX;
   }
 
+
+  inline void free_set_stmt_mem_root()
+  {
+    if (mem_root_for_set_stmt)
+    {
+      free_root(mem_root_for_set_stmt, MYF(0));
+      delete mem_root_for_set_stmt;
+      mem_root_for_set_stmt= 0;
+    }
+  }
+
   LEX();
 
   virtual ~LEX()
   {
+    free_set_stmt_mem_root();
     destroy_query_tables_list();
     plugin_unlock_list(NULL, (plugin_ref *)plugins.buffer, plugins.elements);
     delete_dynamic(&plugins);
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 64e016f..49f3ef8 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -799,6 +799,7 @@ static void handle_bootstrap_impl(THD *thd)
 
     free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC));
     free_root(&thd->transaction.mem_root,MYF(MY_KEEP_PREALLOC));
+    thd->lex->restore_set_statement_var();
   }
 
   DBUG_VOID_RETURN;
@@ -1120,6 +1121,7 @@ bool do_command(THD *thd)
   DBUG_ASSERT(!thd->apc_target.is_enabled());
 
 out:
+  thd->lex->restore_set_statement_var();
   /* The statement instrumentation must be closed in all cases. */
   DBUG_ASSERT(thd->m_statement_psi == NULL);
   DBUG_RETURN(return_value);
@@ -1950,6 +1952,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
 
   /* Check that some variables are reset properly */
   DBUG_ASSERT(thd->abort_on_warning == 0);
+  thd->lex->restore_set_statement_var();
   DBUG_RETURN(error);
 }
 
@@ -2633,11 +2636,13 @@ static bool do_execute_sp(THD *thd, sp_head *sp)
 
   if (!lex->stmt_var_list.is_empty() && !thd->slave_thread)
   {
+    Query_arena backup;
     DBUG_PRINT("info", ("SET STATEMENT %d vars", lex->stmt_var_list.elements));
 
     lex->old_var_list.empty();
     List_iterator_fast<set_var_base> it(lex->stmt_var_list);
     set_var_base *var;
+    lex->set_arena_for_set_stmt(&backup);
     while ((var=it++))
     {
       DBUG_ASSERT(var->is_system());
@@ -2645,6 +2650,9 @@ static bool do_execute_sp(THD *thd, sp_head *sp)
       if (!v->var->is_set_stmt_ok())
       {
         my_error(ER_SET_STATEMENT_NOT_SUPPORTED, MYF(0), v->var->name.str);
+        lex->reset_arena_for_set_stmt(&backup);
+        lex->old_var_list.empty();
+        lex->free_arena_for_set_stmt();
         goto error;
       }
       if (v->var->is_default())
@@ -2717,11 +2725,15 @@ static bool do_execute_sp(THD *thd, sp_head *sp)
       DBUG_ASSERT(o);
       lex->old_var_list.push_back(o);
     }
+    lex->reset_arena_for_set_stmt(&backup);
+    if (lex->old_var_list.is_empty())
+      lex->free_arena_for_set_stmt();
     if (thd->is_error() ||
         (res= sql_set_variables(thd, &lex->stmt_var_list, false)))
     {
       if (!thd->is_error())
         my_error(ER_WRONG_ARGUMENTS, MYF(0), "SET");
+      lex->restore_set_statement_var();
       goto error;
     }
   }
@@ -5546,7 +5558,6 @@ static bool do_execute_sp(THD *thd, sp_head *sp)
                thd->in_multi_stmt_transaction_mode());
 
 
-  lex->restore_set_statement_var();
   lex->unit.cleanup();
 
   if (! thd->in_sub_stmt)
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 7b157f9..9c2aaa3 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -2775,7 +2775,7 @@ void mysql_sql_stmt_execute(THD *thd)
   DBUG_PRINT("info",("stmt: 0x%lx", (long) stmt));
 
   (void) stmt->execute_loop(&expanded_query, FALSE, NULL, NULL);
-
+  stmt->lex->restore_set_statement_var();
   DBUG_VOID_RETURN;
 }
 
@@ -3165,6 +3165,7 @@ bool Select_fetch_protocol_binary::send_eof()
                       thd->query(), thd->query_length());
 
 end:
+  thd->lex->restore_set_statement_var();
   lex_end(thd->lex);
 
   return error;
@@ -4085,6 +4086,7 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor)
     general_log_write(thd, COM_STMT_EXECUTE, thd->query(), thd->query_length());
 
 error:
+  thd->lex->restore_set_statement_var();
   flags&= ~ (uint) IS_IN_USE;
   return error;
 }
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 0dea5a1..9c861b7 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -1195,7 +1195,7 @@ static Sys_var_double Sys_long_query_time(
        "Log all queries that have taken more than long_query_time seconds "
        "to execute to file. The argument will be treated as a decimal value "
        "with microsecond precision",
-       NO_SET_STMT SESSION_VAR(long_query_time_double),
+       SESSION_VAR(long_query_time_double),
        CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, LONG_TIMEOUT), DEFAULT(10),
        NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0),
        ON_UPDATE(update_cached_long_query_time));
@@ -1450,7 +1450,7 @@ static Sys_var_uint Sys_gtid_domain_id(
        "parallel paths (for example multiple masters), each independent "
        "source server must use a distinct domain_id. For simple tree-shaped "
        "replication topologies, it can be left at its default, 0.",
-       NO_SET_STMT SESSION_VAR(gtid_domain_id),
+       SESSION_VAR(gtid_domain_id),
        CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, UINT_MAX32), DEFAULT(0),
        BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG,
        ON_CHECK(check_gtid_domain_id));
@@ -2163,7 +2163,7 @@ static Sys_var_ulong Sys_min_examined_row_limit(
        "min_examined_row_limit",
        "Don't write queries to slow log that examine fewer rows "
        "than that",
-       NO_SET_STMT SESSION_VAR(min_examined_row_limit), CMD_LINE(REQUIRED_ARG),
+       SESSION_VAR(min_examined_row_limit), CMD_LINE(REQUIRED_ARG),
        VALID_RANGE(0, UINT_MAX), DEFAULT(0), BLOCK_SIZE(1));
 
 #ifdef _WIN32
@@ -4102,7 +4102,7 @@ static Sys_var_mybool Sys_slow_query_log(
        "Log slow queries to a table or log file. Defaults logging to a file "
        "'hostname'-slow.log or a table mysql.slow_log if --log-output=TABLE is "
        "used. Must be enabled to activate other slow log options",
-       NO_SET_STMT SESSION_VAR(sql_log_slow), CMD_LINE(OPT_ARG),
+       SESSION_VAR(sql_log_slow), CMD_LINE(OPT_ARG),
        DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG,
        ON_CHECK(0), ON_UPDATE(fix_log_state));
 
@@ -4970,7 +4970,7 @@ static Sys_var_keycache Sys_key_cache_segments(
 static Sys_var_set Sys_log_slow_filter(
        "log_slow_filter",
        "Log only certain types of queries",
-       NO_SET_STMT SESSION_VAR(log_slow_filter), CMD_LINE(REQUIRED_ARG),
+       SESSION_VAR(log_slow_filter), CMD_LINE(REQUIRED_ARG),
        log_slow_filter_names,
        DEFAULT(MAX_SET(array_elements(log_slow_filter_names)-1)));
 
@@ -5017,7 +5017,7 @@ static Sys_var_ulong Sys_log_slow_rate_limit(
        "Write to slow log every #th slow query. Set to 1 to log everything. "
        "Increase it to reduce the size of the slow or the performance impact "
        "of slow logging",
-       NO_SET_STMT SESSION_VAR(log_slow_rate_limit), CMD_LINE(REQUIRED_ARG),
+       SESSION_VAR(log_slow_rate_limit), CMD_LINE(REQUIRED_ARG),
        VALID_RANGE(1, UINT_MAX), DEFAULT(1), BLOCK_SIZE(1));
 
 static const char *log_slow_verbosity_names[]= { "innodb", "query_plan", 
@@ -5025,7 +5025,7 @@ static Sys_var_ulong Sys_log_slow_rate_limit(
 static Sys_var_set Sys_log_slow_verbosity(
        "log_slow_verbosity",
        "Verbosity level for the slow log",
-       NO_SET_STMT SESSION_VAR(log_slow_verbosity), CMD_LINE(REQUIRED_ARG),
+       SESSION_VAR(log_slow_verbosity), CMD_LINE(REQUIRED_ARG),
        log_slow_verbosity_names, DEFAULT(LOG_SLOW_VERBOSITY_INIT));
 
 static Sys_var_ulong Sys_join_cache_level(


More information about the commits mailing list