List:Commits« Previous MessageNext Message »
From:Jon Olav Hauglid Date:July 4 2012 1:47pm
Subject:bzr push into mysql-trunk-wl6406 branch (jon.hauglid:3968 to 3969) WL#6406
View as plain text  
 3969 Jon Olav Hauglid	2012-07-04
      WL#6406 Stacked diagnostic areas
      
      Patch 1:
      - Added THD::push_diagnostics_area(), THD::pop_diagnostics_area()
        and THD::get_stacked_da(). Related code added to sql_error.
      - Removed push/pop of warning info, used push/pop da instead.
      - Removed set_stmt_da(), used push/pop da instead.

    modified:
      sql/rpl_master.cc
      sql/sp_head.cc
      sql/sql_admin.cc
      sql/sql_class.h
      sql/sql_error.cc
      sql/sql_error.h
      sql/sql_get_diagnostics.cc
      sql/sql_partition.cc
      sql/sql_prepare.cc
      sql/sql_show.cc
 3968 Jon Olav Hauglid	2012-07-04
      Change tree name

    modified:
      .bzr-mysql/default.conf
=== modified file 'sql/rpl_master.cc'
--- a/sql/rpl_master.cc	2012-06-25 09:28:20 +0000
+++ b/sql/rpl_master.cc	2012-07-04 13:47:16 +0000
@@ -782,8 +782,7 @@ void mysql_binlog_send(THD* thd, char* l
     Diagnostics_area.
   */
   Diagnostics_area temp_da;
-  Diagnostics_area *saved_da= thd->get_stmt_da();
-  thd->set_stmt_da(&temp_da);
+  thd->push_diagnostics_area(&temp_da);
 
   DBUG_ENTER("mysql_binlog_send");
   DBUG_PRINT("enter",("log_ident: '%s'  pos: %ld", log_ident, (long) pos));
@@ -1538,7 +1537,7 @@ impossible position";
   }
 
 end:
-  thd->set_stmt_da(saved_da);
+  thd->pop_diagnostics_area();
   end_io_cache(&log);
   mysql_file_close(file, MYF(MY_WME));
 
@@ -1589,7 +1588,7 @@ err:
     mysql_file_close(file, MYF(MY_WME));
   thd->variables.max_allowed_packet= old_max_allowed_packet;
 
-  thd->set_stmt_da(saved_da);
+  thd->pop_diagnostics_area();
   my_message(my_errno, error_text, MYF(0));
   DBUG_VOID_RETURN;
 }

