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

 3167 Alexander Nozdrin	2011-06-07
      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/rpl_master.cc
      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/rpl_master.cc'
--- a/sql/rpl_master.cc	2011-06-07 13:09:47 +0000
+++ b/sql/rpl_master.cc	2011-06-07 13:29:37 +0000
@@ -648,7 +648,7 @@ void mysql_binlog_send(THD* thd, char* l
     ER_MASTER_FATAL_ERROR_READING_BINLOG will be set to the original
     Diagnostics_area.
   */
-  Diagnostics_area temp_da;
+  Diagnostics_area temp_da(0, false);
   Diagnostics_area *saved_da= thd->get_stmt_da();
   thd->set_stmt_da(&temp_da);
 

=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc	2011-06-07 13:09:47 +0000
+++ b/sql/sp_head.cc	2011-06-07 13:29:37 +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-07 13:09:47 +0000
+++ b/sql/sql_admin.cc	2011-06-07 13:29:37 +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-07 13:09:47 +0000
+++ b/sql/sql_class.cc	2011-06-07 13:29:37 +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;
@@ -1017,7 +1016,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
@@ -1090,7 +1089,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-06-07 13:09:47 +0000
+++ b/sql/sql_class.h	2011-06-07 13:29:37 +0000
@@ -2178,8 +2178,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; }
@@ -3227,10 +3227,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-07 13:09:47 +0000
+++ b/sql/sql_error.cc	2011-06-07 13:29:37 +0000
@@ -318,6 +318,15 @@ MYSQL_ERROR::set_sqlstate(const char* sq
   m_returned_sqlstate[SQLSTATE_LENGTH]= '\0';
 }
 
+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-07 13:22:10 +0000
+++ b/sql/sql_error.h	2011-06-07 13:29:37 +0000
@@ -485,7 +485,18 @@ public:
     return m_statement_warn_count;
   }
 
-  Diagnostics_area() { reset_diagnostics_area(); }
+public:
+  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 +535,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-07 13:09:47 +0000
+++ b/sql/sql_prepare.cc	2011-06-07 13:29:37 +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-07 13:29:37 +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-07 13:09:47 +0000
+++ b/sql/sql_show.cc	2011-06-07 13:29:37 +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.
+  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->condition());
 
-  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).
@@ -6836,7 +6837,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-20110607132937-9snfx2nh1c9j59bl.bundle
Thread
bzr commit into mysql-trunk branch (alexander.nozdrin:3167) Bug#11763162Alexander Nozdrin7 Jun
  • Re: bzr commit into mysql-trunk branch (alexander.nozdrin:3167) Bug#11763162Davi Arnaut7 Jun
    • Re: bzr commit into mysql-trunk branch (alexander.nozdrin:3167) Bug#11763162Alexander Nozdrin8 Jun
      • Re: bzr commit into mysql-trunk branch (alexander.nozdrin:3167) Bug#11763162Davi Arnaut8 Jun
  • Re: bzr commit into mysql-trunk branch (alexander.nozdrin:3167) Bug#11763162Jon Olav Hauglid8 Jun
    • Re: bzr commit into mysql-trunk branch (alexander.nozdrin:3167) Bug#11763162Alexander Nozdrin8 Jun