[Commits] 3f702e5: MDEV-7006: post review fixes.

sanja at mariadb.com sanja at mariadb.com
Tue Mar 10 15:17:35 EET 2015


revision-id: 3f702e5915f5be6164f69624a5738972579bbaee
parent(s): 83659a68642da2eb6e9327f17a0ef730f512aa96
committer: Oleksandr Byelkin
branch nick: server
timestamp: 2015-03-10 14:17:32 +0100
message:

MDEV-7006: post review fixes.

---
 sql/sql_lex.cc   | 18 ++++++++++++++----
 sql/sql_lex.h    |  3 ++-
 sql/sql_parse.cc |  7 +++++--
 3 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index ee956ed..1593e2a 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -4224,7 +4224,17 @@ int LEX::print_explain(select_result_sink *output, uint8 explain_flags,
   return res;
 }
 
-void LEX::set_arena_for_set_stmt(Query_arena *backup)
+
+/**
+  Allocates and set arena for SET STATEMENT old values.
+
+  @param backup          where to save backup of arena.
+
+  @retval 1 Error
+  @retval 0 OK
+*/
+
+bool LEX::set_arena_for_set_stmt(Query_arena *backup)
 {
   DBUG_ENTER("LEX::set_arena_for_set_stmt");
   DBUG_ASSERT(arena_for_set_stmt== 0);
@@ -4232,18 +4242,18 @@ void LEX::set_arena_for_set_stmt(Query_arena *backup)
   {
     mem_root_for_set_stmt= new MEM_ROOT();
     if (!(mem_root_for_set_stmt))
-      DBUG_VOID_RETURN;
+      DBUG_RETURN(1);
     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_RETURN(1);
   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;
+  DBUG_RETURN(0);
 }
 
 
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index ed3c4a0..bac9044 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -2437,7 +2437,7 @@ struct LEX: public Query_tables_list
   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);
+  bool set_arena_for_set_stmt(Query_arena *backup);
   void reset_arena_for_set_stmt(Query_arena *backup);
   void free_arena_for_set_stmt();
 
@@ -2691,6 +2691,7 @@ struct LEX: public Query_tables_list
 
   inline void free_set_stmt_mem_root()
   {
+    DBUG_ASSERT(!is_arena_for_set_stmt());
     if (mem_root_for_set_stmt)
     {
       free_root(mem_root_for_set_stmt, MYF(0));
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 49f3ef8..9ec540c 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2642,8 +2642,11 @@ static bool do_execute_sp(THD *thd, sp_head *sp)
     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++))
+
+    if (lex->set_arena_for_set_stmt(&backup))
+      goto error;
+
+    while ((var= it++))
     {
       DBUG_ASSERT(var->is_system());
       set_var *o= NULL, *v= (set_var*)var;


More information about the commits mailing list