List:Commits« Previous MessageNext Message »
From:Alexander Nozdrin Date:June 9 2011 8:58am
Subject:bzr push into mysql-trunk branch (alexander.nozdrin:3169 to 3170)
Bug#11763162
View as plain text  
 3170 Alexander Nozdrin	2011-06-09
      Pre-requisite patch for Bug#11763162 (55843 - Handled condition
      appears as not handled).
      
      Make THD::stmt_da and THD::warning_info private,
      and provide getters/setters for them:
        - THD::get_stmt_da()
        - THD::set_stmt_da()
        - THD::get_warning_info()
        - THD::set_warning_info()

    modified:
      libmysqld/emb_qcache.cc
      libmysqld/lib_sql.cc
      sql/binlog.cc
      sql/event_scheduler.cc
      sql/field.cc
      sql/filesort.cc
      sql/ha_ndbcluster_binlog.cc
      sql/handler.cc
      sql/log_event.cc
      sql/log_event_old.cc
      sql/opt_sum.cc
      sql/protocol.cc
      sql/rpl_master.cc
      sql/rpl_reporting.cc
      sql/rpl_rli.cc
      sql/rpl_slave.cc
      sql/sp.cc
      sql/sp_head.cc
      sql/sql_acl.cc
      sql/sql_admin.cc
      sql/sql_alloc_error_handler.cc
      sql/sql_audit.h
      sql/sql_base.cc
      sql/sql_cache.cc
      sql/sql_class.cc
      sql/sql_class.h
      sql/sql_connect.cc
      sql/sql_derived.cc
      sql/sql_error.cc
      sql/sql_insert.cc
      sql/sql_load.cc
      sql/sql_parse.cc
      sql/sql_prepare.cc
      sql/sql_select.cc
      sql/sql_servers.cc
      sql/sql_show.cc
      sql/sql_signal.cc
      sql/sql_table.cc
      sql/sql_time.cc
      sql/sql_update.cc
      sql/sys_vars.cc
      sql/table.cc
      sql/transaction.cc
      sql/tztime.cc
 3169 Olav Sandstaa	2011-06-09
      Fix for bug Bug#12355958 "FAILING ASSERTION: TRX->LOCK.N_ACTIVE_THRS == 1".
      
      The assert that crashes in InnoDB is caused by the ICP code pushing
      down an index condition that contains a subquery. When InnoDB
      evaluates this index condition the subquery is executed and this results in
      a second access to data in InnoDB. InnoDB does not allow a transaction
      to have more than one concurrent executing table operation and this 
      causes the assert to trigger.
      
      The ICP code should not have pushed down this index condition to InnoDB
      since it contains a subquery. The existing ICP code checks for subqueries in
      the condition by checking the value of the condition's with_subselect
      member. In this case the value for the Item_func condition's with_subselect
      is false even though one of the arguments for the Item_func is a subquery.
      This situation can occur when we initially create the item tree
      for a condition and then later substitutes non-subquery parts of it
      with a subquery. In the test case for this bug this occurs when
      optimize_conds() replaces a field reference with a subquery due to the
      subquery will be const when it is evaluated. This replacement is done
      without updating the Item_func node's with_subselect to true.
      
      The fix for this would be easy if it was possible to update the 
      with_subselect member locally when doing changes. What makes this
      more complex is that this information needs to be propagated 
      upwards in the item tree. Since we have no "parent reference" in
      the item tree this can not be done locally. In order to be able
      to propagate this information upwards in the item tree this patch
      extends Item::update_used_tables() to also update
      the value of with_subselect when traversing the item tree.
     @ mysql-test/include/icp_tests.inc
        Test for Bug#12355958 "FAILING ASSERTION: TRX->LOCK.N_ACTIVE_THRS == 1".
     @ mysql-test/r/innodb_icp.result
        Test for Bug#12355958 "FAILING ASSERTION: TRX->LOCK.N_ACTIVE_THRS == 1".
     @ mysql-test/r/innodb_icp_all.result
        Test for Bug#12355958 "FAILING ASSERTION: TRX->LOCK.N_ACTIVE_THRS == 1".
     @ mysql-test/r/innodb_icp_none.result
        Test for Bug#12355958 "FAILING ASSERTION: TRX->LOCK.N_ACTIVE_THRS == 1".
     @ mysql-test/r/myisam_icp.result
        Test for Bug#12355958 "FAILING ASSERTION: TRX->LOCK.N_ACTIVE_THRS == 1".
     @ mysql-test/r/myisam_icp_all.result
        Test for Bug#12355958 "FAILING ASSERTION: TRX->LOCK.N_ACTIVE_THRS == 1".
     @ mysql-test/r/myisam_icp_none.result
        Test for Bug#12355958 "FAILING ASSERTION: TRX->LOCK.N_ACTIVE_THRS == 1".
     @ sql/item.h
        Add Item_ref::has_subquery() that calls has_subquery() on the
        item it has a ref pointer to.
     @ sql/item_cmpfunc.cc
        Extend Item_cond::update_used_tables(), 
        Item_is_not_null_test::update_used_tables(), and 
        Item_equal::update_used_tables() to update its value
        for with_subselect based on the value in its arguments.
     @ sql/item_cmpfunc.h
        Extend Item_func_isnull::update_used_tables() to propagate
        the value of with_subselect in the item tree.
     @ sql/item_func.cc
        Extend Item_func::update_used_tables() to update its value
        for with_subselect based on the value in its arguments.
     @ sql/item_row.cc
        Extend Item_row::update_used_tables() to update its value
        for with_subselect based on the value in its arguments.
     @ sql/item_strfunc.cc
        Extend Item_func_make_set::update_used_tables() to update its 
        value for with_subselect based on the value in its item object.
     @ sql/item_sum.cc
        Extend Item_sum::update_used_tables() to update its value
        for with_subselect based on the value in its arguments.

    modified:
      mysql-test/include/icp_tests.inc
      mysql-test/r/innodb_icp.result
      mysql-test/r/innodb_icp_all.result
      mysql-test/r/innodb_icp_none.result
      mysql-test/r/myisam_icp.result
      mysql-test/r/myisam_icp_all.result
      mysql-test/r/myisam_icp_none.result
      sql/item.h
      sql/item_cmpfunc.cc
      sql/item_cmpfunc.h
      sql/item_func.cc
      sql/item_row.cc
      sql/item_strfunc.cc
      sql/item_sum.cc
=== modified file 'libmysqld/emb_qcache.cc'
--- a/libmysqld/emb_qcache.cc	2010-03-31 14:05:33 +0000
+++ b/libmysqld/emb_qcache.cc	2011-06-09 08:58:41 +0000
@@ -487,7 +487,7 @@ int emb_load_querycache_result(THD *thd,
   data->embedded_info->prev_ptr= prev_row;
 return_ok:
   net_send_eof(thd, thd->server_status,
-               thd->warning_info->statement_warn_count());
+               thd->get_warning_info()->statement_warn_count());
   DBUG_RETURN(0);
 err:
   DBUG_RETURN(1);

=== modified file 'libmysqld/lib_sql.cc'
--- a/libmysqld/lib_sql.cc	2011-05-26 15:20:09 +0000
+++ b/libmysqld/lib_sql.cc	2011-06-09 08:58:41 +0000
@@ -130,7 +130,7 @@ emb_advanced_command(MYSQL *mysql, enum
 
   /* Clear result variables */
   thd->clear_error();
-  thd->stmt_da->reset_diagnostics_area();
+  thd->get_stmt_da()->reset_diagnostics_area();
   mysql->affected_rows= ~(my_ulonglong) 0;
   mysql->field_count= 0;
   net_clear_error(net);
@@ -241,7 +241,7 @@ static my_bool emb_read_prepare_result(M
   stmt->stmt_id= thd->client_stmt_id;
   stmt->param_count= thd->client_param_count;
   stmt->field_count= 0;
-  mysql->warning_count= thd->warning_info->statement_warn_count();
+  mysql->warning_count= thd->get_warning_info()->statement_warn_count();
 
   if (thd->first_data)
   {
@@ -426,7 +426,7 @@ static void emb_free_embedded_thd(MYSQL
 static const char * emb_read_statistics(MYSQL *mysql)
 {
   THD *thd= (THD*)mysql->thd;
-  return thd->is_error() ? thd->stmt_da->message() : "";
+  return thd->is_error() ? thd->get_stmt_da()->message() : "";
 }
 
 
@@ -1047,7 +1047,7 @@ bool Protocol::send_result_set_metadata(
 
   if (flags & SEND_EOF)
     write_eof_packet(thd, thd->server_status,
-                     thd->warning_info->statement_warn_count());
+                     thd->get_warning_info()->statement_warn_count());
 
   DBUG_RETURN(prepare_for_send(list->elements));
  err:

=== modified file 'sql/binlog.cc'
--- a/sql/binlog.cc	2011-05-30 06:25:47 +0000
+++ b/sql/binlog.cc	2011-06-09 08:58:41 +0000
@@ -1261,9 +1261,9 @@ int query_error_code(THD *thd, bool not_
   
   if (not_killed || (thd->killed == THD::KILL_BAD_DATA))
   {
-    error= thd->is_error() ? thd->stmt_da->sql_errno() : 0;
+    error= thd->is_error() ? thd->get_stmt_da()->sql_errno() : 0;
 
-    /* thd->stmt_da->sql_errno() might be ER_SERVER_SHUTDOWN or
+    /* thd->get_stmt_da()->sql_errno() might be ER_SERVER_SHUTDOWN or
        ER_QUERY_INTERRUPTED, So here we need to make sure that error
        is not set to these errors when specified not_killed by the
        caller.
@@ -2087,7 +2087,7 @@ bool MYSQL_BIN_LOG::check_write_error(TH
   if (!thd->is_error())
     DBUG_RETURN(checked);
 
-  switch (thd->stmt_da->sql_errno())
+  switch (thd->get_stmt_da()->sql_errno())
   {
     case ER_TRANS_CACHE_FULL:
     case ER_STMT_CACHE_FULL:

=== modified file 'sql/event_scheduler.cc'
--- a/sql/event_scheduler.cc	2010-07-23 19:03:52 +0000
+++ b/sql/event_scheduler.cc	2011-06-09 08:58:41 +0000
@@ -77,7 +77,7 @@ Event_worker_thread::print_warnings(THD
 {
   MYSQL_ERROR *err;
   DBUG_ENTER("evex_print_warnings");
-  if (thd->warning_info->is_empty())
+  if (thd->get_warning_info()->is_empty())
     DBUG_VOID_RETURN;
 
   char msg_buf[10 * STRING_BUFFER_USUAL_SIZE];
@@ -93,7 +93,7 @@ Event_worker_thread::print_warnings(THD
   prefix.append(et->name.str, et->name.length, system_charset_info);
   prefix.append("] ", 2);
 
-  List_iterator_fast<MYSQL_ERROR> it(thd->warning_info->warn_list());
+  List_iterator_fast<MYSQL_ERROR> it(thd->get_warning_info()->warn_list());
   while ((err= it++))
   {
     String err_msg(msg_buf, sizeof(msg_buf), system_charset_info);

=== modified file 'sql/field.cc'
--- a/sql/field.cc	2011-05-26 15:20:09 +0000
+++ b/sql/field.cc	2011-06-09 08:58:41 +0000
@@ -1163,7 +1163,8 @@ int Field_num::check_int(const CHARSET_I
                         ER_TRUNCATED_WRONG_VALUE_FOR_FIELD, 
                         ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD),
                         "integer", err.ptr(), field_name,
-                        (ulong) table->in_use->warning_info->current_row_for_warning());
+                        (ulong) table->in_use->get_warning_info()->
+                        current_row_for_warning());
     return 1;
   }
   /* Test if we have garbage at the end of the given string. */
@@ -2648,7 +2649,8 @@ int Field_new_decimal::store(const char
                         ER_TRUNCATED_WRONG_VALUE_FOR_FIELD,
                         ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD),
                         "decimal", errmsg.ptr(), field_name,
-                        (ulong) table->in_use->warning_info->current_row_for_warning());
+                        (ulong) table->in_use->get_warning_info()->
+                        current_row_for_warning());
 
     DBUG_RETURN(err);
   }
@@ -2668,7 +2670,7 @@ int Field_new_decimal::store(const char
                           ER_TRUNCATED_WRONG_VALUE_FOR_FIELD,
                           ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD),
                           "decimal", errmsg.ptr(), field_name,
-                          (ulong) table->in_use->warning_info->
+                          (ulong) table->in_use->get_warning_info()->
                           current_row_for_warning());
       my_decimal_set_zero(&decimal_value);
       break;
@@ -5231,7 +5233,7 @@ bool Field_time::get_date(MYSQL_TIME *lt
     push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
                         ER_WARN_DATA_OUT_OF_RANGE,
                         ER(ER_WARN_DATA_OUT_OF_RANGE), field_name,
-                        thd->warning_info->current_row_for_warning());
+                        thd->get_warning_info()->current_row_for_warning());
     return 1;
   }
   return Field_time::get_time(ltime);
@@ -6230,7 +6232,7 @@ check_string_copy_error(Field_str *field
                       ER_TRUNCATED_WRONG_VALUE_FOR_FIELD,
                       ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD),
                       "string", tmp, field->field_name,
-                      thd->warning_info->current_row_for_warning());
+                      thd->get_warning_info()->current_row_for_warning());
   return TRUE;
 }
 
@@ -10078,7 +10080,7 @@ Field::set_warning(MYSQL_ERROR::enum_war
   {
     thd->cuted_fields+= cuted_increment;
     push_warning_printf(thd, level, code, ER(code), field_name,
-                        thd->warning_info->current_row_for_warning());
+                        thd->get_warning_info()->current_row_for_warning());
     return 0;
   }
   return level >= MYSQL_ERROR::WARN_LEVEL_WARN;

