#At file:///home/alik/MySQL/bzr/00/bug55843/mysql-trunk-bug55843-03/ based on revid:alexander.nozdrin@stripped
3172 Alexander Nozdrin 2011-06-09
Pre-requisite patch for Bug#11763162 (55843 - Handled condition
appears as not handled).
The goal of this patch is to change the relationship between THD,
Diagnostics_area and Warning_info classes:
- before the patch, THD owned both Diagnostics_area and
Warning_info instances.
- after the patch THD owns Diagnostics_area instance,
and Diagnostics_area owns Warning_info instance.
The patch changes THD::get_warning_info() and THD::set_warning_info(),
so that they still work to minimize side changes.
Those functions will be removed later in a separate patch.
NOTE:
- Diagnostics_area is pushed in the following cases:
- sql_prepare.cc
Here it's pushed along with a new instance of Warning_info.
- rpl_master.cc
Here Diagnostics_area is pushed alone.
The comment says:
Dump thread sends ER_MASTER_FATAL_ERROR_READING_BINLOG instead of the real
errors happend on master to slave when erorr is encountered.
So set a temporary Diagnostics_area to thd. The low level error is always
set into the temporary Diagnostics_area and be ingored. The original
Diagnostics_area will be restored at the end of this function.
ER_MASTER_FATAL_ERROR_READING_BINLOG will be set to the original
Diagnostics_area.
- Warning_info is pushed in sp_head.cc, sql_admin.cc, sql_show.cc.
The idea is to provide an intermediate Warning_info for an operation
and ignore/process thrown warnings later.
modified:
sql/sql_class.cc
sql/sql_class.h
sql/sql_error.cc
sql/sql_error.h
sql/sql_prepare.cc
sql/sql_prepare.h
=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc 2011-06-09 08:58:41 +0000
+++ b/sql/sql_class.cc 2011-06-09 09:36:20 +0000
@@ -753,8 +753,7 @@ THD::THD(bool enable_plugins)
debug_sync_control(0),
#endif /* defined(ENABLED_DEBUG_SYNC) */
m_enable_plugins(enable_plugins),
- main_warning_info(0, false),
- m_warning_info(&main_warning_info),
+ main_da(0, false),
m_stmt_da(&main_da)
{
ulong tmp;
=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h 2011-06-09 08:58:41 +0000
+++ b/sql/sql_class.h 2011-06-09 09:36:20 +0000
@@ -2834,7 +2834,7 @@ public:
/// Returns Warning-information-area for the current statement.
Warning_info *get_warning_info()
- { return m_warning_info; }
+ { return get_stmt_da()->get_warning_info(); }
/// Returns Warning-information-area for the current statement.
const Warning_info *get_warning_info() const
@@ -2842,7 +2842,7 @@ public:
/// Sets Warning-information-area for the current statement.
void set_warning_info(Warning_info *wi)
- { m_warning_info= wi; }
+ { get_stmt_da()->set_warning_info(wi); }
/// Returns Diagnostics-area for the current statement.
Diagnostics_area *get_stmt_da()
@@ -3247,10 +3247,7 @@ private:
tree itself is reused between executions and thus is stored elsewhere.
*/
MEM_ROOT main_mem_root;
- Warning_info main_warning_info;
Diagnostics_area main_da;
-
- Warning_info *m_warning_info;
Diagnostics_area *m_stmt_da;
/**
=== modified file 'sql/sql_error.cc'
--- a/sql/sql_error.cc 2011-06-09 08:58:41 +0000
+++ b/sql/sql_error.cc 2011-06-09 09:36:20 +0000
@@ -318,6 +318,23 @@ MYSQL_ERROR::set_sqlstate(const char* sq
m_returned_sqlstate[SQLSTATE_LENGTH]= '\0';
}
+Diagnostics_area::Diagnostics_area()
+:
+ m_main_wi(0, false),
+ m_current_wi(&m_main_wi)
+{
+ reset_diagnostics_area();
+}
+
+Diagnostics_area::Diagnostics_area(ulonglong warn_id,
+ bool allow_unlimited_warnings)
+:
+ m_main_wi(warn_id, allow_unlimited_warnings),
+ m_current_wi(&m_main_wi)
+{
+ reset_diagnostics_area();
+}
+
/**
Clear this diagnostics area.
=== modified file 'sql/sql_error.h'
--- a/sql/sql_error.h 2011-06-09 09:03:18 +0000
+++ b/sql/sql_error.h 2011-06-09 09:36:20 +0000
@@ -485,7 +485,19 @@ public:
return m_statement_warn_count;
}
- Diagnostics_area() { reset_diagnostics_area(); }
+public:
+ Diagnostics_area();
+ Diagnostics_area(ulonglong warn_id, bool allow_unlimited_warnings);
+
+public:
+ inline Warning_info *get_warning_info()
+ { return m_current_wi; }
+
+ inline const Warning_info *get_warning_info() const
+ { return m_current_wi; }
+
+ inline void set_warning_info(Warning_info *wi)
+ { m_current_wi= wi; }
private:
/** Message buffer. Can be used by OK or ERROR status. */
@@ -524,6 +536,9 @@ private:
*/
uint m_statement_warn_count;
enum_diagnostics_status m_status;
+
+ Warning_info m_main_wi;
+ Warning_info *m_current_wi;
};
///////////////////////////////////////////////////////////////////////////
=== modified file 'sql/sql_prepare.cc'
--- a/sql/sql_prepare.cc 2011-06-09 08:58:41 +0000
+++ b/sql/sql_prepare.cc 2011-06-09 09:36:20 +0000
@@ -2850,12 +2850,10 @@ void mysql_stmt_get_longdata(THD *thd, c
param= stmt->param_array[param_number];
- Diagnostics_area new_stmt_da, *save_stmt_da= thd->get_stmt_da();
- Warning_info new_warnning_info(thd->query_id, false);
- Warning_info *save_warinig_info= thd->get_warning_info();
+ Diagnostics_area new_stmt_da(thd->query_id, false);
+ Diagnostics_area *save_stmt_da= thd->get_stmt_da();
thd->set_stmt_da(&new_stmt_da);
- thd->set_warning_info(&new_warnning_info);
#ifndef EMBEDDED_LIBRARY
param->set_longdata(packet, (ulong) (packet_end - packet));
@@ -2869,7 +2867,6 @@ void mysql_stmt_get_longdata(THD *thd, c
strncpy(stmt->last_error, thd->get_stmt_da()->message(), MYSQL_ERRMSG_SIZE);
}
thd->set_stmt_da(save_stmt_da);
- thd->set_warning_info(save_warinig_info);
general_log_print(thd, thd->get_command(), NullS);
@@ -3918,7 +3915,7 @@ Ed_result_set::Ed_result_set(List<Ed_row
*/
Ed_connection::Ed_connection(THD *thd)
- :m_warning_info(thd->query_id, false),
+ :m_diagnostics_area(thd->query_id, false),
m_thd(thd),
m_rsets(0),
m_current_rset(0)
@@ -3944,7 +3941,7 @@ Ed_connection::free_old_result()
}
m_current_rset= m_rsets;
m_diagnostics_area.reset_diagnostics_area();
- m_warning_info.clear_warning_info(m_thd->query_id);
+ m_diagnostics_area.get_warning_info()->clear_warning_info(m_thd->query_id);
}
@@ -3982,7 +3979,6 @@ bool Ed_connection::execute_direct(Serve
Prepared_statement stmt(m_thd);
Protocol *save_protocol= m_thd->protocol;
Diagnostics_area *save_diagnostics_area= m_thd->get_stmt_da();
- Warning_info *save_warning_info= m_thd->get_warning_info();
DBUG_ENTER("Ed_connection::execute_direct");
@@ -3990,14 +3986,12 @@ bool Ed_connection::execute_direct(Serve
m_thd->protocol= &protocol_local;
m_thd->set_stmt_da(&m_diagnostics_area);
- m_thd->set_warning_info(&m_warning_info);
rc= stmt.execute_server_runnable(server_runnable);
m_thd->protocol->end_statement();
m_thd->protocol= save_protocol;
m_thd->set_stmt_da(save_diagnostics_area);
- m_thd->set_warning_info(save_warning_info);
/*
Protocol_local makes use of m_current_rset to keep
track of the last result set, while adding result sets to the end.
=== modified file 'sql/sql_prepare.h'
--- a/sql/sql_prepare.h 2010-07-02 18:15:21 +0000
+++ b/sql/sql_prepare.h 2011-06-09 09:36:20 +0000
@@ -252,7 +252,7 @@ public:
*/
ulong get_warn_count() const
{
- return m_warning_info.warn_count();
+ return m_diagnostics_area.get_warning_info()->warn_count();
}
/**
Get the server warnings as a result set.
@@ -261,7 +261,9 @@ public:
The second is a numeric code.
The third is warning text.
*/
- List<MYSQL_ERROR> *get_warn_list() { return &m_warning_info.warn_list(); }
+ List<MYSQL_ERROR> *get_warn_list()
+ { return &m_diagnostics_area.get_warning_info()->warn_list(); }
+
/**
The following members are only valid if execute_direct()
or move_to_next_result() returned an error.
@@ -310,7 +312,6 @@ public:
~Ed_connection() { free_old_result(); }
private:
Diagnostics_area m_diagnostics_area;
- Warning_info m_warning_info;
/**
Execute direct interface does not support multi-statements, only
multi-results. So we never have a situation when we have
Attachment: [text/bzr-bundle] bzr/alexander.nozdrin@oracle.com-20110609093620-28ln6jstgmgy4v9b.bundle