mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
SQL: open TRT only after versioned write [#305]
This commit is contained in:
@ -1416,22 +1416,13 @@ int ha_commit_trans(THD *thd, bool all)
|
||||
|
||||
if (rw_trans || thd->lex->sql_command == SQLCOM_ALTER_TABLE)
|
||||
{
|
||||
for (Ha_trx_info *hi= ha_info; hi; hi= hi->next())
|
||||
{
|
||||
handlerton *ht= hi->ht();
|
||||
if (opt_transaction_registry &&
|
||||
(ht->flags & HTON_NATIVE_SYS_VERSIONING) &&
|
||||
(thd->lex->sql_command == SQLCOM_ALTER_TABLE ?
|
||||
hi->is_trx_tmp_read_write() :
|
||||
hi->is_trx_read_write()))
|
||||
if (opt_transaction_registry && thd->vers_update_trt)
|
||||
{
|
||||
TR_table trt(thd, true);
|
||||
if (trt.update())
|
||||
goto err;
|
||||
if (all)
|
||||
commit_one_phase_2(thd, false, &thd->transaction.stmt, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4075,8 +4066,6 @@ void handler::mark_trx_read_write_internal()
|
||||
*/
|
||||
if (table_share == NULL || table_share->tmp_table == NO_TMP_TABLE)
|
||||
ha_info->set_trx_read_write();
|
||||
else
|
||||
ha_info->set_trx_tmp_read_write();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1582,21 +1582,11 @@ public:
|
||||
DBUG_ASSERT(is_started());
|
||||
m_flags|= (int) TRX_READ_WRITE;
|
||||
}
|
||||
void set_trx_tmp_read_write()
|
||||
{
|
||||
DBUG_ASSERT(is_started());
|
||||
m_flags|= (int) TRX_TMP_READ_WRITE;
|
||||
}
|
||||
bool is_trx_read_write() const
|
||||
{
|
||||
DBUG_ASSERT(is_started());
|
||||
return m_flags & (int) TRX_READ_WRITE;
|
||||
}
|
||||
bool is_trx_tmp_read_write() const
|
||||
{
|
||||
DBUG_ASSERT(is_started());
|
||||
return m_flags & (int) (TRX_READ_WRITE | TRX_TMP_READ_WRITE);
|
||||
}
|
||||
bool is_started() const { return m_ht != NULL; }
|
||||
/** Mark this transaction read-write if the argument is read-write. */
|
||||
void coalesce_trx_with(const Ha_trx_info *stmt_trx)
|
||||
@ -1621,7 +1611,7 @@ public:
|
||||
return m_ht;
|
||||
}
|
||||
private:
|
||||
enum { TRX_READ_ONLY= 0, TRX_READ_WRITE= 1, TRX_TMP_READ_WRITE= 2 };
|
||||
enum { TRX_READ_ONLY= 0, TRX_READ_WRITE= 1 };
|
||||
/** Auxiliary, used for ha_list management */
|
||||
Ha_trx_info *m_next;
|
||||
/**
|
||||
|
@ -716,6 +716,11 @@ Time_zone * thd_get_timezone(THD * thd)
|
||||
return thd->variables.time_zone;
|
||||
}
|
||||
|
||||
void thd_vers_update_trt(THD * thd)
|
||||
{
|
||||
thd->vers_update_trt= true;
|
||||
}
|
||||
|
||||
THD::THD(my_thread_id id, bool is_wsrep_applier)
|
||||
:Statement(&main_lex, &main_mem_root, STMT_CONVENTIONAL_EXECUTION,
|
||||
/* statement id */ 0),
|
||||
@ -1348,6 +1353,8 @@ void THD::init(void)
|
||||
wsrep_skip_wsrep_GTID = false;
|
||||
#endif /* WITH_WSREP */
|
||||
|
||||
vers_update_trt = false;
|
||||
|
||||
if (variables.sql_log_bin)
|
||||
variables.option_bits|= OPTION_BIN_LOG;
|
||||
else
|
||||
|
@ -4542,6 +4542,9 @@ public:
|
||||
|
||||
/* Handling of timeouts for commands */
|
||||
thr_timer_t query_timer;
|
||||
|
||||
bool vers_update_trt;
|
||||
|
||||
public:
|
||||
void set_query_timer()
|
||||
{
|
||||
|
@ -8380,6 +8380,9 @@ no_commit:
|
||||
/* Step-5: Execute insert graph that will result in actual insert. */
|
||||
error = row_insert_for_mysql((byte*) record, m_prebuilt, vers_set_fields);
|
||||
|
||||
if (m_prebuilt->trx->vers_update_trt)
|
||||
thd_vers_update_trt(m_user_thd);
|
||||
|
||||
DEBUG_SYNC(m_user_thd, "ib_after_row_insert");
|
||||
|
||||
/* Step-6: Handling of errors related to auto-increment. */
|
||||
@ -9199,6 +9202,9 @@ ha_innobase::update_row(
|
||||
error = row_insert_for_mysql((byte*) old_row, m_prebuilt, ROW_INS_HISTORICAL);
|
||||
}
|
||||
|
||||
if (m_prebuilt->trx->vers_update_trt)
|
||||
thd_vers_update_trt(m_user_thd);
|
||||
|
||||
if (error == DB_SUCCESS && autoinc) {
|
||||
/* A value for an AUTO_INCREMENT column
|
||||
was specified in the UPDATE statement. */
|
||||
@ -9318,6 +9324,9 @@ ha_innobase::delete_row(
|
||||
|
||||
error = row_update_for_mysql(m_prebuilt, vers_set_fields);
|
||||
|
||||
if (m_prebuilt->trx->vers_update_trt)
|
||||
thd_vers_update_trt(m_user_thd);
|
||||
|
||||
innobase_srv_conc_exit_innodb(m_prebuilt);
|
||||
|
||||
/* Tell the InnoDB server that there might be work for
|
||||
|
@ -586,6 +586,8 @@ bool thd_is_strict_mode(const MYSQL_THD thd);
|
||||
*/
|
||||
extern void mysql_bin_log_commit_pos(THD *thd, ulonglong *out_pos, const char **out_file);
|
||||
|
||||
extern void thd_vers_update_trt(THD * thd);
|
||||
|
||||
/** Get the partition_info working copy.
|
||||
@param thd Thread object.
|
||||
@return NULL or pointer to partition_info working copy. */
|
||||
|
@ -7079,6 +7079,9 @@ ok_exit:
|
||||
ctx->m_stage, add_v, eval_table,
|
||||
ha_alter_info->handler_flags & Alter_inplace_info::ALTER_DROP_HISTORICAL);
|
||||
|
||||
if (m_prebuilt->trx->vers_update_trt)
|
||||
thd_vers_update_trt(m_user_thd);
|
||||
|
||||
#ifndef DBUG_OFF
|
||||
oom:
|
||||
#endif /* !DBUG_OFF */
|
||||
|
Reference in New Issue
Block a user