=== modified file 'sql/filesort.cc'
--- a/sql/filesort.cc	2011-05-26 15:20:09 +0000
+++ b/sql/filesort.cc	2011-06-09 08:58:41 +0000
@@ -361,8 +361,10 @@ ha_rows filesort(THD *thd, TABLE *table,
                     "%s: %s",
                     MYF(ME_ERROR + ME_WAITTANG),
                     ER_THD(thd, ER_FILSORT_ABORT),
-                    kill_errno ? ER(kill_errno) : thd->stmt_da->message());
-                    
+                    kill_errno ?
+                    ER(kill_errno) :
+                    thd->get_stmt_da()->message());
+
     if (global_system_variables.log_warnings > 1)
     {
       sql_print_warning("%s, host: %s, user: %s, thread: %lu, query: %-.4096s",

=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc	2011-05-26 15:20:09 +0000
+++ b/sql/ha_ndbcluster_binlog.cc	2011-06-09 08:58:41 +0000
@@ -288,13 +288,13 @@ static void run_query(THD *thd, char *bu
     Thd_ndb *thd_ndb= get_thd_ndb(thd);
     for (i= 0; no_print_error[i]; i++)
       if ((thd_ndb->m_error_code == no_print_error[i]) ||
-          (thd->stmt_da->sql_errno() == (unsigned) no_print_error[i]))
+          (thd->get_stmt_da()->sql_errno() == (unsigned) no_print_error[i]))
         break;
     if (!no_print_error[i])
       sql_print_error("NDB: %s: error %s %d(ndb: %d) %d %d",
                       buf,
-                      thd->stmt_da->message(),
-                      thd->stmt_da->sql_errno(),
+                      thd->get_stmt_da()->message(),
+                      thd->get_stmt_da()->sql_errno(),
                       thd_ndb->m_error_code,
                       (int) thd->is_error(), thd->is_slave_error);
   }
@@ -308,7 +308,7 @@ static void run_query(THD *thd, char *bu
     is called from ndbcluster_reset_logs(), which is called from
     mysql_flush().
   */
-  thd->stmt_da->reset_diagnostics_area();
+  thd->get_stmt_da()->reset_diagnostics_area();
 
   thd->variables.option_bits= save_thd_options;
   thd->set_query(save_thd_query, save_thd_query_length);
@@ -982,7 +982,7 @@ static void print_could_not_discover_err
                   "my_errno: %d",
                    schema->db, schema->name, schema->query,
                    schema->node_id, my_errno);
-  List_iterator_fast<MYSQL_ERROR> it(thd->warning_info->warn_list());
+  List_iterator_fast<MYSQL_ERROR> it(thd->get_warning_info()->warn_list());
   MYSQL_ERROR *err;
   while ((err= it++))
     sql_print_warning("NDB Binlog: (%d)%s", err->get_sql_errno(),
@@ -2338,8 +2338,8 @@ static int open_ndb_binlog_index(THD *th
       sql_print_error("NDB Binlog: Opening ndb_binlog_index: killed");
     else
       sql_print_error("NDB Binlog: Opening ndb_binlog_index: %d, '%s'",
-                      thd->stmt_da->sql_errno(),
-                      thd->stmt_da->message());
+                      thd->get_stmt_da()->sql_errno(),
+                      thd->get_stmt_da()->message());
     thd->proc_info= save_proc_info;
     return -1;
   }
@@ -2395,9 +2395,9 @@ int ndb_add_ndb_binlog_index(THD *thd, v
   }
 
 add_ndb_binlog_index_err:
-  thd->stmt_da->can_overwrite_status= TRUE;
+  thd->get_stmt_da()->can_overwrite_status= TRUE;
   thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd);
-  thd->stmt_da->can_overwrite_status= FALSE;
+  thd->get_stmt_da()->can_overwrite_status= FALSE;
   close_thread_tables(thd);
   thd->mdl_context.release_transactional_locks();
   ndb_binlog_index= 0;
@@ -4266,9 +4266,9 @@ err:
   sql_print_information("Stopping Cluster Binlog");
   DBUG_PRINT("info",("Shutting down cluster binlog thread"));
   thd->proc_info= "Shutting down";
-  thd->stmt_da->can_overwrite_status= TRUE;
+  thd->get_stmt_da()->can_overwrite_status= TRUE;
   thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd);
-  thd->stmt_da->can_overwrite_status= FALSE;
+  thd->get_stmt_da()->can_overwrite_status= FALSE;
   close_thread_tables(thd);
   thd->mdl_context.release_transactional_locks();
   mysql_mutex_lock(&injector_mutex);

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2011-05-31 09:30:59 +0000
+++ b/sql/handler.cc	2011-06-09 08:58:41 +0000
@@ -1402,7 +1402,7 @@ int ha_rollback_trans(THD *thd, bool all
     trans->no_2pc=0;
     if (is_real_trans && thd->transaction_rollback_request &&
         thd->transaction.xid_state.xa_state != XA_NOTR)
-      thd->transaction.xid_state.rm_error= thd->stmt_da->sql_errno();
+      thd->transaction.xid_state.rm_error= thd->get_stmt_da()->sql_errno();
   }
   /* Always cleanup. Even if nht==0. There may be savepoints. */
   if (is_real_trans)

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2011-05-30 06:25:47 +0000
+++ b/sql/log_event.cc	2011-06-09 08:58:41 +0000
@@ -208,7 +208,7 @@ static void inline slave_rows_error_repo
   char buff[MAX_SLAVE_ERRMSG], *slider;
   const char *buff_end= buff + sizeof(buff);
   uint len;
-  List_iterator_fast<MYSQL_ERROR> it(thd->warning_info->warn_list());
+  List_iterator_fast<MYSQL_ERROR> it(thd->get_warning_info()->warn_list());
   MYSQL_ERROR *err;
   buff[0]= 0;
 
@@ -221,7 +221,7 @@ static void inline slave_rows_error_repo
   }
 
   if (ha_error != 0)