=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc	2012-05-22 13:35:37 +0000
+++ b/sql/sp_head.cc	2012-07-04 13:47:16 +0000
@@ -435,8 +435,8 @@ bool sp_head::execute(THD *thd, bool mer
   Item_change_list old_change_list;
   String old_packet;
   Object_creation_ctx *saved_creation_ctx;
-  Diagnostics_area *da= thd->get_stmt_da();
-  Warning_info sp_wi(da->warning_info_id(), false);
+  Diagnostics_area *caller_da= thd->get_stmt_da();
+  Diagnostics_area sp_da(thd->get_stmt_da()->warning_info_id(), false);
 
   /*
     Just reporting a stack overrun error
@@ -514,9 +514,8 @@ bool sp_head::execute(THD *thd, bool mer
   thd->is_slave_error= 0;
   old_arena= thd->stmt_arena;
 
-  /* Push a new warning information area. */
-  da->copy_sql_conditions_to_wi(thd, &sp_wi);
-  da->push_warning_info(&sp_wi);
+  /* Push a new diagnostics area. */
+  thd->push_diagnostics_area(&sp_da);
 
   /*
     Switch query context. This has to be done early as this is sometimes
@@ -708,34 +707,41 @@ bool sp_head::execute(THD *thd, bool mer
   state= STMT_EXECUTED;
 
   /*
-    Restore the caller's original warning information area:
-      - warnings generated during trigger execution should not be
+    Restore the caller's original diagnostics area:
+      - conditions generated during trigger execution should not be
         propagated to the caller on success;
-      - if there was an exception during execution, warning info should be
+      - if there was an exception during execution, conditions should be
         propagated to the caller in any case.
   */
-  da->pop_warning_info();
+  thd->pop_diagnostics_area();
+  if (sp_da.is_error())
+  {
+    caller_da->set_error_status(sp_da.sql_errno(),
+                                sp_da.message(),
+                                sp_da.get_sqlstate(),
+                                sp_da.get_error_condition());
+  }
 
   if (err_status || merge_da_on_success)
   {
     /*
-      If a routine body is empty or if a routine did not generate any warnings,
+      If a routine body is empty or if a routine did not generate any conditions,
       do not duplicate our own contents by appending the contents of the called
-      routine. We know that the called routine did not change its warning info.
+      routine. We know that the called routine did not change its diagnostic area.
 
       On the other hand, if the routine body is not empty and some statement in
-      the routine generates a warning or uses tables, warning info is guaranteed
-      to have changed. In this case we know that the routine warning info
-      contains only new warnings, and thus we perform a copy.
+      the routine generates a condition or uses tables, diagnostic area is guaranteed
+      to have changed. In this case we know that the routine diagnostic area
+      contains only new conditions, and thus we perform a copy.
     */
-    if (da->warning_info_changed(&sp_wi))
+    if (caller_da->diagnostics_area_changed(&sp_da))
     {
       /*
         If the invocation of the routine was a standalone statement,
         rather than a sub-statement, in other words, if it's a CALL
         of a procedure, rather than invocation of a function or a
         trigger, we need to clear the current contents of the caller's
-        warning info.
+        diagnostic area.
 
         This is per MySQL rules: if a statement generates a warning,
         warnings from the previous statement are flushed.  Normally
@@ -743,9 +749,9 @@ bool sp_head::execute(THD *thd, bool mer
         push_warning() to avoid invocation of condition handlers or
         escalation of warnings to errors.
       */
-      da->opt_clear_warning_info(thd->query_id);
-      da->copy_sql_conditions_from_wi(thd, &sp_wi);
-      da->remove_marked_sql_conditions();
+      caller_da->opt_clear_warning_info(thd->query_id);
+      caller_da->copy_sql_conditions_from_da(thd, &sp_da);
+      caller_da->remove_marked_sql_conditions();
     }
   }
 

=== modified file 'sql/sql_admin.cc'
--- a/sql/sql_admin.cc	2012-06-10 10:12:50 +0000
+++ b/sql/sql_admin.cc	2012-07-04 13:47:16 +0000
@@ -351,17 +351,22 @@ 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 tmp_wi(thd->query_id, false);
-
-        da->push_warning_info(&tmp_wi);
+        Diagnostics_area tmp_da(thd->query_id, false);
+        thd->push_diagnostics_area(&tmp_da);
 
         open_error= open_temporary_tables(thd, table);
 
         if (!open_error)
           open_error= open_and_lock_tables(thd, table, TRUE, 0);
 
-        da->pop_warning_info();
+        thd->pop_diagnostics_area();
+        if (tmp_da.is_error())
+        {
+          thd->get_stmt_da()->set_error_status(tmp_da.sql_errno(),
+                                               tmp_da.message(),
+                                               tmp_da.get_sqlstate(),
+                                               tmp_da.get_error_condition());
+        }
       }
       else
       {

=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h	2012-07-04 08:37:26 +0000
+++ b/sql/sql_class.h	2012-07-04 13:47:16 +0000
@@ -3346,9 +3346,32 @@ public:
   const Diagnostics_area *get_stmt_da() const
   { return m_stmt_da; }
 
-  /// Sets Diagnostics-area for the current statement.
-  void set_stmt_da(Diagnostics_area *da)
-  { m_stmt_da= da; }
+  /**
+    Returns the diagnostics area below the current diagnostics
+    area on the stack.
+  */
+  const Diagnostics_area *get_stacked_da() const
+  { return get_stmt_da()->get_stacked_da(); }
+
+  /**
+    Push the given diagnostics area on top of the stack.
+    Conditions present in the new stacked diagnostics area
+    will be copied to the new top diagnostics area.
+
+    @param da   Diagnostics area to be come the top of
+                the diagnostics area stack.
+  */
+  void push_diagnostics_area(Diagnostics_area *da)
+  {
+    get_stmt_da()->push_diagnostics_area(this, da);
+    m_stmt_da= da;
+  }
+
+  /// Pop the top DA off the diagnostics area stack.
+  void pop_diagnostics_area()
+  {
+    m_stmt_da= get_stmt_da()->pop_diagnostics_area();
+  }
 
 public:
   inline const CHARSET_INFO *charset()

=== modified file 'sql/sql_error.cc'
--- a/sql/sql_error.cc	2012-03-13 13:16:27 +0000
+++ b/sql/sql_error.cc	2012-07-04 13:47:16 +0000
@@ -379,19 +379,16 @@ Sql_condition::set_subclass_origin()
 }
 
 Diagnostics_area::Diagnostics_area()
