List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:June 15 2011 5:01pm
Subject:bzr commit into mysql-trunk branch (davi:3206)
View as plain text  
# At a local mysql-trunk repository of davi

 3206 Davi Arnaut	2011-06-15
      Revert making const MYSQL_ERROR objects useable.

    modified:
      sql/event_scheduler.cc
      sql/log_event.cc
      sql/rpl_slave.cc
      sql/sp_head.cc
      sql/sql_admin.cc
      sql/sql_base.cc
      sql/sql_error.cc
      sql/sql_error.h
      sql/sql_plist.h
      sql/sql_prepare.h
      sql/sql_show.cc
      sql/sql_table.cc
      sql/sql_test.cc
      sql/table.cc
      sql/table.h
=== modified file 'sql/event_scheduler.cc'
--- a/sql/event_scheduler.cc	2011-06-15 13:13:06 +0000
+++ b/sql/event_scheduler.cc	2011-06-15 17:01:24 +0000
@@ -75,7 +75,7 @@ struct scheduler_param {
 void
 Event_worker_thread::print_warnings(THD *thd, Event_job_data *et)
 {
-  const MYSQL_ERROR *err;
+  MYSQL_ERROR *err;
   DBUG_ENTER("evex_print_warnings");
   if (thd->get_stmt_wi()->is_empty())
     DBUG_VOID_RETURN;
@@ -93,7 +93,7 @@ Event_worker_thread::print_warnings(THD
   prefix.append(et->name.str, et->name.length, system_charset_info);
   prefix.append("] ", 2);
 
-  Warning_info::Const_iterator it= thd->get_stmt_wi()->iterator();
+  List_iterator_fast<MYSQL_ERROR> it(thd->get_stmt_wi()->warn_list());
   while ((err= it++))
   {
     String err_msg(msg_buf, sizeof(msg_buf), system_charset_info);

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2011-06-15 13:13:06 +0000
+++ b/sql/log_event.cc	2011-06-15 17:01:24 +0000
@@ -208,8 +208,8 @@ static void inline slave_rows_error_repo
   char buff[MAX_SLAVE_ERRMSG], *slider;
   const char *buff_end= buff + sizeof(buff);
   uint len;
-  Warning_info::Const_iterator it= thd->get_stmt_wi()->iterator();
-  const MYSQL_ERROR *err;
+  List_iterator_fast<MYSQL_ERROR> it(thd->get_stmt_wi()->warn_list());
+  MYSQL_ERROR *err;
   buff[0]= 0;
 
   for (err= it++, slider= buff; err && slider < buff_end - 1;

=== modified file 'sql/rpl_slave.cc'
--- a/sql/rpl_slave.cc	2011-06-15 13:13:06 +0000
+++ b/sql/rpl_slave.cc	2011-06-15 17:01:24 +0000
@@ -3747,8 +3747,8 @@ log '%s' at position %s, relay log '%s'
         }
 
         /* Print any warnings issued */
-        Warning_info::Const_iterator it= thd->get_stmt_wi()->iterator();
-        const MYSQL_ERROR *err;
+        List_iterator_fast<MYSQL_ERROR> it(thd->get_stmt_wi()->warn_list());
+        MYSQL_ERROR *err;
         /*
           Added controlled slave thread cancel for replication
           of user-defined variables.

=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc	2011-06-15 13:13:06 +0000
+++ b/sql/sp_head.cc	2011-06-15 17:01:24 +0000
@@ -1148,8 +1148,8 @@ find_handler_after_execution(THD *thd, s
   }
   else if (thd->get_stmt_wi()->statement_warn_count())
   {
-    Warning_info::Const_iterator it= thd->get_stmt_wi()->iterator();
-    const MYSQL_ERROR *err;
+    List_iterator<MYSQL_ERROR> it(thd->get_stmt_wi()->warn_list());
+    MYSQL_ERROR *err;
     while ((err= it++))
     {
       if (err->get_level() != MYSQL_ERROR::WARN_LEVEL_WARN &&

=== modified file 'sql/sql_admin.cc'
--- a/sql/sql_admin.cc	2011-06-15 13:13:06 +0000
+++ b/sql/sql_admin.cc	2011-06-15 17:01:24 +0000
@@ -639,8 +639,8 @@ send_result:
     lex->cleanup_after_one_table_open();
     thd->clear_error();  // these errors shouldn't get client
     {
-      Warning_info::Const_iterator it= thd->get_stmt_wi()->iterator();
-      const MYSQL_ERROR *err;
+      List_iterator_fast<MYSQL_ERROR> it(thd->get_stmt_wi()->warn_list());
+      MYSQL_ERROR *err;
       while ((err= it++))
       {
         protocol->prepare_for_resend();

=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2011-06-15 13:13:06 +0000
+++ b/sql/sql_base.cc	2011-06-15 17:01:24 +0000
@@ -182,7 +182,7 @@ static void check_unused(void)
   {
     share= (TABLE_SHARE*) my_hash_element(&table_def_cache, idx);
 
-    TABLE_SHARE::TABLE_list::Iterator it(share->free_tables);
+    I_P_List_iterator<TABLE, TABLE_share> it(share->free_tables);
     while ((entry= it++))
     {
       /* We must not have TABLEs in the free list that have their file closed. */
@@ -857,7 +857,7 @@ OPEN_TABLE_LIST *list_open_tables(THD *t
 		  share->db.str)+1,
 	   share->table_name.str);
     (*start_list)->in_use= 0;
-    TABLE_SHARE::TABLE_list::Iterator it(share->used_tables);
+    I_P_List_iterator<TABLE, TABLE_share> it(share->used_tables);
     while (it++)
       ++(*start_list)->in_use;
     (*start_list)->locked= 0;                   /* Obsolete. */
@@ -938,7 +938,7 @@ void free_io_cache(TABLE *table)
 
 static void kill_delayed_threads_for_table(TABLE_SHARE *share)
 {
-  TABLE_SHARE::TABLE_list::Iterator it(share->used_tables);
+  I_P_List_iterator<TABLE, TABLE_share> it(share->used_tables);
   TABLE *tab;
 
   mysql_mutex_assert_owner(&LOCK_open);
@@ -9015,7 +9015,7 @@ void tdc_remove_table(THD *thd, enum_tdc
   {
     if (share->ref_count)
     {
-      TABLE_SHARE::TABLE_list::Iterator it(share->free_tables);
+      I_P_List_iterator<TABLE, TABLE_share> it(share->free_tables);
 #ifndef DBUG_OFF
       if (remove_type == TDC_RT_REMOVE_ALL)
       {
@@ -9023,7 +9023,7 @@ void tdc_remove_table(THD *thd, enum_tdc
       }
       else if (remove_type == TDC_RT_REMOVE_NOT_OWN)
       {
-        TABLE_SHARE::TABLE_list::Iterator it2(share->used_tables);
+        I_P_List_iterator<TABLE, TABLE_share> it2(share->used_tables);
         while ((table= it2++))
           if (table->in_use != thd)
           {

=== modified file 'sql/sql_error.cc'
--- a/sql/sql_error.cc	2011-06-15 13:13:06 +0000
+++ b/sql/sql_error.cc	2011-06-15 17:01:24 +0000
@@ -499,9 +499,9 @@ Warning_info::~Warning_info()
 void Warning_info::clear_warning_info(ulonglong warn_id_arg)
 {
   m_warn_id= warn_id_arg;
-  m_warn_list.empty();
   free_root(&m_warn_root, MYF(0));
   memset(m_warn_count, 0, sizeof(m_warn_count));
+  m_warn_list.empty();
   m_statement_warn_count= 0;
   m_current_row_for_warning= 1; /* Start counting from the first row */
 }
@@ -559,13 +559,13 @@ MYSQL_ERROR *Warning_info::push_warning(
   if (! m_read_only)
   {
     if (m_allow_unlimited_warnings ||
-        m_warn_list.elements() < thd->variables.max_error_count)
+        m_warn_list.elements < thd->variables.max_error_count)
     {
       cond= new (& m_warn_root) MYSQL_ERROR(& m_warn_root);
       if (cond)
       {
         cond->set(sql_errno, sqlstate, level, msg);
-        m_warn_list.push_back(cond);
+        m_warn_list.push_back(cond, &m_warn_root);
       }
     }
     m_warn_count[(uint) level]++;
@@ -692,7 +692,7 @@ bool mysqld_show_warnings(THD *thd, ulon
                                  Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
     DBUG_RETURN(TRUE);
 
-  const MYSQL_ERROR *err;
+  MYSQL_ERROR *err;
   SELECT_LEX *sel= &thd->lex->select_lex;
   SELECT_LEX_UNIT *unit= &thd->lex->unit;
   ulonglong idx= 0;
@@ -700,7 +700,7 @@ bool mysqld_show_warnings(THD *thd, ulon
 
   unit->set_limit(sel);
 
-  Warning_info::Const_iterator it= thd->get_stmt_wi()->iterator();
+  List_iterator_fast<MYSQL_ERROR> it(thd->get_stmt_wi()->warn_list());
   while ((err= it++))
   {
     /* Skip levels that the user is not interested in */

=== modified file 'sql/sql_error.h'
--- a/sql/sql_error.h	2011-06-15 13:13:06 +0000
+++ b/sql/sql_error.h	2011-06-15 17:01:24 +0000
@@ -19,7 +19,6 @@
 #include "sql_list.h" /* Sql_alloc, MEM_ROOT */
 #include "m_string.h" /* LEX_STRING */
 #include "sql_string.h"                        /* String */
-#include "sql_plist.h" /* I_P_List */
 #include "mysql_com.h" /* MYSQL_ERRMSG_SIZE */
 
 class THD;
@@ -201,24 +200,6 @@ private:
   /** Severity (error, warning, note) of this condition. */
   MYSQL_ERROR::enum_warning_level m_level;
 
-
-  /** Pointers for participating in the list of conditions. */
-  MYSQL_ERROR *next_in_wi;
-  MYSQL_ERROR **prev_in_wi;
-
-  /** Type that provides access to the list pointers. */
-  typedef I_P_List_adapter<MYSQL_ERROR,
-                           &MYSQL_ERROR::next_in_wi,
-                           &MYSQL_ERROR::prev_in_wi>
-          Adapter;
-
-  /** The type of the counted and doubly linked list of conditions. */
-  typedef I_P_List<MYSQL_ERROR,
-                   Adapter,
-                   I_P_List_counter,
-                   I_P_List_fast_push_back<MYSQL_ERROR> >
-          List;
-
   /** Memory root to use to hold condition item values. */
   MEM_ROOT *m_mem_root;
 };
@@ -235,7 +216,7 @@ class Warning_info
   MEM_ROOT           m_warn_root;
 
   /** List of warnings of all severities (levels). */
-  MYSQL_ERROR::List  m_warn_list;
+  List <MYSQL_ERROR> m_warn_list;
 
   /** A break down of the number of warnings per severity (level). */
   uint	             m_warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_END];
@@ -268,15 +249,6 @@ public:
   Warning_info(ulonglong warn_id_arg, bool allow_unlimited_warnings);
   ~Warning_info();
 
-  /** Type of the warning list. */
-  typedef MYSQL_ERROR::List List;
-
-  /** Iterator used to iterate through the warning list. */
-  typedef List::Iterator Iterator;
-
-  /** Const iterator used to iterate through the warning list. */
-  typedef List::Const_Iterator Const_iterator;
-
   /**
     Reset the warning information. Clear all warnings,
     the number of warnings, reset current row counter
@@ -301,17 +273,17 @@ public:
 
   void append_warning_info(THD *thd, Warning_info *source)
   {
-    append_warnings(thd, & source->m_warn_list);
+    append_warnings(thd, & source->warn_list());
   }
 
   /**
     Concatenate the list of warnings.
     It's considered tolerable to lose a warning.
   */
-  void append_warnings(THD *thd, List *src)
+  void append_warnings(THD *thd, List<MYSQL_ERROR> *src)
   {
     MYSQL_ERROR *err;
-    Iterator it(*src);
+    List_iterator_fast<MYSQL_ERROR> it(*src);
     /*
       Don't use ::push_warning() to avoid invocation of condition
       handlers or escalation of warnings to errors.
@@ -339,7 +311,7 @@ public:
   ulong warn_count() const
   {
     /*
-      This may be higher than warn_list.elements() if we have
+      This may be higher than warn_list.elements if we have
       had more warnings than thd->variables.max_error_count.
     */
     return (m_warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_NOTE] +
@@ -348,9 +320,10 @@ public:
   }
 
   /**
-    Returns a const iterator pointing to the beginning of the warning list.
+    This is for iteration purposes. We return a non-constant reference
+    since List doesn't have constant iterators.
   */
-  Const_iterator iterator() const { return m_warn_list; }
+  List<MYSQL_ERROR> &warn_list() { return m_warn_list; }
 
   /**
     The number of errors, or number of rows returned by SHOW ERRORS,
@@ -365,7 +338,7 @@ public:
   ulonglong warn_id() const { return m_warn_id; }
 
   /** Do we have any errors and warnings that we can *show*? */
-  bool is_empty() const { return m_warn_list.is_empty(); }
+  bool is_empty() const { return m_warn_list.elements == 0; }
 
   /** Increment the current row counter to point at the next row. */
   void inc_current_row_for_warning() { m_current_row_for_warning++; }
@@ -571,10 +544,12 @@ private:
 ///////////////////////////////////////////////////////////////////////////
 
 
-void push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level,
-                  uint code, const char *msg);
-void push_warning_printf(THD *thd, MYSQL_ERROR::enum_warning_level level,
-			 uint code, const char *format, ...);
+void raise_warning(THD *thd, uint code, const char *msg, uint flags);
+void raise_warning_printf(THD *thd,
+                          uint code,
+                          const char *format,
+                          uint flags, ...) ATTRIBUTE_FORMAT(3, 4);
+
 bool mysqld_show_warnings(THD *thd, ulong levels_to_show);
 uint32 convert_error_message(char *to, uint32 to_length,
                              const CHARSET_INFO *to_cs,

=== modified file 'sql/sql_plist.h'
--- a/sql/sql_plist.h	2011-06-15 13:13:06 +0000
+++ b/sql/sql_plist.h	2011-06-15 17:01:24 +0000
@@ -1,6 +1,6 @@
 #ifndef SQL_PLIST_H
 #define SQL_PLIST_H
-/* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
 
 #include <my_global.h>
 
-template <typename T, typename L>
+template <typename T, typename B, typename C, typename I>
 class I_P_List_iterator;
 class I_P_List_null_counter;
 template <typename T> class I_P_List_no_push_back;
@@ -142,14 +142,10 @@ public:
       I::set_last(&rhs.m_first);
     C::swap(rhs);
   }
-  typedef B Adapter;
-  typedef I_P_List<T, B, C, I> Base;
-  typedef I_P_List_iterator<T, Base> Iterator;
-  typedef I_P_List_iterator<const T, Base> Const_Iterator;
 #ifndef _lint
-  friend class I_P_List_iterator<T, Base>;
-  friend class I_P_List_iterator<const T, Base>;
+  friend class I_P_List_iterator<T, B, C, I>;
 #endif
+  typedef I_P_List_iterator<T, B, C, I> Iterator;
 };
 
 
@@ -157,17 +153,19 @@ public:
    Iterator for I_P_List.
 */
 
-template <typename T, typename L>
+template <typename T, typename B,
+          typename C = I_P_List_null_counter,
+          typename I = I_P_List_no_push_back<T> >
 class I_P_List_iterator
 {
-  const L *list;
+  const I_P_List<T, B, C, I> *list;
   T *current;
 public:
-  I_P_List_iterator(const L &a)
+  I_P_List_iterator(const I_P_List<T, B, C, I> &a)
     : list(&a), current(a.m_first) {}
-  I_P_List_iterator(const L &a, T* current_arg)
+  I_P_List_iterator(const I_P_List<T, B, C, I> &a, T* current_arg)
     : list(&a), current(current_arg) {}
-  inline void init(const L &a)
+  inline void init(const I_P_List<T, B, C, I> &a)
   {
     list= &a;
     current= a.m_first;
@@ -176,12 +174,12 @@ public:
   {
     T *result= current;
     if (result)
-      current= *L::Adapter::next_ptr(current);
+      current= *B::next_ptr(current);
     return result;
   }
   inline T* operator++()
   {
-    current= *L::Adapter::next_ptr(current);
+    current= *B::next_ptr(current);
     return current;
   }
   inline void rewind()
@@ -200,7 +198,7 @@ template <typename T, T* T::*next, T** T
 struct I_P_List_adapter
 {
   static inline T **next_ptr(T *el) { return &(el->*next); }
-  static inline const T* const* next_ptr(const T *el) { return &(el->*next); }
+
   static inline T ***prev_ptr(T *el) { return &(el->*prev); }
 };
 

=== modified file 'sql/sql_prepare.h'
--- a/sql/sql_prepare.h	2011-06-15 13:13:06 +0000
+++ b/sql/sql_prepare.h	2011-06-15 17:01:24 +0000
@@ -254,6 +254,15 @@ public:
   {
     return m_diagnostics_area.get_warning_info()->warn_count();
   }
+  /**
+    Get the server warnings as a result set.
+    The result set has fixed metadata:
+    The first column is the level.
+    The second is a numeric code.
+    The third is warning text.
+  */
+  List<MYSQL_ERROR> *get_warn_list()
+  { return &m_diagnostics_area.get_warning_info()->warn_list(); }
 
   /**
     The following members are only valid if execute_direct()

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2011-06-15 13:13:06 +0000
+++ b/sql/sql_show.cc	2011-06-15 17:01:24 +0000
@@ -6830,8 +6830,9 @@ static bool do_fill_table(THD *thd,
   // Filter out warnings with WARN_LEVEL_ERROR level, because they
   // correspond to the errors which were filtered out in fill_table().
 
-  Warning_info::Const_iterator it= wi_tmp.iterator();
-  const MYSQL_ERROR *err;
+
+  List_iterator_fast<MYSQL_ERROR> it(wi_tmp.warn_list());
+  MYSQL_ERROR *err;
 
   while ((err= it++))
   {

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2011-06-15 13:13:06 +0000
+++ b/sql/sql_table.cc	2011-06-15 17:01:24 +0000
@@ -2942,8 +2942,8 @@ const CHARSET_INFO* get_sql_field_charse
 
 bool check_duplicate_warning(THD *thd, char *msg, ulong length)
 {
-  Warning_info::Const_iterator it= thd->get_stmt_wi()->iterator();
-  const MYSQL_ERROR *err;
+  List_iterator_fast<MYSQL_ERROR> it(thd->get_stmt_wi()->warn_list());
+  MYSQL_ERROR *err;
   while ((err= it++))
   {
     if (strncmp(msg, err->get_message_text(), length) == 0)

=== modified file 'sql/sql_test.cc'
--- a/sql/sql_test.cc	2011-06-15 13:13:06 +0000
+++ b/sql/sql_test.cc	2011-06-15 17:01:24 +0000
@@ -91,7 +91,7 @@ static void print_cached_tables(void)
   {
     share= (TABLE_SHARE*) my_hash_element(&table_def_cache, idx);
 
-    TABLE_SHARE::TABLE_list::Iterator it(share->used_tables);
+    I_P_List_iterator<TABLE, TABLE_share> it(share->used_tables);
     while ((entry= it++))
     {
       printf("%-14.14s %-32s%6ld%8ld%6d  %s\n",

=== modified file 'sql/table.cc'
--- a/sql/table.cc	2011-06-15 13:13:06 +0000
+++ b/sql/table.cc	2011-06-15 17:01:24 +0000
@@ -3215,7 +3215,7 @@ bool TABLE_SHARE::visit_subgraph(Wait_fo
   if (gvisitor->m_lock_open_count++ == 0)
     mysql_mutex_lock(&LOCK_open);
 
-  TABLE_SHARE::TABLE_list::Iterator tables_it(used_tables);
+  I_P_List_iterator <TABLE, TABLE_share> tables_it(used_tables);
 
   /*
     In case of multiple searches running in parallel, avoid going

=== modified file 'sql/table.h'
--- a/sql/table.h	2011-06-15 13:13:06 +0000
+++ b/sql/table.h	2011-06-15 17:01:24 +0000
@@ -600,9 +600,8 @@ struct TABLE_SHARE
     Doubly-linked (back-linked) lists of used and unused TABLE objects
     for this share.
   */
-  typedef I_P_List <TABLE, TABLE_share> TABLE_list;
-  TABLE_list used_tables;
-  TABLE_list free_tables;
+  I_P_List <TABLE, TABLE_share> used_tables;
+  I_P_List <TABLE, TABLE_share> free_tables;
 
   /* The following is copied to each TABLE on OPEN */
   Field **field;


Attachment: [text/bzr-bundle] bzr/davi.arnaut@oracle.com-20110615170124-5qjvs03rvsh3xehg.bundle
Thread
bzr commit into mysql-trunk branch (davi:3206) Davi Arnaut16 Jun