List:Commits« Previous MessageNext Message »
From:Alexander Nozdrin Date:June 8 2011 5:27pm
Subject:bzr commit into mysql-trunk branch (alexander.nozdrin:3170) Bug#11763162
View as plain text  
#At file:///home/alik/MySQL/bzr/00/bug55843/mysql-trunk-bug55843-02/ based on revid:alexander.nozdrin@stripped

 3170 Alexander Nozdrin	2011-06-08
      Pre-requisite patch for Bug#11763162 (55843 - Handled condition
      appears as not handled).
      
      The goal of this patch is to change 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() and THD::set_warning_info(),
      so that they still work to minimize side changes.
      
      Those functions will be removed later in a separate patch.
     @ sql/sp_head.cc
        Note: Warning_info is pushed here alone (without Diagnistics_area).
        Temporary Warning_info instance is used to collect warnings
        from stored-routine-execution and append them to the main
        Warning_info area.
     @ sql/sql_admin.cc
        Note: Warning_info is pushed here alone (without Diagnistics_area).
        Temporary Warning_info instance is used to collect unneeded
        warnings and ignore them.
     @ sql/sql_prepare.cc
        Note: Diagnostics_area is pushed here along with
        a new instance of Warning_info.
     @ sql/sql_show.cc
        Note: Warning_info is pushed here alone (without Diagnistics_area).
        Temporary Warning_info instance is used to collect warnings
        from ST_SHEMA_TABLE::fill_table() and process them afterwards.

    modified:
      sql/sp_head.cc
      sql/sql_admin.cc
      sql/sql_class.cc
      sql/sql_class.h
      sql/sql_error.cc
      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-06-08 14:46:12 +0000
+++ b/sql/sp_head.cc	2011-06-08 17:27:14 +0000
@@ -1288,7 +1288,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
@@ -1497,7 +1497,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-06-08 14:46:12 +0000
+++ b/sql/sql_admin.cc	2011-06-08 17:27:14 +0000
@@ -351,17 +351,18 @@ 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_temporary_tables(thd, table);
 
         if (!open_error)
           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-06-08 14:46:12 +0000
+++ b/sql/sql_class.cc	2011-06-08 17:27:14 +0000
@@ -753,8 +753,7 @@ THD::THD(bool enable_plugins)
    debug_sync_control(0),
 #endif /* defined(ENABLED_DEBUG_SYNC) */
    m_enable_plugins(enable_plugins),
-   main_warning_info(0, false),
-   m_warning_info(&main_warning_info),
+   main_da(0, false),
    m_stmt_da(&main_da)
 {
   ulong tmp;

=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h	2011-06-08 14:46:12 +0000
+++ b/sql/sql_class.h	2011-06-08 17:27:14 +0000
@@ -2834,16 +2834,12 @@ public:
 
   /// Returns Warning-information-area for the current statement.
   Warning_info *get_warning_info()
-  { return m_warning_info; }
+  { return get_stmt_da()->get_warning_info(); }
 
   /// Returns Warning-information-area for the current statement.
   const Warning_info *get_warning_info() const
   { return const_cast<THD *> (this)->get_warning_info(); }
 
-  /// Sets Warning-information-area for the current statement.
-  void set_warning_info(Warning_info *wi)
-  { m_warning_info= wi; }
-
   /// Returns Diagnostics-area for the current statement.
   Diagnostics_area *get_stmt_da()
   { return m_stmt_da; }
@@ -3247,10 +3243,7 @@ private:
     tree itself is reused between executions and thus is stored elsewhere.
   */
   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.cc'
--- a/sql/sql_error.cc	2011-06-08 14:46:12 +0000
+++ b/sql/sql_error.cc	2011-06-08 17:27:14 +0000
@@ -318,6 +318,23 @@ MYSQL_ERROR::set_sqlstate(const char* sq
   m_returned_sqlstate[SQLSTATE_LENGTH]= '\0';
 }
 
+Diagnostics_area::Diagnostics_area()
+:
+  m_main_wi(0, false),
+  m_current_wi(&m_main_wi)
+{
+  reset_diagnostics_area();
+}
+
+Diagnostics_area::Diagnostics_area(ulonglong warn_id,
+                                   bool allow_unlimited_warnings)
+:
+  m_main_wi(warn_id, allow_unlimited_warnings),
+  m_current_wi(&m_main_wi)
+{
+  reset_diagnostics_area();
+}
+
 /**
   Clear this diagnostics area.
 

=== modified file 'sql/sql_error.h'
--- a/sql/sql_error.h	2011-06-08 17:03:06 +0000
+++ b/sql/sql_error.h	2011-06-08 17:27:14 +0000
@@ -485,7 +485,19 @@ public:
     return m_statement_warn_count;
   }
 
-  Diagnostics_area() { reset_diagnostics_area(); }
+public:
+  Diagnostics_area();
+  Diagnostics_area(ulonglong warn_id, bool allow_unlimited_warnings);
+
+public:
+  inline Warning_info *get_warning_info()
+  { return m_current_wi; }
+
+  inline const Warning_info *get_warning_info() const
+  { return m_current_wi; }
+
+  inline void set_warning_info(Warning_info *wi)
+  { m_current_wi= wi; }
 
 private:
   /** Message buffer. Can be used by OK or ERROR status. */
@@ -524,6 +536,9 @@ private:
   */
   uint	     m_statement_warn_count;
   enum_diagnostics_status m_status;
+
+  Warning_info m_main_wi;
+  Warning_info *m_current_wi;
 };
 
 ///////////////////////////////////////////////////////////////////////////