- : m_main_wi(0, false)
+ : m_main_wi(0, false), m_stacked_da(NULL)
 {
-  push_warning_info(&m_main_wi);
-
   reset_diagnostics_area();
 }
 
 Diagnostics_area::Diagnostics_area(ulonglong warning_info_id,
                                    bool allow_unlimited_warnings)
- : m_main_wi(warning_info_id, allow_unlimited_warnings)
+ : m_main_wi(warning_info_id, allow_unlimited_warnings),
+   m_stacked_da(NULL)
 {
-  push_warning_info(&m_main_wi);
-
   reset_diagnostics_area();
 }
 
@@ -414,7 +411,7 @@ Diagnostics_area::reset_diagnostics_area
   m_last_insert_id= 0;
   m_statement_warn_count= 0;
 #endif
-  get_warning_info()->clear_error_condition();
+  m_main_wi.clear_error_condition();
   set_is_sent(false);
   /** Tiny reset in debug mode to see garbage right away */
   m_status= DA_EMPTY;
@@ -546,7 +543,7 @@ Diagnostics_area::set_error_status(uint
   m_sqlstate[SQLSTATE_LENGTH]= '\0';
   strmake(m_message, message, sizeof(m_message)-1);
 
-  get_warning_info()->set_error_condition(error_condition);
+  m_main_wi.set_error_condition(error_condition);
 
   m_status= DA_ERROR;
   DBUG_VOID_RETURN;
@@ -637,31 +634,21 @@ void Warning_info::append_warning_info(T
 }
 
 
-/**
-  Copy Sql_conditions that are not WARN_LEVEL_ERROR from the source
-  Warning_info to the current Warning_info.
-
-  @param thd    Thread context.
-  @param sp_wi  Stored-program Warning_info
-  @param thd     Thread context.
-  @param src_wi  Warning_info to copy from.
-*/
-void Diagnostics_area::copy_non_errors_from_wi(THD *thd,
-                                               const Warning_info *src_wi)
+void Diagnostics_area::copy_non_errors_from_da(THD *thd,
+                                               const Diagnostics_area *src_da)
 {
-  Sql_condition_iterator it(src_wi->m_warn_list);
+  Sql_condition_iterator it(src_da->m_main_wi.m_warn_list);
   const Sql_condition *cond;
-  Warning_info *wi= get_warning_info();
 
   while ((cond= it++))
   {
     if (cond->get_level() == Sql_condition::WARN_LEVEL_ERROR)
       continue;
 
-    Sql_condition *new_condition= wi->push_warning(thd, cond);
+    Sql_condition *new_condition= m_main_wi.push_warning(thd, cond);
 
-    if (src_wi->is_marked_for_removal(cond))
-      wi->mark_condition_for_removal(new_condition);
+    if (src_da->m_main_wi.is_marked_for_removal(cond))
+      m_main_wi.mark_condition_for_removal(new_condition);
   }
 }
 
@@ -756,6 +743,24 @@ Sql_condition *Warning_info::push_warnin
   return new_condition;
 }
 
