summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/sql_class.cc11
-rw-r--r--sql/sql_class.h17
2 files changed, 17 insertions, 11 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index d36ea5c52c9..ff1b03102a6 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -202,12 +202,6 @@ bool foreign_key_prefix(Key *a, Key *b)
** Thread specific functions
****************************************************************************/
-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
*/
@@ -440,7 +434,7 @@ bool Drop_table_error_handler::handle_condition(THD *thd,
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),
sql_log_bin_toplevel(false),
@@ -542,6 +536,9 @@ THD::THD()
command=COM_CONNECT;
*scramble= '\0';
+ /* Call to init() below requires fully initialized Open_tables_state. */
+ init_open_tables_state(this, refresh_version);
+
init();
#if defined(ENABLED_PROFILING)
profiling.set_thd(this);
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 68ae3afe931..a5236201724 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -984,13 +984,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)
{