-    rli->report(level, thd->is_error() ? thd->stmt_da->sql_errno() : 0,
+    rli->report(level, thd->is_error() ? thd->get_stmt_da()->sql_errno() : 0,
                 "Could not execute %s event on table %s.%s;"
                 "%s handler error %s; "
                 "the event's master log %s, end_log_pos %lu",
@@ -229,7 +229,7 @@ static void inline slave_rows_error_repo
                 buff, handler_error == NULL ? "<unknown>" : handler_error,
                 log_name, pos);
   else
-    rli->report(level, thd->is_error() ? thd->stmt_da->sql_errno() : 0,
+    rli->report(level, thd->is_error() ? thd->get_stmt_da()->sql_errno() : 0,
                 "Could not execute %s event on table %s.%s;"
                 "%s the event's master log %s, end_log_pos %lu",
                 type, table->s->db.str, table->s->table_name.str,
@@ -372,13 +372,13 @@ inline int ignored_error_code(int err_co
 */ 
 int convert_handler_error(int error, THD* thd, TABLE *table)
 {
-  uint actual_error= (thd->is_error() ? thd->stmt_da->sql_errno() :
+  uint actual_error= (thd->is_error() ? thd->get_stmt_da()->sql_errno() :
                            0);
 
   if (actual_error == 0)
   {
     table->file->print_error(error, MYF(0));
-    actual_error= (thd->is_error() ? thd->stmt_da->sql_errno() :
+    actual_error= (thd->is_error() ? thd->get_stmt_da()->sql_errno() :
                         ER_UNKNOWN_ERROR);
     if (actual_error == ER_UNKNOWN_ERROR)
       if (global_system_variables.log_warnings)
@@ -3760,7 +3760,7 @@ START SLAVE; . Query: '%s'", expected_er
     }
 
     /* If the query was not ignored, it is printed to the general log */
-    if (!thd->is_error() || thd->stmt_da->sql_errno() != ER_SLAVE_IGNORED_TABLE)
+    if (!thd->is_error() || thd->get_stmt_da()->sql_errno() != ER_SLAVE_IGNORED_TABLE)
       general_log_write(thd, COM_QUERY, thd->query(), thd->query_length());
 
 compare_errors:
@@ -3772,14 +3772,14 @@ compare_errors:
       not exist errors", we silently clear the error if TEMPORARY was used.
     */
     if (thd->lex->sql_command == SQLCOM_DROP_TABLE && thd->lex->drop_temporary &&
-        thd->is_error() && thd->stmt_da->sql_errno() == ER_BAD_TABLE_ERROR &&
+        thd->is_error() && thd->get_stmt_da()->sql_errno() == ER_BAD_TABLE_ERROR &&
         !expected_error)
-      thd->stmt_da->reset_diagnostics_area();
+      thd->get_stmt_da()->reset_diagnostics_area();
     /*
       If we expected a non-zero error code, and we don't get the same error
       code, and it should be ignored or is related to a concurrency issue.
     */
-    actual_error= thd->is_error() ? thd->stmt_da->sql_errno() : 0;
+    actual_error= thd->is_error() ? thd->get_stmt_da()->sql_errno() : 0;
     DBUG_PRINT("info",("expected_error: %d  sql_errno: %d",
                        expected_error, actual_error));
 
@@ -3796,7 +3796,7 @@ Error on slave: actual message='%s', err
 Default database: '%s'. Query: '%s'",
                       ER_SAFE(expected_error),
                       expected_error,
-                      actual_error ? thd->stmt_da->message() : "no error",
+                      actual_error ? thd->get_stmt_da()->message() : "no error",
                       actual_error,
                       print_slave_db_safe(db), query_arg);
       thd->is_slave_error= 1;
@@ -3820,7 +3820,7 @@ Default database: '%s'. Query: '%s'",
     {
       rli->report(ERROR_LEVEL, actual_error,
                       "Error '%s' on query. Default database: '%s'. Query: '%s'",
-                      (actual_error ? thd->stmt_da->message() :
+                      (actual_error ? thd->get_stmt_da()->message() :
                        "unexpected success or fatal error"),
                       print_slave_db_safe(thd->db), query_arg);
       thd->is_slave_error= 1;
@@ -5300,7 +5300,7 @@ int Load_log_event::do_apply_event(NET*
   {
     thd->set_time((time_t)when);
     thd->set_query_id(next_query_id());
-    thd->warning_info->opt_clear_warning_info(thd->query_id);
+    thd->get_warning_info()->opt_clear_warning_info(thd->query_id);
 
     TABLE_LIST tables;
     char table_buf[NAME_LEN + 1];
@@ -5450,9 +5450,9 @@ error:
   thd->catalog= 0;
   thd->set_db(NULL, 0);                   /* will free the current database */
   thd->reset_query();
-  thd->stmt_da->can_overwrite_status= TRUE;
+  thd->get_stmt_da()->can_overwrite_status= TRUE;
   thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd);
-  thd->stmt_da->can_overwrite_status= FALSE;
+  thd->get_stmt_da()->can_overwrite_status= FALSE;
   close_thread_tables(thd);
   /*
     - If inside a multi-statement transaction,
@@ -5479,8 +5479,8 @@ error:
     int sql_errno;
     if (thd->is_error())
     {
-      err= thd->stmt_da->message();
-      sql_errno= thd->stmt_da->sql_errno();
+      err= thd->get_stmt_da()->message();
+      sql_errno= thd->get_stmt_da()->sql_errno();
     }
     else
     {
@@ -8046,7 +8046,7 @@ int Rows_log_event::do_apply_event(Relay
 
     if (open_and_lock_tables(thd, rli->tables_to_lock, FALSE, 0))
     {
-      uint actual_error= thd->stmt_da->sql_errno();
+      uint actual_error= thd->get_stmt_da()->sql_errno();
       if (thd->is_slave_error || thd->is_fatal_error)
       {
         /*
@@ -8057,7 +8057,7 @@ int Rows_log_event::do_apply_event(Relay
         */
         rli->report(ERROR_LEVEL, actual_error,
                     "Error executing row event: '%s'",
-                    (actual_error ? thd->stmt_da->message() :
+                    (actual_error ? thd->get_stmt_da()->message() :
                      "unexpected success or fatal error"));
         thd->is_slave_error= 1;
       }

=== modified file 'sql/log_event_old.cc'
--- a/sql/log_event_old.cc	2011-05-12 21:51:20 +0000
+++ b/sql/log_event_old.cc	2011-06-09 08:58:41 +0000
@@ -99,7 +99,7 @@ Old_rows_log_event::do_apply_event(Old_r
 
     if (open_and_lock_tables(ev_thd, rli->tables_to_lock, FALSE, 0))
     {
-      uint actual_error= ev_thd->stmt_da->sql_errno();
+      uint actual_error= ev_thd->get_stmt_da()->sql_errno();
       if (ev_thd->is_slave_error || ev_thd->is_fatal_error)
       {
         /*
@@ -108,7 +108,7 @@ Old_rows_log_event::do_apply_event(Old_r
         */
         rli->report(ERROR_LEVEL, actual_error,
                     "Error '%s' on opening tables",
-                    (actual_error ? ev_thd->stmt_da->message() :
+                    (actual_error ? ev_thd->get_stmt_da()->message() :
                      "unexpected success or fatal error"));
         ev_thd->is_slave_error= 1;
       }
@@ -242,10 +242,10 @@ Old_rows_log_event::do_apply_event(Old_r
   break;
 
       default:
-  rli->report(ERROR_LEVEL, ev_thd->stmt_da->sql_errno(),
+  rli->report(ERROR_LEVEL, ev_thd->get_stmt_da()->sql_errno(),
                     "Error in %s event: row application failed. %s",
                     ev->get_type_str(),
-                    ev_thd->is_error() ? ev_thd->stmt_da->message() : "");
+                    ev_thd->is_error() ? ev_thd->get_stmt_da()->message() : "");
   thd->is_slave_error= 1;
   break;
       }
@@ -259,12 +259,12 @@ Old_rows_log_event::do_apply_event(Old_r
 
   if (error)
   {                     /* error has occured during the transaction */
-    rli->report(ERROR_LEVEL, ev_thd->stmt_da->sql_errno(),
+    rli->report(ERROR_LEVEL, ev_thd->get_stmt_da()->sql_errno(),
                 "Error in %s event: error during transaction execution "
                 "on table %s.%s. %s",
                 ev->get_type_str(), table->s->db.str,
                 table->s->table_name.str,
-                ev_thd->is_error() ? ev_thd->stmt_da->message() : "");
+                ev_thd->is_error() ? ev_thd->get_stmt_da()->message() : "");
 
     /*
       If one day we honour --skip-slave-errors in row-based replication, and

=== modified file 'sql/opt_sum.cc'
--- a/sql/opt_sum.cc	2011-04-15 08:11:49 +0000
+++ b/sql/opt_sum.cc	2011-06-09 08:58:41 +0000
@@ -450,7 +450,7 @@ int opt_sum_query(THD *thd,
   }
 
   if (thd->is_error())
-    DBUG_RETURN(thd->stmt_da->sql_errno());
+    DBUG_RETURN(thd->get_stmt_da()->sql_errno());
 
   /*
     If we have a where clause, we can only ignore searching in the

=== modified file 'sql/protocol.cc'
--- a/sql/protocol.cc	2011-05-26 15:20:09 +0000
+++ b/sql/protocol.cc	2011-06-09 08:58:41 +0000
@@ -158,14 +158,14 @@ bool net_send_error(THD *thd, uint sql_e
     It's one case when we can push an error even though there
     is an OK or EOF already.
   */
-  thd->stmt_da->can_overwrite_status= TRUE;
+  thd->get_stmt_da()->can_overwrite_status= TRUE;
 
   /* Abort multi-result sets */
   thd->server_status&= ~SERVER_MORE_RESULTS_EXISTS;
 
   error= net_send_error_packet(thd, sql_errno, err, sqlstate);
 
-  thd->stmt_da->can_overwrite_status= FALSE;
+  thd->get_stmt_da()->can_overwrite_status= FALSE;
 
   DBUG_RETURN(error);
 }
@@ -239,7 +239,7 @@ net_send_ok(THD *thd,
     int2store(pos, server_status);
     pos+=2;
   }
-  thd->stmt_da->can_overwrite_status= TRUE;
+  thd->get_stmt_da()->can_overwrite_status= TRUE;
 
   if (message && message[0])
     pos= net_store_data(pos, (uchar*) message, strlen(message));
@@ -248,7 +248,7 @@ net_send_ok(THD *thd,
     error= net_flush(net);
 
 
-  thd->stmt_da->can_overwrite_status= FALSE;
+  thd->get_stmt_da()->can_overwrite_status= FALSE;
   DBUG_PRINT("info", ("OK sent, so no more error sending allowed"));
 
   DBUG_RETURN(error);
@@ -288,11 +288,11 @@ net_send_eof(THD *thd, uint server_statu
   /* Set to TRUE if no active vio, to work well in case of --init-file */
   if (net->vio != 0)
   {
-    thd->stmt_da->can_overwrite_status= TRUE;
+    thd->get_stmt_da()->can_overwrite_status= TRUE;
     error= write_eof_packet(thd, net, server_status, statement_warn_count);
     if (!error)
       error= net_flush(net);
-    thd->stmt_da->can_overwrite_status= FALSE;
+    thd->get_stmt_da()->can_overwrite_status= FALSE;
     DBUG_PRINT("info", ("EOF sent, so no more error sending allowed"));
   }
   DBUG_RETURN(error);
@@ -487,30 +487,30 @@ static uchar *net_store_length_fast(ucha
 void Protocol::end_statement()
 {
   DBUG_ENTER("Protocol::end_statement");
-  DBUG_ASSERT(! thd->stmt_da->is_sent);
+  DBUG_ASSERT(! thd->get_stmt_da()->is_sent);
   bool error= FALSE;
 
   /* Can not be true, but do not take chances in production. */
-  if (thd->stmt_da->is_sent)
+  if (thd->get_stmt_da()->is_sent)
     DBUG_VOID_RETURN;
 
-  switch (thd->stmt_da->status()) {
+  switch (thd->get_stmt_da()->status()) {
   case Diagnostics_area::DA_ERROR:
     /* The query failed, send error to log and abort bootstrap. */
-    error= send_error(thd->stmt_da->sql_errno(),
-                      thd->stmt_da->message(),
-                      thd->stmt_da->get_sqlstate());
+    error= send_error(thd->get_stmt_da()->sql_errno(),
+                      thd->get_stmt_da()->message(),
+                      thd->get_stmt_da()->get_sqlstate());
     break;
   case Diagnostics_area::DA_EOF:
     error= send_eof(thd->server_status,
-                    thd->stmt_da->statement_warn_count());
+                    thd->get_stmt_da()->statement_warn_count());
     break;
   case Diagnostics_area::DA_OK:
     error= send_ok(thd->server_status,
-                   thd->stmt_da->statement_warn_count(),
-                   thd->stmt_da->affected_rows(),
-                   thd->stmt_da->last_insert_id(),
-                   thd->stmt_da->message());
+                   thd->get_stmt_da()->statement_warn_count(),
+                   thd->get_stmt_da()->affected_rows(),
+                   thd->get_stmt_da()->last_insert_id(),
+                   thd->get_stmt_da()->message());
     break;
   case Diagnostics_area::DA_DISABLED:
     break;
@@ -521,7 +521,7 @@ void Protocol::end_statement()
     break;
   }
   if (!error)
-    thd->stmt_da->is_sent= TRUE;
+    thd->get_stmt_da()->is_sent= TRUE;
   DBUG_VOID_RETURN;
 }
 
@@ -639,9 +639,9 @@ bool Protocol::flush()
 {
 #ifndef EMBEDDED_LIBRARY
   bool error;
-  thd->stmt_da->can_overwrite_status= TRUE;
+  thd->get_stmt_da()->can_overwrite_status= TRUE;
   error= net_flush(&thd->net);
-  thd->stmt_da->can_overwrite_status= FALSE;
+  thd->get_stmt_da()->can_overwrite_status= FALSE;
   return error;
 #else
   return 0;
@@ -802,7 +802,7 @@ bool Protocol::send_result_set_metadata(
       Send no warning information, as it will be sent at statement end.
     */
     if (write_eof_packet(thd, &thd->net, thd->server_status,
-                         thd->warning_info->statement_warn_count()))
+                         thd->get_warning_info()->statement_warn_count()))
       DBUG_RETURN(1);
   }
   DBUG_RETURN(prepare_for_send(list->elements));

=== modified file 'sql/rpl_master.cc'
--- a/sql/rpl_master.cc	2011-05-26 15:20:09 +0000
+++ b/sql/rpl_master.cc	2011-06-09 08:58:41 +0000
@@ -649,8 +649,8 @@ void mysql_binlog_send(THD* thd, char* l
     Diagnostics_area.
   */
   Diagnostics_area temp_da;
-  Diagnostics_area *saved_da= thd->stmt_da;
-  thd->stmt_da= &temp_da;
+  Diagnostics_area *saved_da= thd->get_stmt_da();
+  thd->set_stmt_da(&temp_da);
 
   DBUG_ENTER("mysql_binlog_send");
   DBUG_PRINT("enter",("log_ident: '%s'  pos: %ld", log_ident, (long) pos));
@@ -1248,7 +1248,7 @@ impossible position";
   }
 
 end:
-  thd->stmt_da= saved_da;
+  thd->set_stmt_da(saved_da);
   end_io_cache(&log);
   mysql_file_close(file, MYF(MY_WME));
 
@@ -1279,7 +1279,7 @@ err:
     mysql_file_close(file, MYF(MY_WME));
   thd->variables.max_allowed_packet= old_max_allowed_packet;
 
-  thd->stmt_da= saved_da;
+  thd->set_stmt_da(saved_da);
   my_message(my_errno, errmsg, MYF(0));
   DBUG_VOID_RETURN;
 }

=== modified file 'sql/rpl_reporting.cc'
--- a/sql/rpl_reporting.cc	2011-05-12 17:29:19 +0000
+++ b/sql/rpl_reporting.cc	2011-06-09 08:58:41 +0000
@@ -47,7 +47,7 @@ int Slave_reporting_capability::has_temp
   DBUG_ENTER("has_temporary_error");
 
   DBUG_EXECUTE_IF("all_errors_are_temporary_errors",
-                  if (thd->stmt_da->is_error())
+                  if (thd->get_stmt_da()->is_error())
                   {
                     thd->clear_error();
                     my_error(ER_LOCK_DEADLOCK, MYF(0));
@@ -63,7 +63,7 @@ int Slave_reporting_capability::has_temp
   if (thd->is_fatal_error || !thd->is_error())
     DBUG_RETURN(0);
 
-  error= (error_arg == 0)? thd->stmt_da->sql_errno() : error_arg;
+  error= (error_arg == 0)? thd->get_stmt_da()->sql_errno() : error_arg;
 
   /*
     Temporary error codes:

=== modified file 'sql/rpl_rli.cc'
--- a/sql/rpl_rli.cc	2011-06-07 08:55:52 +0000
+++ b/sql/rpl_rli.cc	2011-06-09 08:58:41 +0000
@@ -1004,9 +1004,9 @@ void Relay_log_info::clear_tables_to_loc
 
 void Relay_log_info::slave_close_thread_tables(THD *thd)
 {
-  thd->stmt_da->can_overwrite_status= TRUE;
+  thd->get_stmt_da()->can_overwrite_status= TRUE;
   thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd);
-  thd->stmt_da->can_overwrite_status= FALSE;
+  thd->get_stmt_da()->can_overwrite_status= FALSE;
 
   close_thread_tables(thd);
   /*

=== modified file 'sql/rpl_slave.cc'
--- a/sql/rpl_slave.cc	2011-05-21 08:25:33 +0000
+++ b/sql/rpl_slave.cc	2011-06-09 08:58:41 +0000
@@ -2927,7 +2927,7 @@ static int exec_relay_log_event(THD* thd
         else
         {
           thd->is_fatal_error= 1;
-          rli->report(ERROR_LEVEL, thd->stmt_da->sql_errno(),
+          rli->report(ERROR_LEVEL, thd->get_stmt_da()->sql_errno(),
                       "Slave SQL thread retried transaction %lu time(s) "
                       "in vain, giving up. Consider raising the value of "
                       "the slave_transaction_retries variable.", rli->trans_retries);
@@ -3639,9 +3639,9 @@ log '%s' at position %s, relay log '%s'
 
   if (check_temp_dir(rli->slave_patternload_file))
   {
-    rli->report(ERROR_LEVEL, thd->stmt_da->sql_errno(), 
+    rli->report(ERROR_LEVEL, thd->get_stmt_da()->sql_errno(), 
                 "Unable to use slave's temporary directory %s - %s", 
-                slave_load_tmpdir, thd->stmt_da->message());
+                slave_load_tmpdir, thd->get_stmt_da()->message());
     goto err;
   }
 
@@ -3651,7 +3651,7 @@ log '%s' at position %s, relay log '%s'
     execute_init_command(thd, &opt_init_slave, &LOCK_sys_init_slave);
     if (thd->is_slave_error)
     {
-      rli->report(ERROR_LEVEL, thd->stmt_da->sql_errno(),
+      rli->report(ERROR_LEVEL, thd->get_stmt_da()->sql_errno(),
                   "Slave SQL thread aborted. Can't execute init_slave query");
       goto err;
     }
@@ -3718,20 +3718,22 @@ log '%s' at position %s, relay log '%s'
 
         if (thd->is_error())
         {
-          char const *const errmsg= thd->stmt_da->message();
+          char const *const errmsg= thd->get_stmt_da()->message();
 
           DBUG_PRINT("info",
-                     ("thd->stmt_da->sql_errno()=%d; rli->last_error.number=%d",
-                      thd->stmt_da->sql_errno(), last_errno));
+                     ("thd->get_stmt_da()->sql_errno()=%d; "
+                      "rli->last_error.number=%d",
+                      thd->get_stmt_da()->sql_errno(), last_errno));
           if (last_errno == 0)
           {
             /*
  	      This function is reporting an error which was not reported
  	      while executing exec_relay_log_event().
  	    */ 
-            rli->report(ERROR_LEVEL, thd->stmt_da->sql_errno(), "%s", errmsg);
+            rli->report(ERROR_LEVEL, thd->get_stmt_da()->sql_errno(),
+                        "%s", errmsg);
           }
-          else if (last_errno != thd->stmt_da->sql_errno())
+          else if (last_errno != thd->get_stmt_da()->sql_errno())
           {
             /*
              * An error was reported while executing exec_relay_log_event()
@@ -3740,12 +3742,12 @@ log '%s' at position %s, relay log '%s'
              * what caused the problem.
              */  
             sql_print_error("Slave (additional info): %s Error_code: %d",
-                            errmsg, thd->stmt_da->sql_errno());
+                            errmsg, thd->get_stmt_da()->sql_errno());
           }
         }
 
         /* Print any warnings issued */
-        List_iterator_fast<MYSQL_ERROR> it(thd->warning_info->warn_list());
+        List_iterator_fast<MYSQL_ERROR> it(thd->get_warning_info()->warn_list());
         MYSQL_ERROR *err;
         /*
           Added controlled slave thread cancel for replication
@@ -5485,7 +5487,7 @@ uint sql_slave_skip_counter;
 
   @param mi Pointer to Master_info object for the slave's IO thread.
 
-  @param net_report If true, saves the exit status into thd->stmt_da.
+  @param net_report If true, saves the exit status into Diagnostics_area.
 
   @retval 0 success
   @retval 1 error
@@ -5621,7 +5623,7 @@ int start_slave(THD* thd , Master_info*
 
   @param mi Pointer to Master_info object for the slave's IO thread.
 
-  @param net_report If true, saves the exit status into thd->stmt_da.
+  @param net_report If true, saves the exit status into Diagnostics_area.
 
   @retval 0 success
   @retval 1 error

=== modified file 'sql/sp.cc'
--- a/sql/sp.cc	2011-05-26 15:20:09 +0000
+++ b/sql/sp.cc	2011-06-09 08:58:41 +0000
@@ -1727,7 +1727,7 @@ sp_exist_routines(THD *thd, TABLE_LIST *
                                sp_find_routine(thd, TYPE_ENUM_FUNCTION,
                                                name, &thd->sp_func_cache,
                                                FALSE) != NULL;
-    thd->warning_info->clear_warning_info(thd->query_id);
+    thd->get_warning_info()->clear_warning_info(thd->query_id);
     if (! sp_object_found)
     {
       my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION or PROCEDURE",

=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc	2011-05-26 15:20:09 +0000
+++ b/sql/sp_head.cc	2011-06-09 08:58:41 +0000
@@ -1141,14 +1141,14 @@ find_handler_after_execution(THD *thd, s
   if (thd->is_error())
   {
     ctx->find_handler(thd,
-                      thd->stmt_da->sql_errno(),
-                      thd->stmt_da->get_sqlstate(),
+                      thd->get_stmt_da()->sql_errno(),
+                      thd->get_stmt_da()->get_sqlstate(),
                       MYSQL_ERROR::WARN_LEVEL_ERROR,
-                      thd->stmt_da->message());
+                      thd->get_stmt_da()->message());
   }
-  else if (thd->warning_info->statement_warn_count())
+  else if (thd->get_warning_info()->statement_warn_count())
   {
-    List_iterator<MYSQL_ERROR> it(thd->warning_info->warn_list());
+    List_iterator<MYSQL_ERROR> it(thd->get_warning_info()->warn_list());
     MYSQL_ERROR *err;
     while ((err= it++))
     {
@@ -1215,7 +1215,7 @@ sp_head::execute(THD *thd, bool merge_da
   Reprepare_observer *save_reprepare_observer= thd->m_reprepare_observer;
   Object_creation_ctx *saved_creation_ctx;
   Warning_info *saved_warning_info;
-  Warning_info warning_info(thd->warning_info->warn_id(), false);
+  Warning_info warning_info(thd->get_warning_info()->warn_id(), false);
 
   /*
     Just reporting a stack overrun error
@@ -1286,9 +1286,9 @@ sp_head::execute(THD *thd, bool merge_da
   old_arena= thd->stmt_arena;
 
   /* Push a new warning information area. */
-  warning_info.append_warning_info(thd, thd->warning_info);
-  saved_warning_info= thd->warning_info;
-  thd->warning_info= &warning_info;
+  warning_info.append_warning_info(thd, thd->get_warning_info());
+  saved_warning_info= thd->get_warning_info();
+  thd->set_warning_info(&warning_info);
 
   /*
     Switch query context. This has to be done early as this is sometimes
@@ -1388,7 +1388,7 @@ sp_head::execute(THD *thd, bool merge_da
     }
 
     /* Reset number of warnings for this query. */
-    thd->warning_info->reset_for_next_command();
+    thd->get_warning_info()->reset_for_next_command();
 
     DBUG_PRINT("execute", ("Instruction %u", ip));
 
@@ -1496,8 +1496,8 @@ sp_head::execute(THD *thd, bool merge_da
         propagated to the caller in any case.
   */
   if (err_status || merge_da_on_success)
-    saved_warning_info->merge_with_routine_info(thd, thd->warning_info);
-  thd->warning_info= saved_warning_info;
+    saved_warning_info->merge_with_routine_info(thd, thd->get_warning_info());
+  thd->set_warning_info(saved_warning_info);
 
  done:
   DBUG_PRINT("info", ("err_status: %d  killed: %d  is_slave_error: %d  report_error: %d",
@@ -2129,9 +2129,9 @@ sp_head::execute_procedure(THD *thd, Lis
 
     if (!thd->in_sub_stmt)
     {
-      thd->stmt_da->can_overwrite_status= TRUE;
+      thd->get_stmt_da()->can_overwrite_status= TRUE;
       thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd);
-      thd->stmt_da->can_overwrite_status= FALSE;
+      thd->get_stmt_da()->can_overwrite_status= FALSE;
     }
 
     thd_proc_info(thd, "closing tables");
@@ -2968,9 +2968,9 @@ sp_lex_keeper::reset_lex_and_exec_core(T
     /* Here we also commit or rollback the current statement. */
     if (! thd->in_sub_stmt)
     {
-      thd->stmt_da->can_overwrite_status= TRUE;
+      thd->get_stmt_da()->can_overwrite_status= TRUE;
       thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd);
-      thd->stmt_da->can_overwrite_status= FALSE;
+      thd->get_stmt_da()->can_overwrite_status= FALSE;
     }
     thd_proc_info(thd, "closing tables");
     close_thread_tables(thd);
@@ -3004,9 +3004,9 @@ sp_lex_keeper::reset_lex_and_exec_core(T
     open_tables stage.
   */
   if (!res || !thd->is_error() ||
-      (thd->stmt_da->sql_errno() != ER_CANT_REOPEN_TABLE &&
-       thd->stmt_da->sql_errno() != ER_NO_SUCH_TABLE &&
-       thd->stmt_da->sql_errno() != ER_UPDATE_TABLE_USED))
+      (thd->get_stmt_da()->sql_errno() != ER_CANT_REOPEN_TABLE &&
+       thd->get_stmt_da()->sql_errno() != ER_NO_SUCH_TABLE &&
+       thd->get_stmt_da()->sql_errno() != ER_UPDATE_TABLE_USED))
     thd->stmt_arena->state= Query_arena::STMT_EXECUTED;
 
   /*
@@ -3092,7 +3092,7 @@ sp_instr_stmt::execute(THD *thd, uint *n
     {
       res= m_lex_keeper.reset_lex_and_exec_core(thd, nextp, FALSE, this);
 
-      if (thd->stmt_da->is_eof())
+      if (thd->get_stmt_da()->is_eof())
       {
         /* Finalize server status flags after executing a statement. */
         thd->update_server_status();
@@ -3111,7 +3111,7 @@ sp_instr_stmt::execute(THD *thd, uint *n
     thd->query_name_consts= 0;
 
     if (!thd->is_error())
-      thd->stmt_da->reset_diagnostics_area();
+      thd->get_stmt_da()->reset_diagnostics_area();
   }
   DBUG_RETURN(res || thd->is_error());
 }

=== modified file 'sql/sql_acl.cc'
--- a/sql/sql_acl.cc	2011-05-31 13:52:09 +0000
+++ b/sql/sql_acl.cc	2011-06-09 08:58:41 +0000
@@ -1146,9 +1146,9 @@ my_bool acl_reload(THD *thd)
       Execution might have been interrupted; only print the error message
       if an error condition has been raised.
     */
-    if (thd->stmt_da->is_error())
+    if (thd->get_stmt_da()->is_error())
       sql_print_error("Fatal error: Can't open and lock privilege tables: %s",
-                      thd->stmt_da->message());
+                      thd->get_stmt_da()->message());
     goto end;
   }
 
@@ -9538,7 +9538,7 @@ acl_authenticate(THD *thd, uint connect_
     sctx->external_user= my_strdup(mpvio.auth_info.external_user, MYF(0));
 
   if (res == CR_OK_HANDSHAKE_COMPLETE)
-    thd->stmt_da->disable_status();
+    thd->get_stmt_da()->disable_status();
   else
     my_ok(thd);
 

=== modified file 'sql/sql_admin.cc'
--- a/sql/sql_admin.cc	2011-05-04 07:51:15 +0000
+++ b/sql/sql_admin.cc	2011-06-09 08:58:41 +0000
@@ -352,16 +352,16 @@ static bool mysql_admin_table(THD* thd,
         */
 
         Warning_info wi(thd->query_id, false);
-        Warning_info *wi_saved= thd->warning_info;
+        Warning_info *wi_saved= thd->get_warning_info();
 
-        thd->warning_info= &wi;
+        thd->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->warning_info= wi_saved;
+        thd->set_warning_info(wi_saved);
       }
       else
       {
@@ -479,7 +479,7 @@ static bool mysql_admin_table(THD* thd,
     if (!table->table)
     {
       DBUG_PRINT("admin", ("open table failed"));
-      if (thd->warning_info->is_empty())
+      if (thd->get_warning_info()->is_empty())
         push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
                      ER_CHECK_NO_SUCH_TABLE, ER(ER_CHECK_NO_SUCH_TABLE));
       /* if it was a view will check md5 sum */
@@ -487,8 +487,8 @@ static bool mysql_admin_table(THD* thd,
           view_checksum(thd, table) == HA_ADMIN_WRONG_CHECKSUM)
         push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
                      ER_VIEW_CHECKSUM, ER(ER_VIEW_CHECKSUM));
-      if (thd->stmt_da->is_error() &&
-          table_not_corrupt_error(thd->stmt_da->sql_errno()))
+      if (thd->get_stmt_da()->is_error() &&
+          table_not_corrupt_error(thd->get_stmt_da()->sql_errno()))
         result_code= HA_ADMIN_FAILED;
       else
         /* Default failure code is corrupt table */
@@ -536,7 +536,7 @@ static bool mysql_admin_table(THD* thd,
       table->table=0;				// For query cache
       if (protocol->write())
 	goto err;
-      thd->stmt_da->reset_diagnostics_area();
+      thd->get_stmt_da()->reset_diagnostics_area();
       continue;
       /* purecov: end */
     }
@@ -621,8 +621,8 @@ static bool mysql_admin_table(THD* thd,
           we will store the error message in a result set row 
           and then clear.
         */
-        if (thd->stmt_da->is_ok())
-          thd->stmt_da->reset_diagnostics_area();
+        if (thd->get_stmt_da()->is_ok())
+          thd->get_stmt_da()->reset_diagnostics_area();
         table->table= NULL;
         result_code= result_code ? HA_ADMIN_FAILED : HA_ADMIN_OK;
         goto send_result;
@@ -638,7 +638,7 @@ send_result:
     lex->cleanup_after_one_table_open();
     thd->clear_error();  // these errors shouldn't get client
     {
-      List_iterator_fast<MYSQL_ERROR> it(thd->warning_info->warn_list());
+      List_iterator_fast<MYSQL_ERROR> it(thd->get_warning_info()->warn_list());
       MYSQL_ERROR *err;
       while ((err= it++))
       {
@@ -652,7 +652,7 @@ send_result:
         if (protocol->write())
           goto err;
       }
-      thd->warning_info->clear_warning_info(thd->query_id);
+      thd->get_warning_info()->clear_warning_info(thd->query_id);
     }
     protocol->prepare_for_resend();
     protocol->store(table_name, system_charset_info);
@@ -767,8 +767,8 @@ send_result_message:
         we will store the error message in a result set row 
         and then clear.
       */
-      if (thd->stmt_da->is_ok())
-        thd->stmt_da->reset_diagnostics_area();
+      if (thd->get_stmt_da()->is_ok())
+        thd->get_stmt_da()->reset_diagnostics_area();
       trans_commit_stmt(thd);
       trans_commit(thd);
       close_thread_tables(thd);
@@ -801,7 +801,7 @@ send_result_message:
         DBUG_ASSERT(thd->is_error() || thd->killed);
         if (thd->is_error())
         {
-          const char *err_msg= thd->stmt_da->message();
+          const char *err_msg= thd->get_stmt_da()->message();
           if (!thd->vio_ok())
           {
             sql_print_error("%s", err_msg);

=== modified file 'sql/sql_alloc_error_handler.cc'
--- a/sql/sql_alloc_error_handler.cc	2010-07-02 02:58:51 +0000
+++ b/sql/sql_alloc_error_handler.cc	2011-06-09 08:58:41 +0000
@@ -38,10 +38,10 @@ extern "C" void sql_alloc_error_handler(
       returned in the error packet.
       - SHOW ERROR/SHOW WARNINGS may be empty.
     */
-    thd->stmt_da->set_error_status(thd,
-                                   ER_OUT_OF_RESOURCES,
-                                   ER(ER_OUT_OF_RESOURCES),
-                                   NULL);
+    thd->get_stmt_da()->set_error_status(thd,
+                                         ER_OUT_OF_RESOURCES,
+                                         ER(ER_OUT_OF_RESOURCES),
+                                         NULL);
   }
 
   /* Skip writing to the error log to avoid mtr complaints */

=== modified file 'sql/sql_audit.h'
--- a/sql/sql_audit.h	2011-03-09 20:54:55 +0000
+++ b/sql/sql_audit.h	2011-06-09 08:58:41 +0000
@@ -117,7 +117,7 @@ void mysql_audit_general(THD *thd, uint
       query= thd->query_string;
       user= user_buff;
       userlen= make_user_name(thd, user_buff);
-      rows= thd->warning_info->current_row_for_warning();
+      rows= thd->get_warning_info()->current_row_for_warning();
     }
     else
     {
@@ -135,7 +135,7 @@ void mysql_audit_general(THD *thd, uint
 
 #define MYSQL_AUDIT_NOTIFY_CONNECTION_CONNECT(thd) mysql_audit_notify(\
   (thd), MYSQL_AUDIT_CONNECTION_CLASS, MYSQL_AUDIT_CONNECTION_CONNECT,\
-  (thd)->stmt_da->is_error() ? (thd)->stmt_da->sql_errno() : 0,\
+  (thd)->get_stmt_da()->is_error() ? (thd)->get_stmt_da()->sql_errno() : 0,\
   (thd)->thread_id, (thd)->security_ctx->user,\
   (thd)->security_ctx->user ? strlen((thd)->security_ctx->user) : 0,\
   (thd)->security_ctx->priv_user, strlen((thd)->security_ctx->priv_user),\
@@ -156,7 +156,7 @@ void mysql_audit_general(THD *thd, uint
 
 #define MYSQL_AUDIT_NOTIFY_CONNECTION_CHANGE_USER(thd) mysql_audit_notify(\
   (thd), MYSQL_AUDIT_CONNECTION_CLASS, MYSQL_AUDIT_CONNECTION_CHANGE_USER,\
-  (thd)->stmt_da->is_error() ? (thd)->stmt_da->sql_errno() : 0,\
+  (thd)->get_stmt_da()->is_error() ? (thd)->get_stmt_da()->sql_errno() : 0,\
   (thd)->thread_id, (thd)->security_ctx->user,\
   (thd)->security_ctx->user ? strlen((thd)->security_ctx->user) : 0,\
   (thd)->security_ctx->priv_user, strlen((thd)->security_ctx->priv_user),\

=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2011-05-26 15:20:09 +0000
+++ b/sql/sql_base.cc	2011-06-09 08:58:41 +0000
@@ -676,8 +676,11 @@ get_table_share_with_discover(THD *thd,
 
     @todo Rework alternative ways to deal with ER_NO_SUCH TABLE.
   */
-  if (share || (thd->is_error() && thd->stmt_da->sql_errno() != ER_NO_SUCH_TABLE))
+  if (share || (thd->is_error() &&
+      thd->get_stmt_da()->sql_errno() != ER_NO_SUCH_TABLE))
+  {
     DBUG_RETURN(share);
+  }
 
   *error= 0;
 
@@ -1728,14 +1731,14 @@ bool close_temporary_tables(THD *thd)
       qinfo.db_len= db.length();
       thd->variables.character_set_client= cs_save;
 
-      thd->stmt_da->can_overwrite_status= TRUE;
+      thd->get_stmt_da()->can_overwrite_status= TRUE;
       if ((error= (mysql_bin_log.write(&qinfo) || error)))
       {
         /*
           If we're here following THD::cleanup, thence the connection
           has been closed already. So lets print a message to the
           error log instead of pushing yet another error into the
-          stmt_da.
+          Diagnostics_area.
 
           Also, we keep the error flag so that we propagate the error
           up in the stack. This way, if we're the SQL thread we notice
@@ -1746,7 +1749,7 @@ bool close_temporary_tables(THD *thd)
         sql_print_error("Failed to write the DROP statement for "
                         "temporary tables to binary log");
       }
-      thd->stmt_da->can_overwrite_status= FALSE;
+      thd->get_stmt_da()->can_overwrite_status= FALSE;
 
       thd->variables.pseudo_thread_id= save_pseudo_thread_id;
       thd->thread_specific_used= save_thread_specific_used;
@@ -4013,7 +4016,7 @@ recover_from_failed_open(THD *thd)
         ha_create_table_from_engine(thd, m_failed_table->db,
                                     m_failed_table->table_name);
 
-        thd->warning_info->clear_warning_info(thd->query_id);
+        thd->get_warning_info()->clear_warning_info(thd->query_id);
         thd->clear_error();                 // Clear error message
         thd->mdl_context.release_transactional_locks();
         break;

=== modified file 'sql/sql_cache.cc'
--- a/sql/sql_cache.cc	2011-05-31 13:52:09 +0000
+++ b/sql/sql_cache.cc	2011-06-09 08:58:41 +0000
@@ -993,7 +993,7 @@ void Query_cache::end_of_result(THD *thd
     DBUG_VOID_RETURN;
 
   /* Ensure that only complete results are cached. */
-  DBUG_ASSERT(thd->stmt_da->is_eof());
+  DBUG_ASSERT(thd->get_stmt_da()->is_eof());
 
   if (thd->killed)
   {
@@ -1756,8 +1756,8 @@ def_week_frmt: %lu, in_trans: %d, autoco
     response, we can't handle it anyway.
   */
   (void) trans_commit_stmt(thd);
-  if (!thd->stmt_da->is_set())
-    thd->stmt_da->disable_status();
+  if (!thd->get_stmt_da()->is_set())
+    thd->get_stmt_da()->disable_status();
 
   BLOCK_UNLOCK_RD(query_block);
   MYSQL_QUERY_CACHE_HIT(thd->query(), (ulong) thd->limit_found_rows);

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2011-05-31 13:52:09 +0000
+++ b/sql/sql_class.cc	2011-06-09 08:58:41 +0000
@@ -596,7 +596,7 @@ int thd_tx_isolation(const THD *thd)
 extern "C"
 void thd_inc_row_count(THD *thd)
 {
-  thd->warning_info->inc_current_row_for_warning();
+  thd->get_warning_info()->inc_current_row_for_warning();
 }
 
 
@@ -738,8 +738,6 @@ THD::THD(bool enable_plugins)
    first_successful_insert_id_in_cur_stmt(0),
    stmt_depends_on_first_successful_insert_id_in_prev_stmt(FALSE),
    m_examined_row_count(0),
-   warning_info(&main_warning_info),
-   stmt_da(&main_da),
    m_statement_psi(NULL),
    is_fatal_error(0),
    transaction_rollback_request(0),
@@ -755,7 +753,9 @@ THD::THD(bool enable_plugins)
    debug_sync_control(0),
 #endif /* defined(ENABLED_DEBUG_SYNC) */
    m_enable_plugins(enable_plugins),
-   main_warning_info(0, false)
+   main_warning_info(0, false),
+   m_warning_info(&main_warning_info),
+   m_stmt_da(&main_da)
 {
   ulong tmp;
 
@@ -1010,6 +1010,8 @@ MYSQL_ERROR* THD::raise_condition(uint s
                                   MYSQL_ERROR::enum_warning_level level,
                                   const char* msg)
 {
+  Diagnostics_area *da= get_stmt_da();
+  Warning_info *wi= get_warning_info();
   MYSQL_ERROR *cond= NULL;
   DBUG_ENTER("THD::raise_condition");
 
@@ -1017,7 +1019,7 @@ MYSQL_ERROR* THD::raise_condition(uint s
       (level == MYSQL_ERROR::WARN_LEVEL_NOTE))
     DBUG_RETURN(NULL);
 
-  warning_info->opt_clear_warning_info(query_id);
+  wi->opt_clear_warning_info(query_id);
 
   /*
     TODO: replace by DBUG_ASSERT(sql_errno != 0) once all bugs similar to
@@ -1077,10 +1079,10 @@ MYSQL_ERROR* THD::raise_condition(uint s
     }
     else
     {
-      if (! stmt_da->is_error())
+      if (!da->is_error())
       {
         set_row_count_func(-1);
-        stmt_da->set_error_status(this, sql_errno, msg, sqlstate);
+        da->set_error_status(this, sql_errno, msg, sqlstate);
       }
     }
   }
@@ -1090,7 +1092,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= warning_info->push_warning(this, sql_errno, sqlstate, level, msg);
+  cond= wi->push_warning(this, sql_errno, sqlstate, level, msg);
   DBUG_RETURN(cond);
 }
 

=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h	2011-05-31 13:52:09 +0000
+++ b/sql/sql_class.h	2011-06-09 08:58:41 +0000
@@ -2281,8 +2281,6 @@ public:
   table_map  used_tables;
   USER_CONN *user_connect;
   const CHARSET_INFO *db_charset;
-  Warning_info *warning_info;
-  Diagnostics_area *stmt_da;
 #if defined(ENABLED_PROFILING)
   PROFILING  profiling;
 #endif
@@ -2787,8 +2785,8 @@ public:
   inline void clear_error()
   {
     DBUG_ENTER("clear_error");
-    if (stmt_da->is_error())
-      stmt_da->reset_diagnostics_area();
+    if (get_stmt_da()->is_error())
+      get_stmt_da()->reset_diagnostics_area();
     is_slave_error= 0;
     DBUG_VOID_RETURN;
   }
@@ -2815,7 +2813,7 @@ public:
   */
   inline void fatal_error()
   {
-    DBUG_ASSERT(stmt_da->is_error() || killed);
+    DBUG_ASSERT(get_stmt_da()->is_error() || killed);
     is_fatal_error= 1;
     DBUG_PRINT("error",("Fatal error set"));
   }
@@ -2832,7 +2830,33 @@ public:
 
     To raise this flag, use my_error().
   */
-  inline bool is_error() const { return stmt_da->is_error(); }
+  inline bool is_error() const { return get_stmt_da()->is_error(); }
+
+  /// Returns Warning-information-area for the current statement.
+  Warning_info *get_warning_info()
+  { return m_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; }
+
+  /// Returns Diagnostics-area for the current statement.
+  const Diagnostics_area *get_stmt_da() const
+  { return const_cast<THD *> (this)->get_stmt_da(); }
+
+  /// Sets Diagnostics-area for the current statement.
+  void set_stmt_da(Diagnostics_area *da)
+  { m_stmt_da= da; }
+
+public:
   inline const CHARSET_INFO *charset()
   { return variables.character_set_client; }
   void update_charset();
@@ -3226,6 +3250,9 @@ private:
   Warning_info main_warning_info;
   Diagnostics_area main_da;
 
+  Warning_info *m_warning_info;
+  Diagnostics_area *m_stmt_da;
+
   /**
     It will be set TURE if CURRENT_USER() is called in account management
     statements or default definer is set in CREATE/ALTER SP, SF, Event,
@@ -3247,24 +3274,24 @@ private:
 };
 
 
-/** A short cut for thd->stmt_da->set_ok_status(). */
+/** A short cut for thd->get_stmt_da()->set_ok_status(). */
 
 inline void
 my_ok(THD *thd, ulonglong affected_rows= 0, ulonglong id= 0,
         const char *message= NULL)
 {
   thd->set_row_count_func(affected_rows);
-  thd->stmt_da->set_ok_status(thd, affected_rows, id, message);
+  thd->get_stmt_da()->set_ok_status(thd, affected_rows, id, message);
 }
 
 
-/** A short cut for thd->stmt_da->set_eof_status(). */
+/** A short cut for thd->get_stmt_da()->set_eof_status(). */
 
 inline void
 my_eof(THD *thd)
 {
   thd->set_row_count_func(-1);
-  thd->stmt_da->set_eof_status(thd);
+  thd->get_stmt_da()->set_eof_status(thd);
 }
 
 #define tmp_disable_binlog(A)       \

=== modified file 'sql/sql_connect.cc'
--- a/sql/sql_connect.cc	2011-05-30 11:42:03 +0000
+++ b/sql/sql_connect.cc	2011-06-09 08:58:41 +0000
@@ -631,7 +631,8 @@ void end_connection(THD *thd)
                         thd->thread_id,(thd->db ? thd->db : "unconnected"),
                         sctx->user ? sctx->user : "unauthenticated",
                         sctx->host_or_ip,
-                        (thd->stmt_da->is_error() ? thd->stmt_da->message() :
+                        (thd->get_stmt_da()->is_error() ?
+                         thd->get_stmt_da()->message() :
                          ER(ER_UNKNOWN_ERROR)));
     }
   }
@@ -669,7 +670,7 @@ void prepare_new_connection_state(THD* t
                         thd->thread_id,(thd->db ? thd->db : "unconnected"),
                         sctx->user ? sctx->user : "unauthenticated",
                         sctx->host_or_ip, "init_connect command failed");
-      sql_print_warning("%s", thd->stmt_da->message());
+      sql_print_warning("%s", thd->get_stmt_da()->message());
     }
     thd->proc_info=0;
     thd->set_time();

=== modified file 'sql/sql_derived.cc'
--- a/sql/sql_derived.cc	2011-03-08 19:14:42 +0000
+++ b/sql/sql_derived.cc	2011-06-09 08:58:41 +0000
@@ -184,9 +184,9 @@ exit:
     if (orig_table_list->view)
     {
       if (thd->is_error() &&
-          (thd->stmt_da->sql_errno() == ER_BAD_FIELD_ERROR ||
-          thd->stmt_da->sql_errno() == ER_FUNC_INEXISTENT_NAME_COLLISION ||
-          thd->stmt_da->sql_errno() == ER_SP_DOES_NOT_EXIST))
+          (thd->get_stmt_da()->sql_errno() == ER_BAD_FIELD_ERROR ||
+          thd->get_stmt_da()->sql_errno() == ER_FUNC_INEXISTENT_NAME_COLLISION ||
+          thd->get_stmt_da()->sql_errno() == ER_SP_DOES_NOT_EXIST))
       {
         thd->clear_error();
         my_error(ER_VIEW_INVALID, MYF(0), orig_table_list->db,

=== modified file 'sql/sql_error.cc'
--- a/sql/sql_error.cc	2011-05-26 15:20:09 +0000
+++ b/sql/sql_error.cc	2011-06-09 08:58:41 +0000
@@ -363,7 +363,7 @@ Diagnostics_area::set_ok_status(THD *thd
   if (is_error() || is_disabled())
     return;
 
-  m_statement_warn_count= thd->warning_info->statement_warn_count();
+  m_statement_warn_count= thd->get_warning_info()->statement_warn_count();
   m_affected_rows= affected_rows_arg;
   m_last_insert_id= last_insert_id_arg;
   if (message_arg)
@@ -398,7 +398,7 @@ Diagnostics_area::set_eof_status(THD *th
     anyway.
   */
   m_statement_warn_count= (thd->spcont ?
-                           0 : thd->warning_info->statement_warn_count());
+                           0 : thd->get_warning_info()->statement_warn_count());
 
   m_status= DA_EOF;
   DBUG_VOID_RETURN;
@@ -667,7 +667,7 @@ bool mysqld_show_warnings(THD *thd, ulon
   List<Item> field_list;
   DBUG_ENTER("mysqld_show_warnings");
 
-  DBUG_ASSERT(thd->warning_info->is_read_only());
+  DBUG_ASSERT(thd->get_warning_info()->is_read_only());
 
   field_list.push_back(new Item_empty_string("Level", 7));
   field_list.push_back(new Item_return_int("Code",4, MYSQL_TYPE_LONG));
@@ -685,7 +685,7 @@ bool mysqld_show_warnings(THD *thd, ulon
 
   unit->set_limit(sel);
 
-  List_iterator_fast<MYSQL_ERROR> it(thd->warning_info->warn_list());
+  List_iterator_fast<MYSQL_ERROR> it(thd->get_warning_info()->warn_list());
   while ((err= it++))
   {
     /* Skip levels that the user is not interested in */
@@ -708,7 +708,7 @@ bool mysqld_show_warnings(THD *thd, ulon
   }
   my_eof(thd);
 
-  thd->warning_info->set_read_only(FALSE);
+  thd->get_warning_info()->set_read_only(FALSE);
 
   DBUG_RETURN(FALSE);
 }

=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc	2011-05-30 06:25:47 +0000
+++ b/sql/sql_insert.cc	2011-06-09 08:58:41 +0000
@@ -931,7 +931,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
       error=write_record(thd, table ,&info);
     if (error)
       break;
-    thd->warning_info->inc_current_row_for_warning();
+    thd->get_warning_info()->inc_current_row_for_warning();
   }
 
   free_underlaid_joins(thd, &thd->lex->select_lex);
@@ -1086,11 +1086,11 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
       sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records,
 	      (lock_type == TL_WRITE_DELAYED) ? (ulong) 0 :
 	      (ulong) (info.records - info.copied),
-              (ulong) thd->warning_info->statement_warn_count());
+              (ulong) thd->get_warning_info()->statement_warn_count());
     else
       sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records,
 	      (ulong) (info.deleted + updated),
-              (ulong) thd->warning_info->statement_warn_count());
+              (ulong) thd->get_warning_info()->statement_warn_count());
     ::my_ok(thd, info.copied + info.deleted + updated, id, buff);
   }
   thd->abort_on_warning= 0;
@@ -2153,10 +2153,11 @@ bool delayed_get_table(THD *thd, MDL_req
             want to send "Server shutdown in progress" in the
             INSERT THREAD.
           */
-          if (di->thd.stmt_da->sql_errno() == ER_SERVER_SHUTDOWN)
+          if (di->thd.get_stmt_da()->sql_errno() == ER_SERVER_SHUTDOWN)
             my_message(ER_QUERY_INTERRUPTED, ER(ER_QUERY_INTERRUPTED), MYF(0));
           else
-            my_message(di->thd.stmt_da->sql_errno(), di->thd.stmt_da->message(),
+            my_message(di->thd.get_stmt_da()->sql_errno(),
+                       di->thd.get_stmt_da()->message(),
                        MYF(0));
         }
         di->unlock();
@@ -2241,10 +2242,12 @@ TABLE *Delayed_insert::get_local_table(T
         killed using THD::notify_shared_lock() or
         kill_delayed_threads_for_table().
       */
-      if (!thd.is_error() || thd.stmt_da->sql_errno() == ER_SERVER_SHUTDOWN)
+      if (!thd.is_error() ||
+          thd.get_stmt_da()->sql_errno() == ER_SERVER_SHUTDOWN)
         my_message(ER_QUERY_INTERRUPTED, ER(ER_QUERY_INTERRUPTED), MYF(0));
       else
-        my_message(thd.stmt_da->sql_errno(), thd.stmt_da->message(), MYF(0));
+        my_message(thd.get_stmt_da()->sql_errno(),
+                   thd.get_stmt_da()->message(), MYF(0));
       goto error;
     }
   }
@@ -2627,8 +2630,8 @@ pthread_handler_t handle_delayed_insert(
   if (my_thread_init())
   {
     /* Can't use my_error since store_globals has not yet been called */
-    thd->stmt_da->set_error_status(thd, ER_OUT_OF_RESOURCES,
-                                   ER(ER_OUT_OF_RESOURCES), NULL);
+    thd->get_stmt_da()->set_error_status(thd, ER_OUT_OF_RESOURCES,
+                                         ER(ER_OUT_OF_RESOURCES), NULL);
     di->handler_thread_initialized= TRUE;
   }
   else
@@ -2638,8 +2641,8 @@ pthread_handler_t handle_delayed_insert(
     if (init_thr_lock() || thd->store_globals())
     {
       /* Can't use my_error since store_globals has perhaps failed */
-      thd->stmt_da->set_error_status(thd, ER_OUT_OF_RESOURCES,
-                                     ER(ER_OUT_OF_RESOURCES), NULL);
+      thd->get_stmt_da()->set_error_status(thd, ER_OUT_OF_RESOURCES,
+                                           ER(ER_OUT_OF_RESOURCES), NULL);
       di->handler_thread_initialized= TRUE;
       thd->fatal_error();
       goto err;
@@ -3048,7 +3051,7 @@ bool Delayed_insert::handle_inserts(void
 	{
 	  /* This should never happen */
 	  table->file->print_error(error,MYF(0));
-	  sql_print_error("%s", thd.stmt_da->message());
+	  sql_print_error("%s", thd.get_stmt_da()->message());
           DBUG_PRINT("error", ("HA_EXTRA_NO_CACHE failed in loop"));
 	  goto err;
 	}
@@ -3093,7 +3096,7 @@ bool Delayed_insert::handle_inserts(void
   if ((error=table->file->extra(HA_EXTRA_NO_CACHE)))
   {						// This shouldn't happen
     table->file->print_error(error,MYF(0));
-    sql_print_error("%s", thd.stmt_da->message());
+    sql_print_error("%s", thd.get_stmt_da()->message());
     DBUG_PRINT("error", ("HA_EXTRA_NO_CACHE failed after loop"));
     goto err;
   }
@@ -3519,7 +3522,7 @@ bool select_insert::send_eof()
   error= (thd->locked_tables_mode <= LTM_LOCK_TABLES ?
           table->file->ha_end_bulk_insert() : 0);
   if (!error && thd->is_error())
-    error= thd->stmt_da->sql_errno();
+    error= thd->get_stmt_da()->sql_errno();
 
   table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
   table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE);
@@ -3570,11 +3573,11 @@ bool select_insert::send_eof()
   if (info.ignore)
     sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records,
 	    (ulong) (info.records - info.copied),
-            (ulong) thd->warning_info->statement_warn_count());
+            (ulong) thd->get_warning_info()->statement_warn_count());
   else
     sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records,
 	    (ulong) (info.deleted+info.updated),
-            (ulong) thd->warning_info->statement_warn_count());
+            (ulong) thd->get_warning_info()->statement_warn_count());
   row_count= info.copied + info.deleted +
              ((thd->client_capabilities & CLIENT_FOUND_ROWS) ?
               info.touched : info.updated);

=== modified file 'sql/sql_load.cc'
--- a/sql/sql_load.cc	2011-05-26 15:20:09 +0000
+++ b/sql/sql_load.cc	2011-06-09 08:58:41 +0000
@@ -590,7 +590,7 @@ int mysql_load(THD *thd,sql_exchange *ex
   }
   sprintf(name, ER(ER_LOAD_INFO), (ulong) info.records, (ulong) info.deleted,
 	  (ulong) (info.records - info.copied),
-          (ulong) thd->warning_info->statement_warn_count());
+          (ulong) thd->get_warning_info()->statement_warn_count());
 
 #ifndef EMBEDDED_LIBRARY
   if (mysql_bin_log.is_open())
@@ -833,7 +833,7 @@ read_fixed_length(THD *thd, COPY_INFO &i
         push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
                             ER_WARN_TOO_FEW_RECORDS,
                             ER(ER_WARN_TOO_FEW_RECORDS),
-                            thd->warning_info->current_row_for_warning());
+                            thd->get_warning_info()->current_row_for_warning());
         if (!field->maybe_null() && field->type() == FIELD_TYPE_TIMESTAMP)
             ((Field_timestamp*) field)->set_time();
       }
@@ -857,7 +857,7 @@ read_fixed_length(THD *thd, COPY_INFO &i
       push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
                           ER_WARN_TOO_MANY_RECORDS,
                           ER(ER_WARN_TOO_MANY_RECORDS),
-                          thd->warning_info->current_row_for_warning());
+                          thd->get_warning_info()->current_row_for_warning());
     }
 
     if (thd->killed ||
@@ -893,9 +893,9 @@ read_fixed_length(THD *thd, COPY_INFO &i
       push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
                           ER_WARN_TOO_MANY_RECORDS,
                           ER(ER_WARN_TOO_MANY_RECORDS),
-                          thd->warning_info->current_row_for_warning());
+                          thd->get_warning_info()->current_row_for_warning());
     }
-    thd->warning_info->inc_current_row_for_warning();
+    thd->get_warning_info()->inc_current_row_for_warning();
 continue_loop:;
   }
   DBUG_RETURN(test(read_info.error));
@@ -959,7 +959,7 @@ read_sep_field(THD *thd, COPY_INFO &info
           if (field->reset())
           {
             my_error(ER_WARN_NULL_TO_NOTNULL, MYF(0), field->field_name,
-                     thd->warning_info->current_row_for_warning());
+                     thd->get_warning_info()->current_row_for_warning());
             DBUG_RETURN(1);
           }
           field->set_null();
@@ -1031,7 +1031,7 @@ read_sep_field(THD *thd, COPY_INFO &info
           if (field->reset())
           {
             my_error(ER_WARN_NULL_TO_NOTNULL, MYF(0),field->field_name,
-                     thd->warning_info->current_row_for_warning());
+                     thd->get_warning_info()->current_row_for_warning());
             DBUG_RETURN(1);
           }
           if (!field->maybe_null() && field->type() == FIELD_TYPE_TIMESTAMP)
@@ -1046,7 +1046,7 @@ read_sep_field(THD *thd, COPY_INFO &info
           push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
                               ER_WARN_TOO_FEW_RECORDS,
                               ER(ER_WARN_TOO_FEW_RECORDS),
-                              thd->warning_info->current_row_for_warning());
+                              thd->get_warning_info()->current_row_for_warning());
         }
         else if (item->type() == Item::STRING_ITEM)
         {
@@ -1092,11 +1092,11 @@ read_sep_field(THD *thd, COPY_INFO &info
       thd->cuted_fields++;			/* To long row */
       push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
                           ER_WARN_TOO_MANY_RECORDS, ER(ER_WARN_TOO_MANY_RECORDS),
-                          thd->warning_info->current_row_for_warning());
+                          thd->get_warning_info()->current_row_for_warning());
       if (thd->killed)
         DBUG_RETURN(1);
     }
-    thd->warning_info->inc_current_row_for_warning();
+    thd->get_warning_info()->inc_current_row_for_warning();
 continue_loop:;
   }
   DBUG_RETURN(test(read_info.error));
@@ -1230,7 +1230,7 @@ read_xml_field(THD *thd, COPY_INFO &info
           push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
                               ER_WARN_TOO_FEW_RECORDS,
                               ER(ER_WARN_TOO_FEW_RECORDS),
-                              thd->warning_info->current_row_for_warning());
+                              thd->get_warning_info()->current_row_for_warning());
         }
         else
           ((Item_user_var_as_out_param *)item)->set_null_value(cs);
@@ -1260,7 +1260,7 @@ read_xml_field(THD *thd, COPY_INFO &info
       We don't need to reset auto-increment field since we are restoring
       its default value at the beginning of each loop iteration.
     */
-    thd->warning_info->inc_current_row_for_warning();
+    thd->get_warning_info()->inc_current_row_for_warning();
     continue_loop:;
   }
   DBUG_RETURN(test(read_info.error) || thd->is_error());

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2011-05-30 06:25:47 +0000
+++ b/sql/sql_parse.cc	2011-06-09 08:58:41 +0000
@@ -794,7 +794,7 @@ bool do_command(THD *thd)
     Consider moving to init_connect() instead.
   */
   thd->clear_error();				// Clear error message
-  thd->stmt_da->reset_diagnostics_area();
+  thd->get_stmt_da()->reset_diagnostics_area();
 
   net_new_transaction(net);
 
@@ -1173,7 +1173,7 @@ bool dispatch_command(enum enum_server_c
       }
 
 /* PSI end */
-      MYSQL_END_STATEMENT(thd->m_statement_psi, thd->stmt_da);
+      MYSQL_END_STATEMENT(thd->m_statement_psi, thd->get_stmt_da());
 
 /* DTRACE end */
       if (MYSQL_QUERY_DONE_ENABLED())
@@ -1319,7 +1319,7 @@ bool dispatch_command(enum enum_server_c
     /* We don't calculate statistics for this command */
     general_log_print(thd, command, NullS);
     net->error=0;				// Don't give 'abort' message
-    thd->stmt_da->disable_status();              // Don't send anything back
+    thd->get_stmt_da()->disable_status();              // Don't send anything back
     error=TRUE;					// End server
     break;
 #ifndef EMBEDDED_LIBRARY
@@ -1459,7 +1459,7 @@ bool dispatch_command(enum enum_server_c
 #else
     (void) my_net_write(net, (uchar*) buff, length);
     (void) net_flush(net);
-    thd->stmt_da->disable_status();
+    thd->get_stmt_da()->disable_status();
 #endif
     break;
   }
@@ -1534,7 +1534,8 @@ bool dispatch_command(enum enum_server_c
     mysql_audit_general(thd, MYSQL_AUDIT_GENERAL_RESULT, 0, 0);
 
   mysql_audit_general(thd, MYSQL_AUDIT_GENERAL_STATUS,
-                      thd->stmt_da->is_error() ? thd->stmt_da->sql_errno() : 0,
+                      thd->get_stmt_da()->is_error() ?
+                      thd->get_stmt_da()->sql_errno() : 0,
                       command_name[command].str);
 
   log_slow_statement(thd);
@@ -1547,7 +1548,7 @@ bool dispatch_command(enum enum_server_c
   free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC));
 
   /* Performance Schema Interface instrumentation, end */
-  MYSQL_END_STATEMENT(thd->m_statement_psi, thd->stmt_da);
+  MYSQL_END_STATEMENT(thd->m_statement_psi, thd->get_stmt_da());
   thd->m_statement_psi= NULL;
 
   /* DTRACE instrumentation, end */
@@ -2024,12 +2025,12 @@ mysql_execute_command(THD *thd)
     variables, but for now this is probably good enough.
   */
   if ((sql_command_flags[lex->sql_command] & CF_DIAGNOSTIC_STMT) != 0)
-    thd->warning_info->set_read_only(TRUE);
+    thd->get_warning_info()->set_read_only(TRUE);
   else
   {
-    thd->warning_info->set_read_only(FALSE);
+    thd->get_warning_info()->set_read_only(FALSE);
     if (all_tables)
-      thd->warning_info->opt_clear_warning_info(thd->query_id);
+      thd->get_warning_info()->opt_clear_warning_info(thd->query_id);
   }
 
 #ifdef HAVE_REPLICATION
@@ -4526,7 +4527,7 @@ finish:
     /* report error issued during command execution */
     if (thd->killed_errno())
     {
-      if (! thd->stmt_da->is_set())
+      if (! thd->get_stmt_da()->is_set())
         thd->send_kill_message();
     }
     if (thd->killed == THD::KILL_QUERY || thd->killed == THD::KILL_BAD_DATA)
@@ -4539,9 +4540,9 @@ finish:
     else
     {
       /* If commit fails, we should be able to reset the OK status. */
-      thd->stmt_da->can_overwrite_status= TRUE;
+      thd->get_stmt_da()->can_overwrite_status= TRUE;
       trans_commit_stmt(thd);
-      thd->stmt_da->can_overwrite_status= FALSE;
+      thd->get_stmt_da()->can_overwrite_status= FALSE;
     }
   }
 
@@ -4560,10 +4561,10 @@ finish:
     /* No transaction control allowed in sub-statements. */
     DBUG_ASSERT(! thd->in_sub_stmt);
     /* If commit fails, we should be able to reset the OK status. */
-    thd->stmt_da->can_overwrite_status= TRUE;
+    thd->get_stmt_da()->can_overwrite_status= TRUE;
     /* Commit the normal transaction if one is active. */
     trans_commit_implicit(thd);
-    thd->stmt_da->can_overwrite_status= FALSE;
+    thd->get_stmt_da()->can_overwrite_status= FALSE;
     thd->mdl_context.release_transactional_locks();
   }
   else if (! thd->in_sub_stmt && ! thd->in_multi_stmt_transaction_mode())
@@ -5442,8 +5443,8 @@ void THD::reset_for_next_command()
     thd->user_var_events_alloc= thd->mem_root;
   }
   thd->clear_error();
-  thd->stmt_da->reset_diagnostics_area();
-  thd->warning_info->reset_for_next_command();
+  thd->get_stmt_da()->reset_diagnostics_area();
+  thd->get_warning_info()->reset_for_next_command();
   thd->rand_used= 0;
   thd->m_sent_row_count= thd->m_examined_row_count= 0;
   thd->thd_marker.emb_on_expr_nest= NULL;

=== modified file 'sql/sql_prepare.cc'
--- a/sql/sql_prepare.cc	2011-05-26 15:20:09 +0000
+++ b/sql/sql_prepare.cc	2011-06-09 08:58:41 +0000
@@ -340,7 +340,7 @@ static bool send_prep_stmt(Prepared_stat
   int2store(buff+5, columns);
   int2store(buff+7, stmt->param_count);
   buff[9]= 0;                                   // Guard against a 4.1 client
-  tmp= min(stmt->thd->warning_info->statement_warn_count(), 65535);
+  tmp= min(stmt->thd->get_warning_info()->statement_warn_count(), 65535);
   int2store(buff+10, tmp);
 
   /*
@@ -357,7 +357,7 @@ static bool send_prep_stmt(Prepared_stat
 
   if (!error)
     /* Flag that a response has already been sent */
-    thd->stmt_da->disable_status();
+    thd->get_stmt_da()->disable_status();
 
   DBUG_RETURN(error);
 }
@@ -370,7 +370,7 @@ static bool send_prep_stmt(Prepared_stat
   thd->client_stmt_id= stmt->id;
   thd->client_param_count= stmt->param_count;
   thd->clear_error();
-  thd->stmt_da->disable_status();
+  thd->get_stmt_da()->disable_status();
 
   return 0;
 }
@@ -1957,7 +1957,7 @@ static bool check_prepared_statement(Pre
 
   /* Reset warning count for each query that uses tables */
   if (tables)
-    thd->warning_info->opt_clear_warning_info(thd->query_id);
+    thd->get_warning_info()->opt_clear_warning_info(thd->query_id);
 
   if (sql_command_flags[sql_command] & CF_HA_CLOSE)
     mysql_ha_rm_tables(thd, tables);
@@ -2745,7 +2745,7 @@ void mysqld_stmt_close(THD *thd, char *p
   Prepared_statement *stmt;
   DBUG_ENTER("mysqld_stmt_close");
 
-  thd->stmt_da->disable_status();
+  thd->get_stmt_da()->disable_status();
 
   if (!(stmt= find_prepared_statement(thd, stmt_id)))
     DBUG_VOID_RETURN;
@@ -2821,7 +2821,7 @@ void mysql_stmt_get_longdata(THD *thd, c
 
   status_var_increment(thd->status_var.com_stmt_send_long_data);
 
-  thd->stmt_da->disable_status();
+  thd->get_stmt_da()->disable_status();
 #ifndef EMBEDDED_LIBRARY
   /* Minimal size of long data packet is 6 bytes */
   if (packet_length < MYSQL_LONG_DATA_HEADER)
@@ -2850,26 +2850,26 @@ void mysql_stmt_get_longdata(THD *thd, c
 
   param= stmt->param_array[param_number];
 
-  Diagnostics_area new_stmt_da, *save_stmt_da= thd->stmt_da;
+  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->warning_info;
+  Warning_info *save_warinig_info= thd->get_warning_info();
 
-  thd->stmt_da= &new_stmt_da;
-  thd->warning_info= &new_warnning_info;
+  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));
 #else
   param->set_longdata(thd->extra_data, thd->extra_length);
 #endif
-  if (thd->stmt_da->is_error())
+  if (thd->get_stmt_da()->is_error())
   {
     stmt->state= Query_arena::STMT_ERROR;
-    stmt->last_errno= thd->stmt_da->sql_errno();
-    strncpy(stmt->last_error, thd->stmt_da->message(), MYSQL_ERRMSG_SIZE);
+    stmt->last_errno= thd->get_stmt_da()->sql_errno();
+    strncpy(stmt->last_error, thd->get_stmt_da()->message(), MYSQL_ERRMSG_SIZE);
   }
-  thd->stmt_da= save_stmt_da;
-  thd->warning_info= save_warinig_info;
+  thd->set_stmt_da(save_stmt_da);
+  thd->set_warning_info(save_warinig_info);
 
   general_log_print(thd, thd->get_command(), NullS);
 
@@ -2945,8 +2945,8 @@ Reprepare_observer::report_error(THD *th
     that this thread execution stops and returns to the caller,
     backtracking all the way to Prepared_statement::execute_loop().
   */
-  thd->stmt_da->set_error_status(thd, ER_NEED_REPREPARE,
-                                 ER(ER_NEED_REPREPARE), "HY000");
+  thd->get_stmt_da()->set_error_status(thd, ER_NEED_REPREPARE,
+                                       ER(ER_NEED_REPREPARE), "HY000");
   m_invalidated= TRUE;
 
   return TRUE;
@@ -3454,7 +3454,7 @@ reexecute:
       reprepare_observer.is_invalidated() &&
       reprepare_attempt++ < MAX_REPREPARE_ATTEMPTS)
   {
-    DBUG_ASSERT(thd->stmt_da->sql_errno() == ER_NEED_REPREPARE);
+    DBUG_ASSERT(thd->get_stmt_da()->sql_errno() == ER_NEED_REPREPARE);
     thd->clear_error();
 
     error= reprepare();
@@ -3556,7 +3556,7 @@ Prepared_statement::reprepare()
       Sic: we can't simply silence warnings during reprepare, because if
       it's failed, we need to return all the warnings to the user.
     */
-    thd->warning_info->clear_warning_info(thd->query_id);
+    thd->get_warning_info()->clear_warning_info(thd->query_id);
   }
   return error;
 }
@@ -3981,23 +3981,23 @@ 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->stmt_da;
-  Warning_info *save_warning_info= m_thd->warning_info;
+  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");
 
   free_old_result(); /* Delete all data from previous execution, if any */
 
   m_thd->protocol= &protocol_local;
-  m_thd->stmt_da= &m_diagnostics_area;
-  m_thd->warning_info= &m_warning_info;
+  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->stmt_da= save_diagnostics_area;
-  m_thd->warning_info= save_warning_info;
+  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_select.cc'
--- a/sql/sql_select.cc	2011-06-07 16:28:07 +0000
+++ b/sql/sql_select.cc	2011-06-09 08:58:41 +0000
@@ -17655,7 +17655,7 @@ sub_select(JOIN *join,JOIN_TAB *join_tab
     /* Set first_unmatched for the last inner table of this group */
     join_tab->last_inner->first_unmatched= join_tab;
   }
-  join->thd->warning_info->reset_current_row_for_warning();
+  join->thd->get_warning_info()->reset_current_row_for_warning();
 
   error= (*join_tab->read_first_record)(join_tab);
 
@@ -17982,7 +17982,7 @@ evaluate_join_record(JOIN *join, JOIN_TA
       enum enum_nested_loop_state rc;
       /* A match from join_tab is found for the current partial join. */
       rc= (*join_tab->next_select)(join, join_tab+1, 0);
-      join->thd->warning_info->inc_current_row_for_warning();
+      join->thd->get_warning_info()->inc_current_row_for_warning();
       if (rc != NESTED_LOOP_OK && rc != NESTED_LOOP_NO_MORE_ROWS)
         DBUG_RETURN(rc);
 
@@ -18014,7 +18014,7 @@ evaluate_join_record(JOIN *join, JOIN_TA
     }
     else
     {
-      join->thd->warning_info->inc_current_row_for_warning();
+      join->thd->get_warning_info()->inc_current_row_for_warning();
       if (join_tab->not_null_compl)
       {
         /* a NULL-complemented row is not in a table so cannot be locked */
@@ -18029,7 +18029,7 @@ evaluate_join_record(JOIN *join, JOIN_TA
       with the beginning coinciding with the current partial join.
     */
     join->examined_rows++;
-    join->thd->warning_info->inc_current_row_for_warning();
+    join->thd->get_warning_info()->inc_current_row_for_warning();
     if (join_tab->not_null_compl)
       join_tab->read_record.unlock_row(join_tab);
   }

=== modified file 'sql/sql_servers.cc'
--- a/sql/sql_servers.cc	2011-04-19 03:29:06 +0000
+++ b/sql/sql_servers.cc	2011-06-09 08:58:41 +0000
@@ -261,9 +261,9 @@ bool servers_reload(THD *thd)
       Execution might have been interrupted; only print the error message
       if an error condition has been raised.
     */
-    if (thd->stmt_da->is_error())
+    if (thd->get_stmt_da()->is_error())
       sql_print_error("Can't open and lock privilege tables: %s",
-                      thd->stmt_da->message());
+                      thd->get_stmt_da()->message());
     return_val= FALSE;
     goto end;
   }

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2011-05-26 15:20:09 +0000
+++ b/sql/sql_show.cc	2011-06-09 08:58:41 +0000
@@ -3130,7 +3130,7 @@ fill_schema_table_by_open(THD *thd, bool
     of backward compatibility.
   */
   if (!is_show_fields_or_keys && result && thd->is_error() &&
-      thd->stmt_da->sql_errno() == ER_NO_SUCH_TABLE)
+      thd->get_stmt_da()->sql_errno() == ER_NO_SUCH_TABLE)
   {
     /*
       Hide error for a non-existing table.
@@ -3220,7 +3220,7 @@ static int fill_schema_table_names(THD *
     default:
       DBUG_ASSERT(0);
     }
-    if (thd->is_error() && thd->stmt_da->sql_errno() == ER_NO_SUCH_TABLE)
+    if (thd->is_error() && thd->get_stmt_da()->sql_errno() == ER_NO_SUCH_TABLE)
     {
       thd->clear_error();
       return 0;
@@ -4118,13 +4118,13 @@ err:
       column with the error text, and clear the error so that the operation
       can continue.
     */
-    const char *error= thd->is_error() ? thd->stmt_da->message() : "";
+    const char *error= thd->is_error() ? thd->get_stmt_da()->message() : "";
     table->field[20]->store(error, strlen(error), cs);
 
     if (thd->is_error())
     {
       push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-                   thd->stmt_da->sql_errno(), thd->stmt_da->message());
+                   thd->get_stmt_da()->sql_errno(), thd->get_stmt_da()->message());
       thd->clear_error();
     }
   }
@@ -4281,7 +4281,7 @@ static int get_schema_column_record(THD
       */
       if (thd->is_error())
         push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-                     thd->stmt_da->sql_errno(), thd->stmt_da->message());
+                     thd->get_stmt_da()->sql_errno(), thd->get_stmt_da()->message());
       thd->clear_error();
       res= 0;
     }
@@ -4942,7 +4942,7 @@ static int get_schema_stat_record(THD *t
       */
       if (thd->is_error())
         push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-                     thd->stmt_da->sql_errno(), thd->stmt_da->message());
+                     thd->get_stmt_da()->sql_errno(), thd->get_stmt_da()->message());
       thd->clear_error();
       res= 0;
     }
@@ -5161,7 +5161,7 @@ static int get_schema_views_record(THD *
       DBUG_RETURN(1);
     if (res && thd->is_error())
       push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-                   thd->stmt_da->sql_errno(), thd->stmt_da->message());
+                   thd->get_stmt_da()->sql_errno(), thd->get_stmt_da()->message());
   }
   if (res)
     thd->clear_error();