+
+void Diagnostics_area::push_diagnostics_area(THD *thd, Diagnostics_area *da)
+{
+  DBUG_ASSERT(da->m_stacked_da == NULL);
+  da->m_stacked_da= this;
+  da->m_main_wi.append_warning_info(thd, &m_main_wi);
+}
+
+
+Diagnostics_area *Diagnostics_area::pop_diagnostics_area()
+{
+  DBUG_ASSERT(m_stacked_da);
+  Diagnostics_area *da= m_stacked_da;
+  m_stacked_da= NULL;
+  return da;
+}
+
+
 /*
   Push the warning to error list if there is still room in the list
 

=== modified file 'sql/sql_error.h'
--- a/sql/sql_error.h	2012-05-25 07:57:33 +0000
+++ b/sql/sql_error.h	2012-07-04 13:47:16 +0000
@@ -280,17 +280,11 @@ class Warning_info
   /** Read only status. */
   bool m_read_only;
 
-  /** Pointers for participating in the stack of Warning_info objects. */
-  Warning_info *m_next_in_da;
-  Warning_info **m_prev_in_da;
-
   List<Sql_condition> m_marked_sql_conditions;
 
-public:
   Warning_info(ulonglong warn_id_arg, bool allow_unlimited_warnings);
   ~Warning_info();
 
-private:
   Warning_info(const Warning_info &rhs); /* Not implemented */
   Warning_info& operator=(const Warning_info &rhs); /* Not implemented */
 
@@ -521,7 +515,6 @@ private:
   { m_error_condition= NULL; }
 
   // for:
-  //   - m_next_in_da / m_prev_in_da
   //   - is_marked_for_removal()
   friend class Diagnostics_area;
 };
