@@ -8484,22 +8484,38 @@ LEX_CSTRING *fk_option_name(enum_fk_option opt)
84848484 return names + opt;
84858485}
84868486
8487- TR_table::TR_table (THD* _thd, bool rw) : thd(_thd)
8487+ TR_table::TR_table (THD* _thd, bool rw) :
8488+ thd(_thd), open_tables_backup(NULL )
84888489{
84898490 init_one_table (LEX_STRING_WITH_LEN (MYSQL_SCHEMA_NAME),
84908491 LEX_STRING_WITH_LEN (TRANSACTION_REG_NAME),
84918492 TRANSACTION_REG_NAME.str , rw ? TL_WRITE : TL_READ);
8493+ }
8494+
8495+ bool TR_table::open ()
8496+ {
8497+ DBUG_ASSERT (!table);
84928498 open_tables_backup= new Open_tables_backup;
8493- if (open_tables_backup)
8494- open_log_table (thd, this , open_tables_backup);
8495- else
8499+ if (!open_tables_backup)
8500+ {
84968501 my_error (ER_OUT_OF_RESOURCES, MYF (0 ));
8502+ return true ;
8503+ }
8504+
8505+ All_tmp_tables_list *temporary_tables= thd->temporary_tables ;
8506+ bool error= !open_log_table (thd, this , open_tables_backup);
8507+ thd->temporary_tables = temporary_tables;
8508+
8509+ return error;
84978510}
84988511
84998512TR_table::~TR_table ()
85008513{
85018514 if (table)
8515+ {
8516+ thd->temporary_tables = NULL ;
85028517 close_log_table (thd, open_tables_backup);
8518+ }
85038519 delete open_tables_backup;
85048520}
85058521
@@ -8532,16 +8548,17 @@ enum_tx_isolation TR_table::iso_level() const
85328548 return res;
85338549}
85348550
8535- bool TR_table::update (bool &updated )
8551+ bool TR_table::update ()
85368552{
8537- if (!table)
8553+ if (!table && open () )
85388554 return true ;
85398555
85408556 DBUG_ASSERT (table->s );
85418557 handlerton *hton= table->s ->db_type ();
85428558 DBUG_ASSERT (hton);
85438559 DBUG_ASSERT (hton->flags & HTON_NATIVE_SYS_VERSIONING);
85448560
8561+ bool updated;
85458562 if ((updated= hton->vers_get_trt_data (*this )))
85468563 {
85478564 int error= table->file ->ha_write_row (table->record [0 ]);
@@ -8557,7 +8574,7 @@ bool TR_table::update(bool &updated)
85578574#define newx new (thd->mem_root)
85588575bool TR_table::query (ulonglong trx_id)
85598576{
8560- if (!table)
8577+ if (!table && open () )
85618578 return false ;
85628579 SQL_SELECT_auto select;
85638580 READ_RECORD info;
@@ -8587,7 +8604,7 @@ bool TR_table::query(ulonglong trx_id)
85878604
85888605bool TR_table::query (MYSQL_TIME &commit_time, bool backwards)
85898606{
8590- if (!table)
8607+ if (!table && open () )
85918608 return false ;
85928609 SQL_SELECT_auto select;
85938610 READ_RECORD info;
@@ -8684,13 +8701,13 @@ bool TR_table::query_sees(bool &result, ulonglong trx_id1, ulonglong trx_id0,
86848701 return false ;
86858702}
86868703
8687- bool TR_table::check () const
8704+ bool TR_table::check ()
86888705{
86898706 // InnoDB may not be loaded
86908707 if (!ha_resolve_by_legacy_type (thd, DB_TYPE_INNODB))
86918708 return false ;
86928709
8693- if (!table )
8710+ if (open () )
86948711 return true ;
86958712
86968713 if (table->file ->ht ->db_type != DB_TYPE_INNODB)
0 commit comments