@@ -5195,7 +5195,7 @@ static int get_schema_constraints_record
   {
     if (thd->is_error())
       push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-                   thd->stmt_da->sql_errno(), thd->stmt_da->message());
+                   thd->get_stmt_da()->sql_errno(), thd->get_stmt_da()->message());
     thd->clear_error();
     DBUG_RETURN(0);
   }
@@ -5298,7 +5298,7 @@ static int get_schema_triggers_record(TH
   {
     if (thd->is_error())
       push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-                   thd->stmt_da->sql_errno(), thd->stmt_da->message());
+                   thd->get_stmt_da()->sql_errno(), thd->get_stmt_da()->message());
     thd->clear_error();
     DBUG_RETURN(0);
   }
@@ -5379,7 +5379,7 @@ static int get_schema_key_column_usage_r
   {
     if (thd->is_error())
       push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-                   thd->stmt_da->sql_errno(), thd->stmt_da->message());
+                   thd->get_stmt_da()->sql_errno(), thd->get_stmt_da()->message());
     thd->clear_error();
     DBUG_RETURN(0);
   }
@@ -5666,7 +5666,7 @@ static int get_schema_partitions_record(
   {
     if (thd->is_error())
       push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-                   thd->stmt_da->sql_errno(), thd->stmt_da->message());
+                   thd->get_stmt_da()->sql_errno(), thd->get_stmt_da()->message());
     thd->clear_error();
     DBUG_RETURN(0);
   }
