[Commits] cbfded1: c

sanja at mariadb.com sanja at mariadb.com
Mon Mar 16 11:31:40 EET 2015


revision-id: cbfded120ed1310b5225fda0c95faabd0a8ed2bc
parent(s): 8adaba89d4540e312da038bfaea7d818c5d4e777
committer: Oleksandr Byelkin
branch nick: server
timestamp: 2015-03-16 10:31:37 +0100
message:

c

---
 sql/sql_lex.cc   |  6 ++++++
 sql/sql_lex.h    |  1 +
 sql/sql_parse.cc | 22 +++++++++++++++++-----
 sql/sql_parse.h  |  2 +-
 sql/sql_yacc.yy  |  2 +-
 5 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index f603534..c3e74f6 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -4225,6 +4225,12 @@ int LEX::print_explain(select_result_sink *output, uint8 explain_flags,
 }
 
 
+void LEX::switch_arena_for_set_stmt(Query_arena *backup)
+{
+  thd->set_n_backup_active_arena(arena_for_set_stmt, backup);
+}
+
+
 /**
   Allocates and set arena for SET STATEMENT old values.
 
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 6eb5bae..46e471f 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -2439,6 +2439,7 @@ struct LEX: public Query_tables_list
 public:
   inline bool is_arena_for_set_stmt() {return arena_for_set_stmt != 0;}
   bool set_arena_for_set_stmt(Query_arena *backup);
+  void switch_arena_for_set_stmt(Query_arena *backup);
   void reset_arena_for_set_stmt(Query_arena *backup);
   void free_arena_for_set_stmt();
 
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 6d29235..1e6fde1 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2383,13 +2383,13 @@ static bool do_execute_sp(THD *thd, sp_head *sp)
   return 0;
 }
 
-bool maria_set_statement_variables(THD *thd)
+bool maria_set_statement_variables(THD *thd, bool add_more)
 {
   LEX *lex= thd->lex;
   DBUG_ENTER("maria_set_statement_variables");
 
   if (!lex->stmt_var_list.is_empty() && !thd->slave_thread
-      && lex->old_var_list.is_empty())
+      && (lex->old_var_list.is_empty() || add_more))
   {
     Query_arena backup;
     DBUG_PRINT("info", ("SET STATEMENT %d vars", lex->stmt_var_list.elements));
@@ -2397,8 +2397,20 @@ bool maria_set_statement_variables(THD *thd)
     List_iterator_fast<set_var_base> it(lex->stmt_var_list);
     set_var_base *var;
 
-    if (lex->set_arena_for_set_stmt(&backup))
-      DBUG_RETURN(TRUE);
+    if (lex->is_arena_for_set_stmt())
+    {
+      DBUG_ASSERT(add_more);
+      DBUG_ASSERT(lex->old_var_list.elements);
+      List_iterator_fast<set_var_base> oit(lex->old_var_list);
+      while(oit++)
+        it++;
+      lex->switch_arena_for_set_stmt(&backup);
+    }
+    else
+    {
+      if (lex->set_arena_for_set_stmt(&backup))
+        DBUG_RETURN(TRUE);
+    }
 
     while ((var= it++))
     {
@@ -2763,7 +2775,7 @@ bool maria_set_statement_variables(THD *thd)
   thd->get_binlog_format(&orig_binlog_format,
                          &orig_current_stmt_binlog_format);
 
-  if (maria_set_statement_variables(thd))
+  if (maria_set_statement_variables(thd, FALSE))
     goto error;
 
   if (thd->lex->mi.connection_name.str == NULL)
diff --git a/sql/sql_parse.h b/sql/sql_parse.h
index da5d796..a4e2706 100644
--- a/sql/sql_parse.h
+++ b/sql/sql_parse.h
@@ -178,6 +178,6 @@ inline bool check_some_routine_access(THD *thd, const char *db,
                    bool no_errors)
 { return false; }
 #endif /*NO_EMBEDDED_ACCESS_CHECKS*/
-bool maria_set_statement_variables(THD *thd);
+bool maria_set_statement_variables(THD *thd, bool add_more);
 
 #endif /* SQL_PARSE_INCLUDED */
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 55cea59..2a48285 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -14540,7 +14540,7 @@ set:
           FOR_SYM
           {
             if (thd->is_main_statement() &&
-                maria_set_statement_variables(thd))
+                maria_set_statement_variables(thd, TRUE))
             {
               MYSQL_YYABORT;
             }


More information about the commits mailing list