From: Alexander Nozdrin Date: June 8 2011 5:27pm Subject: bzr commit into mysql-trunk branch (alexander.nozdrin:3170) Bug#11763162 List-Archive: http://lists.mysql.com/commits/138873 X-Bug: 11763162 Message-Id: <201106081727.p58HRJJW003363@acsmt358.oracle.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8996221471619811092==" --===============8996221471619811092== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline #At file:///home/alik/MySQL/bzr/00/bug55843/mysql-trunk-bug55843-02/ based on revid:alexander.nozdrin@stripped 3170 Alexander Nozdrin 2011-06-08 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. @ sql/sp_head.cc Note: Warning_info is pushed here alone (without Diagnistics_area). Temporary Warning_info instance is used to collect warnings from stored-routine-execution and append them to the main Warning_info area. @ sql/sql_admin.cc Note: Warning_info is pushed here alone (without Diagnistics_area). Temporary Warning_info instance is used to collect unneeded warnings and ignore them. @ sql/sql_prepare.cc Note: Diagnostics_area is pushed here along with a new instance of Warning_info. @ sql/sql_show.cc Note: Warning_info is pushed here alone (without Diagnistics_area). Temporary Warning_info instance is used to collect warnings from ST_SHEMA_TABLE::fill_table() and process them afterwards. modified: sql/sp_head.cc sql/sql_admin.cc sql/sql_class.cc sql/sql_class.h sql/sql_error.cc sql/sql_error.h sql/sql_prepare.cc sql/sql_prepare.h sql/sql_show.cc === modified file 'sql/sp_head.cc' --- a/sql/sp_head.cc 2011-06-08 14:46:12 +0000 +++ b/sql/sp_head.cc 2011-06-08 17:27:14 +0000 @@ -1288,7 +1288,7 @@ sp_head::execute(THD *thd, bool merge_da /* Push a new warning information area. */ warning_info.append_warning_info(thd, thd->get_warning_info()); saved_warning_info= thd->get_warning_info(); - thd->set_warning_info(&warning_info); + thd->get_stmt_da()->set_warning_info(&warning_info); /* Switch query context. This has to be done early as this is sometimes @@ -1497,7 +1497,7 @@ sp_head::execute(THD *thd, bool merge_da */ if (err_status || merge_da_on_success) saved_warning_info->merge_with_routine_info(thd, thd->get_warning_info()); - thd->set_warning_info(saved_warning_info); + thd->get_stmt_da()->set_warning_info(saved_warning_info); done: DBUG_PRINT("info", ("err_status: %d killed: %d is_slave_error: %d report_error: %d", === modified file 'sql/sql_admin.cc' --- a/sql/sql_admin.cc 2011-06-08 14:46:12 +0000 +++ b/sql/sql_admin.cc 2011-06-08 17:27:14 +0000 @@ -351,17 +351,18 @@ static bool mysql_admin_table(THD* thd, because it's already known that the table is badly damaged. */ + Diagnostics_area *da= thd->get_stmt_da(); Warning_info wi(thd->query_id, false); Warning_info *wi_saved= thd->get_warning_info(); - thd->set_warning_info(&wi); + da->set_warning_info(&wi); open_error= open_temporary_tables(thd, table); if (!open_error) open_error= open_and_lock_tables(thd, table, TRUE, 0); - thd->set_warning_info(wi_saved); + da->set_warning_info(wi_saved); } else { === modified file 'sql/sql_class.cc' --- a/sql/sql_class.cc 2011-06-08 14:46:12 +0000 +++ b/sql/sql_class.cc 2011-06-08 17:27:14 +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-08 14:46:12 +0000 +++ b/sql/sql_class.h 2011-06-08 17:27:14 +0000 @@ -2834,16 +2834,12 @@ 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 { return const_cast (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; } @@ -3247,10 +3243,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-08 14:46:12 +0000 +++ b/sql/sql_error.cc 2011-06-08 17:27:14 +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-08 17:03:06 +0000 +++ b/sql/sql_error.h 2011-06-08 17:27:14 +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-08 14:46:12 +0000 +++ b/sql/sql_prepare.cc 2011-06-08 17:27:14 +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(Listquery_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-08 17:27:14 +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 *get_warn_list() { return &m_warning_info.warn_list(); } + List *get_warn_list() + { return &m_diagnostics_area.get_warning_info()->warn_list(); } + /** The following members are only valid if execute_direct() or move_to_next_result() returned an error. @@ -310,7 +312,6 @@ public: ~Ed_connection() { free_old_result(); } private: Diagnostics_area m_diagnostics_area; - Warning_info m_warning_info; /** Execute direct interface does not support multi-statements, only multi-results. So we never have a situation when we have === modified file 'sql/sql_show.cc' --- a/sql/sql_show.cc 2011-06-08 14:46:12 +0000 +++ b/sql/sql_show.cc 2011-06-08 17:27:14 +0000 @@ -6803,25 +6803,26 @@ static bool do_fill_table(THD *thd, // Warning_info, so "useful warnings" get rejected. In order to avoid // that problem we create a Warning_info instance, which is capable of // storing "unlimited" number of warnings. - Warning_info wi(thd->query_id, true); - Warning_info *wi_saved= thd->get_warning_info(); + Diagnostics_area *da= thd->get_stmt_da(); + Warning_info wi_tmp(thd->query_id, true); + Warning_info *wi= thd->get_warning_info(); - thd->set_warning_info(&wi); + da->set_warning_info(&wi_tmp); bool res= table_list->schema_table->fill_table( thd, table_list, join_table->condition()); - thd->set_warning_info(wi_saved); + da->set_warning_info(wi); // Pass an error if any. - if (thd->get_stmt_da()->is_error()) + if (da->is_error()) { - thd->get_warning_info()->push_warning(thd, - thd->get_stmt_da()->sql_errno(), - thd->get_stmt_da()->get_sqlstate(), - MYSQL_ERROR::WARN_LEVEL_ERROR, - thd->get_stmt_da()->message()); + wi->push_warning(thd, + da->sql_errno(), + da->get_sqlstate(), + MYSQL_ERROR::WARN_LEVEL_ERROR, + da->message()); } // Pass warnings (if any). @@ -6830,13 +6831,13 @@ static bool do_fill_table(THD *thd, // correspond to the errors which were filtered out in fill_table(). - List_iterator_fast it(wi.warn_list()); + List_iterator_fast it(wi_tmp.warn_list()); MYSQL_ERROR *err; while ((err= it++)) { if (err->get_level() != MYSQL_ERROR::WARN_LEVEL_ERROR) - thd->get_warning_info()->push_warning(thd, err); + wi->push_warning(thd, err); } return res; --===============8996221471619811092== MIME-Version: 1.0 Content-Type: text/bzr-bundle; charset="us-ascii"; name="bzr/alexander.nozdrin@stripped" Content-Transfer-Encoding: 7bit Content-Disposition: inline # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: alexander.nozdrin@stripped\ # d42js75vidpq03g0 # target_branch: file:///home/alik/MySQL/bzr/00/bug55843/mysql-trunk-\ # bug55843-02/ # testament_sha1: 97aea6bfcb398d0972e146dca51e654788aff941 # timestamp: 2011-06-08 21:27:19 +0400 # base_revision_id: alexander.nozdrin@stripped\ # ceudi3h5mur917gm # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWTm81NUACHp/gFQQIADZd/// dkf9oL////pgD0532Hrns8Iq97bZy0ndzu3Zt1rfYjp7dV9s0APQOgNGog6cMUmpmhR5R6NPVPTT UMg0009QAAAABoJKDVPExIKeymoPSPUZAAABoAAAJSam01NNBHqGpqPU0epkPUAAAAAGICRECaQC aNIyT1DJk1MaAA0CeppmiDCKUqe0wgajKfqTaT2pqbEyj9UD01Bo/VNAABoIpCaTJiNAJiJ6aBCa YqD1GhoBoB6hCOhA5xp2PgMBqqCwBjGYtYzRMYi9QIC+jBcB88Pd3+Hrr6/398p8BsjZrxYQh8B8 7bOuJpBVwqSWJk/+Qchv29IJzzbcQzo/RBxniTfZ6N2qa/37HCS6nu6t0xgqEzcoIjImUMzK6Y6s TZou0mlonc9ILaTg81tvimrhmcDqClVQiEM8v87vJ/yOPVlBleeyHih1oG2NjY2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