@@ -6195,7 +6195,7 @@ get_referential_constraints_record(THD *
   {
     if (thd->is_error())
       push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-                   thd->stmt_da->sql_errno(), thd->stmt_da->message());
+                   thd->get_stmt_da()->sql_errno(), thd->get_stmt_da()->message());
     thd->clear_error();
     DBUG_RETURN(0);
   }
@@ -6804,24 +6804,24 @@ static bool do_fill_table(THD *thd,
   // 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->warning_info;
+  Warning_info *wi_saved= thd->get_warning_info();
 
-  thd->warning_info= &wi;
+  thd->set_warning_info(&wi);
 
   bool res= table_list->schema_table->fill_table(
     thd, table_list, join_table->condition());
 
-  thd->warning_info= wi_saved;
+  thd->set_warning_info(wi_saved);
 
   // Pass an error if any.
 
-  if (thd->stmt_da->is_error())
+  if (thd->get_stmt_da()->is_error())
   {
-    thd->warning_info->push_warning(thd,
-                                    thd->stmt_da->sql_errno(),
-                                    thd->stmt_da->get_sqlstate(),
-                                    MYSQL_ERROR::WARN_LEVEL_ERROR,
-                                    thd->stmt_da->message());
+    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());
   }
 
   // Pass warnings (if any).
