List:Commits« Previous MessageNext Message »
From:Alexander Nozdrin Date:May 19 2011 10:12am
Subject:bzr commit into mysql-5.5 branch (alexander.nozdrin:3389) Bug#11763162
View as plain text  
#At file:///home/alik/MySQL/bzr/00/bug55843/2011.05.19/mysql-5.5/ based on revid:alexander.nozdrin@stripped

 3389 Alexander Nozdrin	2011-05-19
      Pre-requisite patch for Bug#11763162 (55843 - Handled condition
      appears as not handled).
      
      The patch changes the relationship between THD, Diagnostics_area
      and Warning_info classes:
      
        - before the patch, THD owned both Diagnostics_area and
          Warning_info instances.
      
        - after the patch THD owns Diagnostics_area instance,
          and Diagnostics_area owns Warning_info instance.
      
      The patch changes THD::get_warning_info() so that it still
      works (to save code changes) and eliminates THD::set_warning_info().
      Users should use Diagnostics_area::set_warning_info() instead.

    modified:
      sql/sp_head.cc
      sql/sql_admin.cc
      sql/sql_class.cc
      sql/sql_class.h
      sql/sql_error.h
      sql/sql_prepare.cc
      sql/sql_prepare.h
      sql/sql_show.cc
=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc	2011-05-19 10:10:49 +0000
+++ b/sql/sp_head.cc	2011-05-19 10:12:31 +0000
@@ -1291,7 +1291,7 @@ sp_head::execute(THD *thd, bool merge_da
   /* Push a new warning information area. */
   warning_info.append_warning_info(thd, thd->get_warning_info());
   saved_warning_info= thd->get_warning_info();
-  thd->set_warning_info(&warning_info);
+  thd->get_stmt_da()->set_warning_info(&warning_info);
 
   /*
     Switch query context. This has to be done early as this is sometimes
@@ -1500,7 +1500,7 @@ sp_head::execute(THD *thd, bool merge_da
   */
   if (err_status || merge_da_on_success)
     saved_warning_info->merge_with_routine_info(thd, thd->get_warning_info());
-  thd->set_warning_info(saved_warning_info);
+  thd->get_stmt_da()->set_warning_info(saved_warning_info);
 
  done:
   DBUG_PRINT("info", ("err_status: %d  killed: %d  is_slave_error: %d  report_error: %d",

=== modified file 'sql/sql_admin.cc'
--- a/sql/sql_admin.cc	2011-05-19 10:10:49 +0000
+++ b/sql/sql_admin.cc	2011-05-19 10:12:31 +0000
@@ -346,14 +346,15 @@ static bool mysql_admin_table(THD* thd,
           because it's already known that the table is badly damaged.
         */
 
+        Diagnostics_area *da= thd->get_stmt_da();
         Warning_info wi(thd->query_id, false);
         Warning_info *wi_saved= thd->get_warning_info();
 
-        thd->set_warning_info(&wi);
+        da->set_warning_info(&wi);
 
         open_error= open_and_lock_tables(thd, table, TRUE, 0);
 
-        thd->set_warning_info(wi_saved);
+        da->set_warning_info(wi_saved);
       }
       else
       {

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2011-05-19 10:10:49 +0000
+++ b/sql/sql_class.cc	2011-05-19 10:12:31 +0000
@@ -520,7 +520,7 @@ THD::THD()
    debug_sync_control(0),
 #endif /* defined(ENABLED_DEBUG_SYNC) */
    main_warning_info(0, false),
-   m_warning_info(&main_warning_info),
+   main_da(&main_warning_info),
    m_stmt_da(&main_da)
 {
   ulong tmp;
@@ -783,7 +783,7 @@ MYSQL_ERROR* THD::raise_condition(uint s
       (level == MYSQL_ERROR::WARN_LEVEL_NOTE))
     DBUG_RETURN(NULL);
 
-  m_warning_info->opt_clear_warning_info(query_id);
+  get_warning_info()->opt_clear_warning_info(query_id);
 
   /*
     TODO: replace by DBUG_ASSERT(sql_errno != 0) once all bugs similar to
@@ -856,7 +856,7 @@ MYSQL_ERROR* THD::raise_condition(uint s
   /* When simulating OOM, skip writing to error log to avoid mtr errors */
   DBUG_EXECUTE_IF("simulate_out_of_memory", DBUG_RETURN(NULL););
 
-  cond= m_warning_info->push_warning(this, sql_errno, sqlstate, level, msg);
+  cond= get_warning_info()->push_warning(this, sql_errno, sqlstate, level, msg);
   DBUG_RETURN(cond);
 }
 

=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h	2011-05-19 10:10:49 +0000
+++ b/sql/sql_class.h	2011-05-19 10:12:31 +0000
@@ -1895,8 +1895,8 @@ public:
     auto_inc_intervals_forced.append(next_id, ULONGLONG_MAX, 0);
   }
 
-  inline Warning_info *get_warning_info() { return m_warning_info; }
-  inline void set_warning_info(Warning_info *wi) { m_warning_info= wi; }
+  inline Warning_info *get_warning_info()
+  { return get_stmt_da()->get_warning_info(); }
 
   inline Diagnostics_area *get_stmt_da() { return m_stmt_da; }
   inline void set_stmt_da(Diagnostics_area *da) { m_stmt_da= da; }
@@ -2838,8 +2838,6 @@ private:
   MEM_ROOT main_mem_root;
   Warning_info main_warning_info;
   Diagnostics_area main_da;
-
-  Warning_info *m_warning_info;
   Diagnostics_area *m_stmt_da;
 
   /**

=== modified file 'sql/sql_error.h'
--- a/sql/sql_error.h	2011-04-15 12:02:22 +0000
+++ b/sql/sql_error.h	2011-05-19 10:12:31 +0000
@@ -90,7 +90,22 @@ public:
     return m_statement_warn_count;
   }
 
-  Diagnostics_area() { reset_diagnostics_area(); }
+public:
+  inline Diagnostics_area(class Warning_info *wi) :
+    m_current_wi(wi)
+  {
+    reset_diagnostics_area();
+  }
+
+public:
+  inline class Warning_info *get_warning_info()
+  { return m_current_wi; }
+
+  inline const class Warning_info *get_warning_info() const
+  { return m_current_wi; }
+
+  inline void set_warning_info(class Warning_info *wi)
+  { m_current_wi= wi; }
 
 private:
   /** Message buffer. Can be used by OK or ERROR status. */
@@ -129,6 +144,8 @@ private:
   */
   uint	     m_statement_warn_count;
   enum_diagnostics_status m_status;
+
+  class Warning_info *m_current_wi;
 };
 
 ///////////////////////////////////////////////////////////////////////////

=== modified file 'sql/sql_prepare.cc'
--- a/sql/sql_prepare.cc	2011-05-19 10:10:49 +0000
+++ b/sql/sql_prepare.cc	2011-05-19 10:12:31 +0000
@@ -2841,12 +2841,11 @@ void mysql_stmt_get_longdata(THD *thd, c
 
   param= stmt->param_array[param_number];
 
-  Diagnostics_area new_stmt_da, *save_stmt_da= thd->get_stmt_da();
   Warning_info new_warnning_info(thd->query_id, false);
-  Warning_info *save_warinig_info= thd->get_warning_info();
+  Diagnostics_area new_stmt_da(&new_warnning_info);
+  Diagnostics_area *save_stmt_da= thd->get_stmt_da();
 
   thd->set_stmt_da(&new_stmt_da);
-  thd->set_warning_info(&new_warnning_info);
 
 #ifndef EMBEDDED_LIBRARY
   param->set_longdata(packet, (ulong) (packet_end - packet));
@@ -2860,7 +2859,6 @@ void mysql_stmt_get_longdata(THD *thd, c
     strncpy(stmt->last_error, thd->get_stmt_da()->message(), MYSQL_ERRMSG_SIZE);
   }
   thd->set_stmt_da(save_stmt_da);
-  thd->set_warning_info(save_warinig_info);
 
   general_log_print(thd, thd->command, NullS);
 
@@ -3900,8 +3898,9 @@ Ed_result_set::Ed_result_set(List<Ed_row
   Create a new "execute direct" connection.
 */
 
-Ed_connection::Ed_connection(THD *thd)
-  :m_warning_info(thd->query_id, false),
+Ed_connection::Ed_connection(THD *thd) :
+  m_warning_info(thd->query_id, false),
+  m_diagnostics_area(&m_warning_info),
   m_thd(thd),
   m_rsets(0),
   m_current_rset(0)
@@ -3927,7 +3926,7 @@ Ed_connection::free_old_result()
   }
   m_current_rset= m_rsets;
   m_diagnostics_area.reset_diagnostics_area();
-  m_warning_info.clear_warning_info(m_thd->query_id);
+  m_diagnostics_area.get_warning_info()->clear_warning_info(m_thd->query_id);
 }
 
 
@@ -3965,7 +3964,6 @@ bool Ed_connection::execute_direct(Serve
   Prepared_statement stmt(m_thd);
   Protocol *save_protocol= m_thd->protocol;
   Diagnostics_area *save_diagnostics_area= m_thd->get_stmt_da();
-  Warning_info *save_warning_info= m_thd->get_warning_info();
 
   DBUG_ENTER("Ed_connection::execute_direct");
 
@@ -3973,14 +3971,12 @@ bool Ed_connection::execute_direct(Serve
 
   m_thd->protocol= &protocol_local;
   m_thd->set_stmt_da(&m_diagnostics_area);
-  m_thd->set_warning_info(&m_warning_info);
 
   rc= stmt.execute_server_runnable(server_runnable);
   m_thd->protocol->end_statement();
 
   m_thd->protocol= save_protocol;
   m_thd->set_stmt_da(save_diagnostics_area);
-  m_thd->set_warning_info(save_warning_info);
   /*
     Protocol_local makes use of m_current_rset to keep
     track of the last result set, while adding result sets to the end.

=== modified file 'sql/sql_prepare.h'
--- a/sql/sql_prepare.h	2009-10-21 20:02:06 +0000
+++ b/sql/sql_prepare.h	2011-05-19 10:12:31 +0000
@@ -252,7 +252,7 @@ public:
   */
   ulong get_warn_count() const
   {
-    return m_warning_info.warn_count();
+    return m_diagnostics_area.get_warning_info()->warn_count();
   }
   /**
     Get the server warnings as a result set.
@@ -261,7 +261,9 @@ public:
     The second is a numeric code.
     The third is warning text.
   */
-  List<MYSQL_ERROR> *get_warn_list() { return &m_warning_info.warn_list(); }
+  List<MYSQL_ERROR> *get_warn_list()
+  { return &m_diagnostics_area.get_warning_info()->warn_list(); }
+
   /**
     The following members are only valid if execute_direct()
     or move_to_next_result() returned an error.
@@ -309,8 +311,8 @@ public:
 
   ~Ed_connection() { free_old_result(); }
 private:
-  Diagnostics_area m_diagnostics_area;
   Warning_info m_warning_info;
+  Diagnostics_area m_diagnostics_area;
   /**
     Execute direct interface does not support multi-statements, only
     multi-results. So we never have a situation when we have

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2011-05-19 10:10:49 +0000
+++ b/sql/sql_show.cc	2011-05-19 10:12:31 +0000
@@ -6773,25 +6773,26 @@ static bool do_fill_table(THD *thd,
   // Warning_info, so "useful warnings" get rejected. In order to avoid
   // that problem we create a Warning_info instance, which is capable of
   // storing "unlimited" number of warnings.
+  Diagnostics_area *da= thd->get_stmt_da();
   Warning_info wi(thd->query_id, true);
   Warning_info *wi_saved= thd->get_warning_info();
 
-  thd->set_warning_info(&wi);
+  da->set_warning_info(&wi);
 
   bool res= table_list->schema_table->fill_table(
     thd, table_list, join_table->select_cond);
 
-  thd->set_warning_info(wi_saved);
+  da->set_warning_info(wi_saved);
 
   // Pass an error if any.
 
-  if (thd->get_stmt_da()->is_error())
+  if (da->is_error())
   {
-    thd->get_warning_info()->push_warning(thd,
-                                          thd->get_stmt_da()->sql_errno(),
-                                          thd->get_stmt_da()->get_sqlstate(),
-                                          MYSQL_ERROR::WARN_LEVEL_ERROR,
-                                          thd->get_stmt_da()->message());
+    wi_saved->push_warning(thd,
+                           da->sql_errno(),
+                           da->get_sqlstate(),
+                           MYSQL_ERROR::WARN_LEVEL_ERROR,
+                           da->message());
   }
 
   // Pass warnings (if any).
@@ -6806,7 +6807,7 @@ static bool do_fill_table(THD *thd,
   while ((err= it++))
   {
     if (err->get_level() != MYSQL_ERROR::WARN_LEVEL_ERROR)
-      thd->get_warning_info()->push_warning(thd, err);
+      wi_saved->push_warning(thd, err);
   }
 
   return res;


Attachment: [text/bzr-bundle] bzr/alexander.nozdrin@oracle.com-20110519101231-pzl6mt0yn3irksbl.bundle
Thread
bzr commit into mysql-5.5 branch (alexander.nozdrin:3389) Bug#11763162Alexander Nozdrin19 May