=== modified file 'sql/sql_prepare.cc'
--- a/sql/sql_prepare.cc	2011-06-08 14:46:12 +0000
+++ b/sql/sql_prepare.cc	2011-06-08 17:27:14 +0000
@@ -2850,12 +2850,10 @@ 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(thd->query_id, false);
+  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));
@@ -2869,7 +2867,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->get_command(), NullS);
 
@@ -3918,7 +3915,7 @@ Ed_result_set::Ed_result_set(List<Ed_row
 */
 
 Ed_connection::Ed_connection(THD *thd)
-  :m_warning_info(thd->query_id, false),
+  :m_diagnostics_area(thd->query_id, false),
   m_thd(thd),
   m_rsets(0),
   m_current_rset(0)
@@ -3944,7 +3941,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);
 }
 
 
@@ -3982,7 +3979,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");
 
@@ -3990,14 +3986,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	2010-07-02 18:15:21 +0000
+++ b/sql/sql_prepare.h	2011-06-08 17:27:14 +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.
@@ -310,7 +312,6 @@ public:
   ~Ed_connection() { free_old_result(); }
 private:
   Diagnostics_area m_diagnostics_area;
-  Warning_info m_warning_info;
   /**
     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-06-08 14:46:12 +0000
+++ b/sql/sql_show.cc	2011-06-08 17:27:14 +0000
@@ -6803,25 +6803,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.
-  Warning_info wi(thd->query_id, true);
-  Warning_info *wi_saved= thd->get_warning_info();
+  Diagnostics_area *da= thd->get_stmt_da();
+  Warning_info wi_tmp(thd->query_id, true);
+  Warning_info *wi= thd->get_warning_info();
 
-  thd->set_warning_info(&wi);
+  da->set_warning_info(&wi_tmp);
 
   bool res= table_list->schema_table->fill_table(
     thd, table_list, join_table->condition());
 
-  thd->set_warning_info(wi_saved);
+  da->set_warning_info(wi);
 
   // 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->push_warning(thd,
+                     da->sql_errno(),
+                     da->get_sqlstate(),
+                     MYSQL_ERROR::WARN_LEVEL_ERROR,
+                     da->message());
   }
 
   // Pass warnings (if any).
@@ -6830,13 +6831,13 @@ static bool do_fill_table(THD *thd,
   // correspond to the errors which were filtered out in fill_table().
 
 
-  List_iterator_fast<MYSQL_ERROR> it(wi.warn_list());
+  List_iterator_fast<MYSQL_ERROR> it(wi_tmp.warn_list());
   MYSQL_ERROR *err;
 
   while ((err= it++))
   {
     if (err->get_level() != MYSQL_ERROR::WARN_LEVEL_ERROR)
-      thd->get_warning_info()->push_warning(thd, err);
+      wi->push_warning(thd, err);
   }
 
   return res;


Attachment: [text/bzr-bundle] bzr/alexander.nozdrin@oracle.com-20110608172714-d42js75vidpq03g0.bundle
Thread
bzr commit into mysql-trunk branch (alexander.nozdrin:3170) Bug#11763162Alexander Nozdrin9 Jun
  • Re: bzr commit into mysql-trunk branch (alexander.nozdrin:3170) Bug#11763162Jon Olav Hauglid9 Jun