@@ -6836,7 +6836,7 @@ static bool do_fill_table(THD *thd,
   while ((err= it++))
   {
     if (err->get_level() != MYSQL_ERROR::WARN_LEVEL_ERROR)
-      thd->warning_info->push_warning(thd, err);
+      thd->get_warning_info()->push_warning(thd, err);
   }
 
   return res;

=== modified file 'sql/sql_signal.cc'
--- a/sql/sql_signal.cc	2011-03-09 20:54:55 +0000
+++ b/sql/sql_signal.cc	2011-06-09 08:58:41 +0000
@@ -467,9 +467,9 @@ bool Sql_cmd_signal::execute(THD *thd)
     This has roots in the SQL standard specification for SIGNAL.
   */
 
-  thd->stmt_da->reset_diagnostics_area();
+  thd->get_stmt_da()->reset_diagnostics_area();
   thd->set_row_count_func(0);
-  thd->warning_info->clear_warning_info(thd->query_id);
+  thd->get_warning_info()->clear_warning_info(thd->query_id);
 
   result= raise_condition(thd, &cond);
 
@@ -484,7 +484,7 @@ bool Sql_cmd_resignal::execute(THD *thd)
 
   DBUG_ENTER("Sql_cmd_resignal::execute");
 
-  thd->warning_info->m_warn_id= thd->query_id;
+  thd->get_warning_info()->m_warn_id= thd->query_id;
 
   if (! thd->spcont || ! (signaled= thd->spcont->raised_condition()))
   {

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2011-06-01 09:11:28 +0000
+++ b/sql/sql_table.cc	2011-06-09 08:58:41 +0000
@@ -2942,7 +2942,7 @@ const CHARSET_INFO* get_sql_field_charse
 
 bool check_duplicate_warning(THD *thd, char *msg, ulong length)
 {
-  List_iterator_fast<MYSQL_ERROR> it(thd->warning_info->warn_list());
+  List_iterator_fast<MYSQL_ERROR> it(thd->get_warning_info()->warn_list());
   MYSQL_ERROR *err;
   while ((err= it++))
   {
@@ -7053,7 +7053,7 @@ bool mysql_alter_table(THD *thd,char *ne
 end_temporary:
   my_snprintf(tmp_name, sizeof(tmp_name), ER(ER_INSERT_INFO),
 	      (ulong) (copied + deleted), (ulong) deleted,
-	      (ulong) thd->warning_info->statement_warn_count());
+	      (ulong) thd->get_warning_info()->statement_warn_count());
   my_ok(thd, copied + deleted, 0L, tmp_name);
   DBUG_RETURN(FALSE);
 
@@ -7080,7 +7080,7 @@ err:
     Report error here.
   */
   if (alter_info->error_if_not_empty &&
-      thd->warning_info->current_row_for_warning())
+      thd->get_warning_info()->current_row_for_warning())
   {
     const char *f_val= 0;
     enum enum_mysql_timestamp_type t_type= MYSQL_TIMESTAMP_DATE;
@@ -7285,7 +7285,7 @@ copy_data_between_tables(TABLE *from,TAB
   init_read_record(&info, thd, from, (SQL_SELECT *) 0, 1, 1, FALSE);
   if (ignore)
     to->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
-  thd->warning_info->reset_current_row_for_warning();
+  thd->get_warning_info()->reset_current_row_for_warning();
   restore_record(to, s->default_values);        // Create empty record
   while (!(error=info.read_record(&info)))
   {
@@ -7344,7 +7344,7 @@ copy_data_between_tables(TABLE *from,TAB
     }
     else
       found_count++;
-    thd->warning_info->inc_current_row_for_warning();
+    thd->get_warning_info()->inc_current_row_for_warning();
   }
   end_read_record(&info);
   free_io_cache(from);

=== modified file 'sql/sql_time.cc'
--- a/sql/sql_time.cc	2011-03-09 20:54:55 +0000
+++ b/sql/sql_time.cc	2011-06-09 08:58:41 +0000
@@ -817,7 +817,7 @@ void make_truncated_value_warning(THD *t
     cs->cset->snprintf(cs, warn_buff, sizeof(warn_buff),
                        ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD),
                        type_str, str.c_ptr(), field_name,
-                       (ulong) thd->warning_info->current_row_for_warning());
+                       (ulong) thd->get_warning_info()->current_row_for_warning());
   else
   {
     if (time_type > MYSQL_TIMESTAMP_ERROR)

=== modified file 'sql/sql_update.cc'
--- a/sql/sql_update.cc	2011-05-26 15:20:09 +0000
+++ b/sql/sql_update.cc	2011-06-09 08:58:41 +0000
@@ -791,7 +791,7 @@ int mysql_update(THD *thd,
     }
     else
       table->file->unlock_row();
-    thd->warning_info->inc_current_row_for_warning();
+    thd->get_warning_info()->inc_current_row_for_warning();
     if (thd->is_error())
     {
       error= 1;
@@ -897,7 +897,7 @@ int mysql_update(THD *thd,
     char buff[MYSQL_ERRMSG_SIZE];
     my_snprintf(buff, sizeof(buff), ER(ER_UPDATE_INFO), (ulong) found,
                 (ulong) updated,
-                (ulong) thd->warning_info->statement_warn_count());
+                (ulong) thd->get_warning_info()->statement_warn_count());
     my_ok(thd, (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated,
           id, buff);
     DBUG_PRINT("info",("%ld records updated", (long) updated));

=== modified file 'sql/sys_vars.cc'
--- a/sql/sys_vars.cc	2011-05-21 08:25:33 +0000
+++ b/sql/sys_vars.cc	2011-06-09 08:58:41 +0000
@@ -2838,7 +2838,7 @@ static Sys_var_session_special Sys_rand_
 
 static ulonglong read_error_count(THD *thd)
 {
-  return thd->warning_info->error_count();
+  return thd->get_warning_info()->error_count();
 }
 // this really belongs to the SHOW STATUS
 static Sys_var_session_special Sys_error_count(
@@ -2850,7 +2850,7 @@ static Sys_var_session_special Sys_error
 
 static ulonglong read_warning_count(THD *thd)
 {
-  return thd->warning_info->warn_count();
+  return thd->get_warning_info()->warn_count();
 }
 // this really belongs to the SHOW STATUS
 static Sys_var_session_special Sys_warning_count(

=== modified file 'sql/table.cc'
--- a/sql/table.cc	2011-05-26 15:20:09 +0000
+++ b/sql/table.cc	2011-06-09 08:58:41 +0000
@@ -3841,26 +3841,32 @@ void TABLE_LIST::hide_view_error(THD *th
   /* Hide "Unknown column" or "Unknown function" error */
   DBUG_ASSERT(thd->is_error());
 
-  if (thd->stmt_da->sql_errno() == ER_BAD_FIELD_ERROR ||
-      thd->stmt_da->sql_errno() == ER_SP_DOES_NOT_EXIST ||
-      thd->stmt_da->sql_errno() == ER_FUNC_INEXISTENT_NAME_COLLISION ||
-      thd->stmt_da->sql_errno() == ER_PROCACCESS_DENIED_ERROR ||
-      thd->stmt_da->sql_errno() == ER_COLUMNACCESS_DENIED_ERROR ||
-      thd->stmt_da->sql_errno() == ER_TABLEACCESS_DENIED_ERROR ||
-      thd->stmt_da->sql_errno() == ER_TABLE_NOT_LOCKED ||
-      thd->stmt_da->sql_errno() == ER_NO_SUCH_TABLE)
-  {
-    TABLE_LIST *top= top_table();
-    thd->clear_error();
-    my_error(ER_VIEW_INVALID, MYF(0), top->view_db.str, top->view_name.str);
-  }
-  else if (thd->stmt_da->sql_errno() == ER_NO_DEFAULT_FOR_FIELD)
-  {
-    TABLE_LIST *top= top_table();
-    thd->clear_error();
-    // TODO: make correct error message
-    my_error(ER_NO_DEFAULT_FOR_VIEW_FIELD, MYF(0),
-             top->view_db.str, top->view_name.str);
+  switch (thd->get_stmt_da()->sql_errno()) {
+    case ER_BAD_FIELD_ERROR:
+    case ER_SP_DOES_NOT_EXIST:
+    case ER_FUNC_INEXISTENT_NAME_COLLISION:
+    case ER_PROCACCESS_DENIED_ERROR:
+    case ER_COLUMNACCESS_DENIED_ERROR:
+    case ER_TABLEACCESS_DENIED_ERROR:
+    case ER_TABLE_NOT_LOCKED:
+    case ER_NO_SUCH_TABLE:
+    {
+      TABLE_LIST *top= top_table();
+      thd->clear_error();
+      my_error(ER_VIEW_INVALID, MYF(0),
+               top->view_db.str, top->view_name.str);
+      break;
+    }
+
+    case ER_NO_DEFAULT_FOR_FIELD:
+    {
+      TABLE_LIST *top= top_table();
+      thd->clear_error();
+      // TODO: make correct error message
+      my_error(ER_NO_DEFAULT_FOR_VIEW_FIELD, MYF(0),
+               top->view_db.str, top->view_name.str);
+      break;
+    }
   }
 }
 

=== modified file 'sql/transaction.cc'
--- a/sql/transaction.cc	2011-05-16 14:30:54 +0000
+++ b/sql/transaction.cc	2011-06-09 08:58:41 +0000
@@ -752,7 +752,7 @@ bool trans_xa_rollback(THD *thd)
       ha_commit_or_rollback_by_xid(thd->lex->xid, 0);
       xid_cache_delete(xs);
     }
-    DBUG_RETURN(thd->stmt_da->is_error());
+    DBUG_RETURN(thd->get_stmt_da()->is_error());
   }
 
   if (xa_state != XA_IDLE && xa_state != XA_PREPARED && xa_state != XA_ROLLBACK_ONLY)

=== modified file 'sql/tztime.cc'
--- a/sql/tztime.cc	2011-05-26 15:20:09 +0000
+++ b/sql/tztime.cc	2011-06-09 08:58:41 +0000
@@ -1671,7 +1671,7 @@ my_tz_init(THD *org_thd, const char *def
                            MYSQL_OPEN_IGNORE_FLUSH | MYSQL_LOCK_IGNORE_TIMEOUT))
   {
     sql_print_warning("Can't open and lock time zone table: %s "
-                      "trying to live without them", thd->stmt_da->message());
+                      "trying to live without them", thd->get_stmt_da()->message());
     /* We will try emulate that everything is ok */
     return_val= time_zone_tables_exist= 0;
     goto end_with_setting_default_tz;

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (alexander.nozdrin:3169 to 3170)Bug#11763162Alexander Nozdrin9 Jun