#At file:///home/dlenev/src/bzr/mysql-6.0-3726-w2/
2677 Dmitry Lenev 2008-06-26
Fix warnings about passing pointer to not fully-initialized THD
object to constructor of base Open_tables_state classe, which
appeared on Windows and were introduced by one of the patches
implementing WL#3726 "DDL locking for all metadata objects".
modified:
sql/sql_class.cc
sql/sql_class.h
per-file messages:
sql/sql_class.cc
Moved code preparing Open_tables_state instance for operations
which open/lock/close tables from class constructor to
init_open_tables_state() method. This allows us to move such
initialization of base Open_table_state instance in THD class
constructor from base classes initialization section to
constructor's body and thus to get rid of warnings about
about passing pointer to not fully-initialized THD object
to base class constructor.
sql/sql_class.h
Moved code preparing Open_tables_state instance for operations
which open/lock/close tables from class constructor to
init_open_tables_state() method. This allows us to move such
initialization of base Open_table_state instance in THD class
constructor from base classes initialization section to
constructor's body and thus to get rid of warnings about
about passing pointer to not fully-initialized THD object
to base class constructor.
=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc 2008-06-11 11:49:58 +0000
+++ b/sql/sql_class.cc 2008-06-26 09:08:27 +0000
@@ -214,12 +214,6 @@ Reprepare_observer::report_error(THD *th
}
-Open_tables_state::Open_tables_state(THD *thd, ulong version_arg)
- :version(version_arg), state_flags(0U)
-{
- reset_open_tables_state(thd);
-}
-
/*
The following functions form part of the C plugin API
*/
@@ -513,7 +507,7 @@ Diagnostics_area::disable_status()
THD::THD()
:Statement(&main_lex, &main_mem_root, CONVENTIONAL_EXECUTION,
/* statement id */ 0),
- Open_tables_state(this, refresh_version), rli_fake(0),
+ rli_fake(0),
lock_id(&main_lock_id),
user_time(0), in_sub_stmt(0),
binlog_table_maps(0), binlog_flags(0UL),
@@ -615,6 +609,9 @@ THD::THD()
slave_net = 0;
command=COM_CONNECT;
*scramble= '\0';
+
+ /* Call to init() below requires fully initialized Open_tables_state. */
+ init_open_tables_state(this, refresh_version);
init();
/* Initialize sub structures */
=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h 2008-06-11 11:49:58 +0000
+++ b/sql/sql_class.h 2008-06-26 09:08:27 +0000
@@ -995,13 +995,22 @@ public:
MDL_CONTEXT mdl_context;
MDL_CONTEXT handler_mdl_context;
- /*
- This constructor serves for creation of Open_tables_state instances
- which are used as backup storage.
+ /**
+ This constructor initializes Open_tables_state instance which can only
+ be used as backup storage. To prepare Open_tables_state instance for
+ operations which open/lock/close tables (e.g. open_table()) one has to
+ call init_open_tables_state().
*/
Open_tables_state() : state_flags(0U) { }
- Open_tables_state(THD *thd, ulong version_arg);
+ /**
+ Prepare Open_tables_state instance for operations dealing with tables.
+ */
+ void init_open_tables_state(THD *thd, ulong version_arg)
+ {
+ reset_open_tables_state(thd);
+ version= version_arg;
+ }
void set_open_tables_state(Open_tables_state *state)
{
| Thread |
|---|
| • bzr commit into mysql-6.0 branch (dlenev:2677) WL#3726 | Dmitry Lenev | 26 Jun |