@@ -586,16 +579,6 @@ public:
 */
 class Diagnostics_area
 {
-private:
-  /** The type of the counted and doubly linked list of conditions. */
-  typedef I_P_List<Warning_info,
-                   I_P_List_adapter<Warning_info,
-                                    &Warning_info::m_next_in_da,
-                                    &Warning_info::m_prev_in_da>,
-                   I_P_List_counter,
-                   I_P_List_fast_push_back<Warning_info> >
-          Warning_info_list;
-
 public:
   /** Const iterator used to iterate through the warning list. */
   typedef Warning_info::Sql_condition_list::Const_Iterator
@@ -675,84 +658,75 @@ public:
   Diagnostics_area();
   Diagnostics_area(ulonglong warning_info_id, bool allow_unlimited_warnings);
 
-  void push_warning_info(Warning_info *wi)
-  { m_wi_stack.push_front(wi); }
-
-  void pop_warning_info()
-  {
-    DBUG_ASSERT(m_wi_stack.elements() > 0);
-    m_wi_stack.remove(m_wi_stack.front());
-  }
-
   void set_warning_info_id(ulonglong id)
-  { get_warning_info()->id(id); }
+  { m_main_wi.id(id); }
 
   ulonglong warning_info_id() const
-  { return get_warning_info()->id(); }
+  { return m_main_wi.id(); }
 
   /**
-    Compare given current warning info and current warning info
+    Compare given current and given diagnostic area
     and see if they are different. They will be different if
     warnings have been generated or statements that use tables
     have been executed. This is checked by comparing m_warn_id.
 
-    @param wi  Warning info to compare with current Warning info.
+    @param da  Diagnostic area to compare with current diagnostic area.
 
     @return    false if they are equal, true if they are not.
   */
-  bool warning_info_changed(const Warning_info *wi) const
-  { return get_warning_info()->id() != wi->id(); }
+  bool diagnostics_area_changed(const Diagnostics_area *da) const
+  { return m_main_wi.id() != da->m_main_wi.id(); }
 
   bool is_warning_info_empty() const
-  { return get_warning_info()->is_empty(); }
+  { return m_main_wi.is_empty(); }
 
   ulong current_statement_warn_count() const
-  { return get_warning_info()->current_statement_warn_count(); }
+  { return m_main_wi.current_statement_warn_count(); }
 
   bool has_sql_condition(const char *message_str, ulong message_length) const
-  { return get_warning_info()->has_sql_condition(message_str, message_length); }
+  { return m_main_wi.has_sql_condition(message_str, message_length); }
 
   void reset_for_next_command()
-  { get_warning_info()->reset_for_next_command(); }
+  { m_main_wi.reset_for_next_command(); }
 
   void clear_warning_info(ulonglong id)
-  { get_warning_info()->clear(id); }
+  { m_main_wi.clear(id); }
 
   void opt_clear_warning_info(ulonglong query_id)
-  { get_warning_info()->opt_clear(query_id); }
+  { m_main_wi.opt_clear(query_id); }
 
   ulong current_row_for_warning() const
-  { return get_warning_info()->current_row_for_warning(); }
+  { return m_main_wi.current_row_for_warning(); }
 
   void inc_current_row_for_warning()
-  { get_warning_info()->inc_current_row_for_warning(); }
+  { m_main_wi.inc_current_row_for_warning(); }
 
   void reset_current_row_for_warning()
-  { get_warning_info()->reset_current_row_for_warning(); }
+  { m_main_wi.reset_current_row_for_warning(); }
 
   bool is_warning_info_read_only() const
-  { return get_warning_info()->is_read_only(); }
+  { return m_main_wi.is_read_only(); }
 
   void set_warning_info_read_only(bool read_only)
-  { get_warning_info()->set_read_only(read_only); }
+  { m_main_wi.set_read_only(read_only); }
 
   ulong error_count() const
-  { return get_warning_info()->error_count(); }
+  { return m_main_wi.error_count(); }
 
   ulong warn_count() const
-  { return get_warning_info()->warn_count(); }
+  { return m_main_wi.warn_count(); }
 
   uint cond_count() const
-  { return get_warning_info()->cond_count(); }
+  { return m_main_wi.cond_count(); }
 
   Sql_condition_iterator sql_conditions() const
-  { return get_warning_info()->m_warn_list; }
+  { return m_main_wi.m_warn_list; }
 
   void reserve_space(THD *thd, uint count)
-  { get_warning_info()->reserve_space(thd, count); }
+  { m_main_wi.reserve_space(thd, count); }
 
   Sql_condition *push_warning(THD *thd, const Sql_condition *sql_condition)
-  { return get_warning_info()->push_warning(thd, sql_condition); }
+  { return m_main_wi.push_warning(thd, sql_condition); }
 
   Sql_condition *push_warning(THD *thd,
                               uint sql_errno,
@@ -760,34 +734,65 @@ public:
                               Sql_condition::enum_warning_level level,
                               const char* msg)
   {
-    return get_warning_info()->push_warning(thd,
-                                            sql_errno, sqlstate, level, msg);
+    return m_main_wi.push_warning(thd, sql_errno, sqlstate, level, msg);
   }
 
   void mark_sql_conditions_for_removal()
-  { get_warning_info()->mark_sql_conditions_for_removal(); }
+  { m_main_wi.mark_sql_conditions_for_removal(); }
 
   void unmark_sql_conditions_from_removal()
-  { get_warning_info()->unmark_sql_conditions_from_removal(); }
+  { m_main_wi.unmark_sql_conditions_from_removal(); }
 
   void remove_marked_sql_conditions()
-  { get_warning_info()->remove_marked_sql_conditions(); }
+  { m_main_wi.remove_marked_sql_conditions(); }
 
   const Sql_condition *get_error_condition() const
-  { return get_warning_info()->get_error_condition(); }
+  { return m_main_wi.get_error_condition(); }
 
-  void copy_sql_conditions_to_wi(THD *thd, Warning_info *dst_wi) const
-  { dst_wi->append_warning_info(thd, get_warning_info()); }
+  void copy_sql_conditions_from_da(THD *thd, const Diagnostics_area *src_da)
+  { m_main_wi.append_warning_info(thd, &src_da->m_main_wi); }
 
-  void copy_sql_conditions_from_wi(THD *thd, const Warning_info *src_wi)
-  { get_warning_info()->append_warning_info(thd, src_wi); }
+  /**
+    Copy Sql_conditions that are not WARN_LEVEL_ERROR from the source
+    diagnostic area to the current diagnostic area.
 
-  void copy_non_errors_from_wi(THD *thd, const Warning_info *src_wi);
+    @param thd    Thread context.
+    @param src_da Diagnostic area to copy from.
+  */
+  void copy_non_errors_from_da(THD *thd, const Diagnostics_area *src_da);
 
 private:
-  Warning_info *get_warning_info() { return m_wi_stack.front(); }
+  /**
+    Push the given diagnostics area on top of the stack.
+    "This" will then become the stacked diagnostics area.
+    Conditions present in the new stacked diagnostics area
+    will be copied to the new top diagnostics area.
+
+    @note This function will not set THD::m_stmt_da.
+          Use THD::push_diagnostics_area() instead.
+
+    @param thd  Thread context
+    @param da   Diagnostics area to be come the top of
+                the diagnostics area stack.
+  */
+  void push_diagnostics_area(THD *thd, Diagnostics_area *da);
+
+  /**
+    Pop "this" off the diagnostics area stack.
 
-  const Warning_info *get_warning_info() const { return m_wi_stack.front(); }
+    @note This function will not set THD::m_stmt_da.
+          Use THD::pop_diagnostics_area() instead.
+
+    @returns The new top of the diagnostics area stack.
+  */
+  Diagnostics_area *pop_diagnostics_area();
+
+  /**
+    Returns the diagnostics area below the current diagnostics
+    area on the stack.
+  */
+  const Diagnostics_area *get_stacked_da() const
+  { return m_stacked_da; }
 
 private:
   /** True if status information is sent to the client. */
@@ -839,7 +844,10 @@ private:
 
   Warning_info m_main_wi;
 
-  Warning_info_list m_wi_stack;
+  /** Pointer to the diagnostic area below on the stack. */
+  Diagnostics_area *m_stacked_da;
+
+  friend class THD;
 };
 
 ///////////////////////////////////////////////////////////////////////////

=== modified file 'sql/sql_get_diagnostics.cc'
--- a/sql/sql_get_diagnostics.cc	2012-03-13 13:16:27 +0000
+++ b/sql/sql_get_diagnostics.cc	2012-07-04 13:47:16 +0000
@@ -50,10 +50,10 @@ Sql_cmd_get_diagnostics::execute(THD *th
   /* Disable the unneeded read-only mode of the original DA. */
   save_stmt_da->set_warning_info_read_only(false);
 
-  /* Set new diagnostics area, execute statement and restore. */
-  thd->set_stmt_da(&new_stmt_da);
+  /* Push new diagnostics area, execute statement and pop. */
+  thd->push_diagnostics_area(&new_stmt_da);
   rv= m_info->aggregate(thd, save_stmt_da);
-  thd->set_stmt_da(save_stmt_da);
+  thd->pop_diagnostics_area();
 
   /* Bail out early if statement succeeded. */
   if (! rv)

=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc	2012-06-21 09:50:01 +0000
+++ b/sql/sql_partition.cc	2012-07-04 13:47:16 +0000
@@ -6526,14 +6526,14 @@ static void alter_partition_lock_handlin
     {
       /* reopen might fail if we have a previous error, use a temporary da. */
       stmt_da= thd->get_stmt_da();
-      thd->set_stmt_da(&tmp_stmt_da);
+      thd->push_diagnostics_area(&tmp_stmt_da);
     }
 
     if (thd->locked_tables_list.reopen_tables(thd))
       sql_print_warning("We failed to reacquire LOCKs in ALTER TABLE");
 
     if (stmt_da)
-      thd->set_stmt_da(stmt_da);
+      thd->pop_diagnostics_area();
   }
 }
 
@@ -6730,14 +6730,14 @@ err_exclusive_lock:
     {
       /* reopen might fail if we have a previous error, use a temporary da. */
       stmt_da= thd->get_stmt_da();
-      thd->set_stmt_da(&tmp_stmt_da);
+      thd->push_diagnostics_area(&tmp_stmt_da);
     }
 
     if (thd->locked_tables_list.reopen_tables(thd))
       sql_print_warning("We failed to reacquire LOCKs in ALTER TABLE");
 
     if (stmt_da)
-      thd->set_stmt_da(stmt_da);
+      thd->pop_diagnostics_area();
   }
 
   DBUG_VOID_RETURN;

=== modified file 'sql/sql_prepare.cc'
--- a/sql/sql_prepare.cc	2012-05-29 19:18:45 +0000
+++ b/sql/sql_prepare.cc	2012-07-04 13:47:16 +0000
@@ -2926,9 +2926,7 @@ void mysql_stmt_get_longdata(THD *thd, c
   param= stmt->param_array[param_number];
 
   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->push_diagnostics_area(&new_stmt_da);
 
 #ifndef EMBEDDED_LIBRARY
   param->set_longdata(packet, (ulong) (packet_end - packet));
@@ -2941,7 +2939,7 @@ void mysql_stmt_get_longdata(THD *thd, c
     stmt->last_errno= thd->get_stmt_da()->sql_errno();
     strncpy(stmt->last_error, thd->get_stmt_da()->message(), MYSQL_ERRMSG_SIZE);
   }
-  thd->set_stmt_da(save_stmt_da);
+  thd->pop_diagnostics_area();
 
   general_log_print(thd, thd->get_command(), NullS);
 
@@ -4067,20 +4065,19 @@ bool Ed_connection::execute_direct(Serve
   Protocol_local protocol_local(m_thd, this);
   Prepared_statement stmt(m_thd);
   Protocol *save_protocol= m_thd->protocol;
-  Diagnostics_area *save_diagnostics_area= m_thd->get_stmt_da();
 
   DBUG_ENTER("Ed_connection::execute_direct");
 
   free_old_result(); /* Delete all data from previous execution, if any */
 
   m_thd->protocol= &protocol_local;
-  m_thd->set_stmt_da(&m_diagnostics_area);
+  m_thd->push_diagnostics_area(&m_diagnostics_area);
 
   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->pop_diagnostics_area();
   /*
     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_show.cc'
--- a/sql/sql_show.cc	2012-06-01 14:02:36 +0000
+++ b/sql/sql_show.cc	2012-07-04 13:47:16 +0000
@@ -7196,38 +7196,40 @@ static bool do_fill_table(THD *thd,
 {
   // NOTE: fill_table() may generate many "useless" warnings, which will be
   // ignored afterwards. On the other hand, there might be "useful"
-  // warnings, which should be presented to the user. Warning_info usually
+  // warnings, which should be presented to the user. Diagnostics_area usually
   // stores no more than THD::variables.max_error_count warnings.
   // The problem is that "useless warnings" may occupy all the slots in the
-  // Warning_info, so "useful warnings" get rejected. In order to avoid
-  // that problem we create a Warning_info instance, which is capable of
+  // Diagnostics_area, so "useful warnings" get rejected. In order to avoid
+  // that problem we create a Diagnostics_area instance, which is capable of
   // storing "unlimited" number of warnings.
   Diagnostics_area *da= thd->get_stmt_da();
-  Warning_info wi_tmp(thd->query_id, true);
-
-  da->push_warning_info(&wi_tmp);
+  Diagnostics_area tmp_da(thd->query_id, true);
+  thd->push_diagnostics_area(&tmp_da);
 
   bool res= table_list->schema_table->fill_table(
     thd, table_list, join_table->condition());
 
-  da->pop_warning_info();
+  thd->pop_diagnostics_area();
 
   // Pass an error if any.
-
-  if (da->is_error())
+  if (tmp_da.is_error())
   {
+    da->set_error_status(tmp_da.sql_errno(),
+                         tmp_da.message(),
+                         tmp_da.get_sqlstate(),
+                         tmp_da.get_error_condition());
     da->push_warning(thd,
-                     da->sql_errno(),
-                     da->get_sqlstate(),
+                     tmp_da.sql_errno(),
+                     tmp_da.get_sqlstate(),
                      Sql_condition::WARN_LEVEL_ERROR,
-                     da->message());
+                     tmp_da.message());
   }
 
   // Pass warnings (if any).
   //
   // Filter out warnings with WARN_LEVEL_ERROR level, because they
   // correspond to the errors which were filtered out in fill_table().
-  da->copy_non_errors_from_wi(thd, &wi_tmp);
+  da->copy_non_errors_from_da(thd, &tmp_da);
 
   return res;
 }

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk-wl6406 branch (jon.hauglid:3968 to 3969) WL#6406Jon Olav Hauglid4 Jul