// Forward declaration struct mtr_t; struct rw_trx_hash_element_t; class ha_handler_stats;
/******************************************************************//**
Set detailed error message for the transaction. */ void
trx_set_detailed_error( /*===================*/
trx_t* trx, /*!< in: transaction struct */ constchar* msg); /*!< in: detailed error message */ /*************************************************************//**
Set detailed error message for the transaction from a file. Note that the
file is rewinded before reading from it. */ void
trx_set_detailed_error_from_file( /*=============================*/
trx_t* trx, /*!< in: transaction struct */
FILE* file); /*!< in: file to read message from */ /****************************************************************//**
Retrieves the error_info field from a trx.
@return the error info */
UNIV_INLINE const dict_index_t*
trx_get_error_info( /*===============*/ const trx_t* trx); /*!< in: trx object */
/** @return an allocated transaction */
trx_t *trx_create();
/** At shutdown, frees a transaction object. */ void trx_free_at_shutdown(trx_t *trx);
/** Initialize (resurrect) transactions at startup. */
dberr_t trx_lists_init_at_db_start();
/*************************************************************//**
Starts the transaction if it is not yet started. */ void
trx_start_if_not_started_xa_low( /*============================*/
trx_t* trx, /*!< in/out: transaction */ bool read_write); /*!< in: true if read write transaction */ /*************************************************************//**
Starts the transaction if it is not yet started. */ void
trx_start_if_not_started_low( /*=========================*/
trx_t* trx, /*!< in/out: transaction */ bool read_write); /*!< in: true if read write transaction */
/** Startatransactionforinternalprocessing. @paramtrxtransaction
@param read_write whether writes may be performed */ void trx_start_internal_low(trx_t *trx, bool read_write);
/** Commit a transaction */ void trx_commit_for_mysql(trx_t *trx) noexcept; /** XA PREPARE a transaction.
@param[in,out] trx transaction to prepare */ void trx_prepare_for_mysql(trx_t* trx); /**********************************************************************//** This function is used to find number of prepared transactions and
their transaction objects for a recovery.
@return number of prepared transactions */ int
trx_recover_for_mysql( /*==================*/
XID* xid_list, /*!< in/out: prepared transactions */
uint len); /*!< in: number of slots in xid_list */ /** Look up an X/Open distributed transaction in XA PREPARE state. @param[in]xidX/OpenXAtransactionidentifier @returntransactiononmatch(thetrx_t::xidwillbeinvalidated); notethatthetrxmayhavebeencommittedbeforethecalleracquires trx_t::mutex
@retval NULL if no match */
trx_t* trx_get_trx_by_xid(const XID* xid); /** Durably write log until trx->commit_lsn
(if trx_t::commit_in_memory() was invoked with flush_log_later=true). */ void trx_commit_complete_for_mysql(trx_t *trx); /****************************************************************//**
Prepares a transaction for commit/rollback. */ void
trx_commit_or_rollback_prepare( /*===========================*/
trx_t* trx); /*!< in/out: transaction */ /*********************************************************************//**
Creates a commit command node struct.
@return own: commit node struct */
commit_node_t*
trx_commit_node_create( /*===================*/
mem_heap_t* heap); /*!< in: mem heap where created */ /***********************************************************//**
Performs an execution step for a commit type node in a query graph.
@return query thread to run next, or NULL */
que_thr_t*
trx_commit_step( /*============*/
que_thr_t* thr); /*!< in: query thread */
/**********************************************************************//**
Prints info about a transaction. */ void
trx_print_low( /*==========*/
FILE* f, /*!< in: output stream */ const trx_t* trx, /*!< in: transaction */
ulint n_rec_locks, /*!< in: trx->lock.n_rec_locks */
ulint n_trx_locks, /*!< in: length of trx->lock.trx_locks */
ulint heap_size); /*!< in: mem_heap_get_size(trx->lock.lock_heap) */
/**********************************************************************//**
Prints info about a transaction. */ void
trx_print_latched( /*==============*/
FILE* f, /*!< in: output stream */ const trx_t* trx); /*!< in: transaction */
/**********************************************************************//**
Determines if a transaction is in the given state.
The caller must hold trx->mutex, or it must be the thread
that is serving a running transaction.
A running RW transaction must be in trx_sys.rw_trx_hash.
@returnTRUEif trx->state == state */
UNIV_INLINE bool
trx_state_eq( /*=========*/ const trx_t* trx, /*!< in: transaction */
trx_state_t state, /*!< in: state; ifstate!=TRX_STATE_NOT_STARTED assertsthat
trx->state != TRX_STATE_NOT_STARTED */ bool relaxed = false) /*!< in: whether to allow trx->state==TRX_STATE_NOT_STARTED
after an error has been reported */
MY_ATTRIBUTE((nonnull, warn_unused_result));
/**********************************************************************//**
Determines if the currently running transaction has been interrupted.
@returntrueif interrupted */ bool
trx_is_interrupted( /*===============*/ const trx_t* trx); /*!< in: transaction */
/*******************************************************************//**
Calculates the "weight" of a transaction. The weight of one transaction
is estimated as the number of altered rows + the number of locked rows.
@param t transaction
@return transaction weight */ #define TRX_WEIGHT(t) ((t)->undo_no + UT_LIST_GET_LEN((t)->lock.trx_locks))
/** Create the trx_t pool */ void
trx_pool_init();
/** Destroy the trx_t pool */ void
trx_pool_close();
/** Setthetransactionasaread-writetransactionifitisnotalready taggedassuch.
@param[in,out] trx Transaction that needs to be "upgraded" to RW from RO */ void
trx_set_rw_mode(
trx_t* trx);
/** The locks and state of an active transaction. Protected by
lock_sys.latch, trx->mutex or both. */ struct trx_lock_t
{ /** Lock request being waited for. Settononnullwhenholdinglock_sys.latch,lock_sys.wait_mutexand trx->mutex,bythethreadthatisexecutingthetransaction.
Set to nullptr when holding lock_sys.wait_mutex. */
Atomic_relaxed<lock_t*> wait_lock; /** Transaction being waited for; protected by lock_sys.wait_mutex */
trx_t *wait_trx; /** condition variable for !wait_lock; used with lock_sys.wait_mutex */
pthread_cond_t cond; /** lock wait start time */
Atomic_relaxed<my_hrtime_t> suspend_time;
#ifdefined(UNIV_DEBUG) || !defined(DBUG_OFF) /** 2=high priority WSREP thread has marked this trx to abort; 1=anothertransactionchosethisasavictimindeadlockresolution.
Otherthreadsthantheonethatisexecutingthetransactionmayset
flags in this while holding lock_sys.wait_mutex. */
Atomic_relaxed<byte> was_chosen_as_deadlock_victim;
/** Flag the lock owner as a victim in Galera conflict resolution. */ void set_wsrep_victim()
{
was_chosen_as_deadlock_victim.fetch_or(2);
} #else/* defined(UNIV_DEBUG) || !defined(DBUG_OFF) */
/** High priority WSREP thread has marked this trx to abort or anothertransactionchosethisasavictimindeadlockresolution.
Otherthreadsthantheonethatisexecutingthetransactionmayset
this while holding lock_sys.wait_mutex. */
Atomic_relaxed<bool> was_chosen_as_deadlock_victim;
/** Flag the lock owner as a victim in Galera conflict resolution. */ void set_wsrep_victim() { was_chosen_as_deadlock_victim= true; } #endif/* defined(UNIV_DEBUG) || !defined(DBUG_OFF) */
/** Next available rec_pool[] entry */
byte rec_cached; /** Next available table_pool[] entry */
byte table_cached;
que_thr_t* wait_thr; /*!< query thread belonging to this trxthatisinwaiting state.Forthreadssuspendedina lockwait,thisisprotectedby lock_sys.latch.Otherwise,thismay onlybemodifiedbythethreadthatis
serving the running transaction. */
/** Memory heap for trx_locks. Protected by lock_sys.assert_locked()
and lock_sys.is_writer() || trx->mutex_is_owner(). */
mem_heap_t *lock_heap;
/** Locks held by the transaction. Protected by lock_sys.assert_locked() andlock_sys.is_writer()||trx->mutex_is_owner(). (Iflock_sys.latchisonlyheldinsharedmode,thenthemodification
must be protected by trx->mutex.) */
trx_lock_list_t trx_locks;
lock_list table_locks; /*!< All table locks requested by this
transaction, including AUTOINC locks */
/** List of pending trx_t::evict_table() */
UT_LIST_BASE_NODE_T(dict_table_t) evicted_tables;
/** number of record locks; protected by lock_sys.assert_locked(page_id) */
ulint n_rec_locks; /** number of lock_rec_set_nth_bit() calls since the start of transaction;
protected by lock_sys.is_writer() or trx->mutex_is_owner(). */
ulint set_nth_bit_calls;
};
/** Logical first modification time of a table in a transaction */ class trx_mod_table_time_t
{ /** Impossible value for trx_t::undo_no */ static constexpr undo_no_t NONE= ~undo_no_t{0}; /** Theoretical maximum value for trx_t::undo_no. DB_ROLL_PTRisonly7bytes,soitcannotpointtomorethan
this many undo log records. */ static constexpr undo_no_t LIMIT= (undo_no_t{1} << (7 * 8)) - 1;
/** Flag in 'first' to indicate that subsequent operations are coveredbyaTRX_UNDO_EMPTYrecord(forthefirststatementto
insert into an empty table) */ static constexpr undo_no_t BULK= 1ULL << 63;
/** First modification of the table, possibly ORed with BULK */
undo_no_t first; /** First modification of a system versioned column
(NONE= no versioning, BULK= the table was dropped) */
undo_no_t first_versioned= NONE; #ifdef UNIV_DEBUG /** Whether the modified table is a FTS auxiliary table */ bool fts_aux_table= false; #endif/* UNIV_DEBUG */
/** Buffer to store insert opertion */
row_merge_bulk_t *bulk_store= nullptr;
friendstruct trx_t; public: /** Constructor
@param rows number of modified rows so far */
trx_mod_table_time_t(undo_no_t rows) : first(rows) { ut_ad(rows < LIMIT); }
#ifdef UNIV_DEBUG /** Validation @paramrowsnumberofmodifiedrowssofar
@return whether the object is valid */ bool valid(undo_no_t rows= NONE) const
{ auto f= first & LIMIT; return f <= first_versioned && f <= rows; } #endif/* UNIV_DEBUG */ /** @return if versioned columns were modified */ bool is_versioned() const { return (~first_versioned & LIMIT) != 0; } /** @return if the table was dropped */ bool is_dropped() const { return first_versioned == BULK; }
/** After writing an undo log record, set is_versioned() if needed
@param rows number of modified rows so far */ void set_versioned(undo_no_t rows)
{
ut_ad(first_versioned == NONE);
first_versioned= rows;
ut_ad(valid(rows));
}
/** After writing an undo log record, note that the table will be dropped */ void set_dropped()
{
ut_ad(first_versioned == NONE);
first_versioned= BULK;
}
/** Notify the start of a bulk insert operation @paramtabletabletodobulkoperation
@param also_primary start bulk insert operation for primary index */ void start_bulk_insert(dict_table_t *table, bool also_primary)
{
first|= BULK; if (!table->is_temporary())
bulk_store= new row_merge_bulk_t(table, also_primary);
}
/** Notify the end of a bulk insert operation */ void end_bulk_insert() { first&= ~BULK; }
/** @return whether an insert is covered by TRX_UNDO_EMPTY record */ bool is_bulk_insert() const { return first & BULK; }
/** Invoked after partial rollback @paramlimitnumberofsurvivingmodifiedrows(trx_t::undo_no)
@return whether this should be erased from trx_t::mod_tables */ bool rollback(undo_no_t limit)
{
ut_ad(valid()); if ((LIMIT & first) >= limit) returntrue; if (first_versioned < limit)
first_versioned= NONE; returnfalse;
}
/** Collection of persistent tables and their first modification inatransaction. Westorepointerstothetableobjectsinmemorybecause weknowthatatableobjectwillnotbedestroyedwhileatransaction
that modified it is running. */ typedef std::map<
dict_table_t*, trx_mod_table_time_t,
std::less<dict_table_t*>,
ut_allocator<std::pair<dict_table_t* const, trx_mod_table_time_t> > >
trx_mod_tables_t;
*Thelockingcode(inparticular,lock_deadlock_recursive()and lock_rec_convert_impl_to_expl())willaccesstransactionsassociated tootherconnections.Thelocksoftransactionsareprotectedby
lock_sys.latch (insertions also by trx->mutex). */
/** Represents an instance of rollback segment along with its state variables.*/ struct trx_undo_ptr_t {
trx_rseg_t* rseg; /*!< rollback segment assigned to the transaction,orNULLifnotassigned
yet */
trx_undo_t* undo; /*!< pointer to the undo log, or
NULL if nothing logged yet */
};
/** An instance of temporary rollback segment. */ struct trx_temp_undo_t { /** temporary rollback segment, or NULL if not assigned yet */
trx_rseg_t* rseg; /** pointer to the undo log, or NULL if nothing logged yet */
trx_undo_t* undo;
};
/** Rollback segments assigned to a transaction for undo logging. */ struct trx_rsegs_t { /** undo log ptr holding reference to a rollback segment that resides in system/undotablespaceusedforundologgingoftablesthatneeds
to be recovered on crash. */
trx_undo_ptr_t m_redo;
/** undo log for temporary tables; discarded immediately after
transaction commit/rollback */
trx_temp_undo_t m_noredo;
};
public: /** trx_sys.rw_trx_ids index, protected by trx_sys.rw_trx_ids.latch */
uint32_t rw_trx_ids_slot; /** Transaction identifier (0 if no locks were acquired). Setbytrx_sys_t::register_rw()ortrx_resurrect()before thetransactionisaddedtotrx_sys.rw_trx_hash. Clearedincommit_in_memory()aftercommit_state(),
trx_sys_t::deregister_rw(), release_locks(). */
trx_id_t id; union
{ /** The largest encountered transaction identifier for which no transactionwasobservedtobeactive.Thisisacachetospeedup trx_sys_t::find_same_or_older()aswellastoelidesomecallsto trx_sys_t::find().
Thiswillbezero-initializedinPool::Pool()andnotinitialized whenatransactionobjectinthepoolisfreedandreused.The ideaisthatnewtransactionscanreusetheresultof anexpensivetrx_sys_t::find_same_or_older_low()invocationthat wasperformedinanearliertransactionthatusedthesame
memory area. */
trx_id_t max_inactive_id; /** Same as max_inactive_id, for purge_sys.query->trx which may be accessedbymultipleconcurrentthreadsinin trx_sys_t::find_same_or_older_in_purge().Writesareprotectedby
trx_t::mutex. */
Atomic_relaxed<trx_id_t> max_inactive_id_atomic;
};
private: /** mutex protecting state and some of lock
(some are protected by lock_sys.latch) */
srw_spin_mutex mutex; #ifdef UNIV_DEBUG /** The owner of mutex (0 if none); protected by mutex */
std::atomic<pthread_t> mutex_owner{0}; #endif/* UNIV_DEBUG */ public: void mutex_init() { mutex.init(); } void mutex_destroy() { mutex.destroy(); }
TransitionsbetweenNOT_STARTEDandABORTEDcanbeperformedatanytimeby
the thread that is associated with the transaction. */
Atomic_relaxed<trx_state_t> state;
/** The locks of the transaction. Protected by lock_sys.latch
(insertions also by trx_t::mutex). */
alignas(CPU_LEVEL1_DCACHE_LINESIZE) trx_lock_t lock;
/** @return whether the transaction has been started */ bool is_started() const noexcept
{
static_assert(TRX_STATE_NOT_STARTED == 0, "");
static_assert(TRX_STATE_ABORTED == 1, ""); return state > TRX_STATE_ABORTED;
}
/** Consistent read view of the transaction */
ReadView read_view;
/* These fields are not protected by any mutex. */
/** false=normal transaction, true=recovered (must be rolled back) ordisconnectedtransactioninXAPREPARESTATE.
Thisfieldisaccessedbythethreadthatownsthetransaction, withoutholdinganymutex. Thereisonlyoneforeign-threadaccessintrx_print_low()
and a possible race condition with disconnect_prepared(). */ bool is_recovered; constchar* op_info; /*!< English text describing the currentoperation,oranempty
string */ /** TRX_ISO_REPEATABLE_READ, ... */ unsigned isolation_level:2; /** when set, REPEATABLE READ will actually be Snapshot Isolation, due to
detecting write/write conflicts and disabling "semi-consistent read" */ unsigned snapshot_isolation:1; /** normally set; "SET foreign_key_checks=0" can be issued to suppress
foreign key checks, in table imports, for example */ unsigned check_foreigns:1; /** normally set; "SET unique_checks=0, foreign_key_checks=0"
enables bulk insert into an empty table */ unsigned check_unique_secondary:1; /** whether an insert into an empty table is active Possiblestatesare TRX_NO_BULK TRX_DML_BULK TRX_DDL_BULK
@see trx_bulk_insert in trx0types.h */ unsigned bulk_insert:2; /*------------------------------*/ /* MySQL has a transaction coordinator to coordinate two phase commitbetweenmultiplestorageenginesandthebinarylog.When anengineparticipatesinatransaction,it'sresponsiblefor
registering itself using the trans_register_ha() API. */ bool is_registered; /* This flag is set to true after the transactionhasbeenregisteredwith thecoordinatorusingtheXAAPI,and issettofalseaftercommitor
rollback. */ /** whether this is holding the prepare mutex */ bool active_commit_ordered; /** whether innobase_xa_prepare() was done. */ bool active_prepare; /*------------------------------*/ bool flush_log_later;/* In 2PC, we hold the prepare_commitmutexacross bothphases.Inthatcase,we deferflushofthelogstodisk untilafterwereleasethe
mutex. */
byte duplicates; /*!< TRX_DUP_IGNORE | TRX_DUP_REPLACE */ /** whether this modifies InnoDB dictionary tables */ bool dict_operation; #ifdef UNIV_DEBUG /** copy of dict_operation during commit() */ bool was_dict_operation; #endif /** whether dict_sys.latch is held exclusively; protected by
dict_sys.latch */ bool dict_operation_lock_mode;
/** wall-clock time of the latest transition to TRX_STATE_ACTIVE;
used for diagnostic purposes only */
time_t start_time; /** microsecond_interval_timer() of transaction start */
ulonglong start_time_micro;
lsn_t commit_lsn; /*!< lsn at the time of the commit */ /*------------------------------*/
THD* mysql_thd; /*!< MySQL thread handle corresponding
to this trx, or NULL */
/** EXPLAIN ANALYZE statistics, or nullptr if not active */
ha_handler_stats *active_handler_stats; /** number of pages accessed in the buffer pool */
size_t pages_accessed; #ifdef BTR_CUR_HASH_ADAPT /** number of successful adaptive hash index lookups */
size_t n_sea; /** number of B-tree searches without adaptive hash index */
size_t n_non_sea; /** number of rows added to adaptive hash index */
size_t n_ahi_rows_added; /** number of pages added to adaptive hash index */
size_t n_ahi_pages_added; #endif
constchar* mysql_log_file_name; /*!< if MySQL binlog is used, this field containsapointertothelatestfile name;thisisNULLifbinlogisnot
used */
ulonglong mysql_log_offset; /*!< if MySQL binlog is used, this fieldcontainstheendoffsetofthe
binlog entry */ /*------------------------------*/
ib_uint32_t n_mysql_tables_in_use; /*!< number of Innobase tables usedintheprocessingofthecurrent
SQL statement in MySQL */
ib_uint32_t mysql_n_tables_locked; /*!< how many tables the current SQL statementuses,exceptthose
in consistent read */
/** DB_SUCCESS or error code; usually only the thread that is running thetransactionisallowedtomodifythisfield.Theonlyexceptionis whenathreadinvokeslock_sys_t::cancel()inordertoaborta
lock_wait(). That is protected by lock_sys.wait_mutex and lock.wait_lock. */
dberr_t error_state;
const dict_index_t*error_info; /*!< if the error number indicates a duplicatekeyerror,apointerto
the problematic index is stored here */
ulint error_key_num; /*!< if the index creation fails to a duplicatekeyerror,amysqlkey
number of that index is stored here */
que_t* graph; /*!< query currently run in the session, orNULLifnone;NOTEthatthequery belongstothesession,anditcan surviveoveratransactioncommit,if itisastoredprocedurewithaCOMMIT
WORK statement, for instance */ /*------------------------------*/
undo_no_t undo_no; /*!< next undo log record number to assign;sincetheundologis privateforatransaction,this isasimpleascendingsequence withnogaps;thusitrepresents thenumberofmodified/inserted
rows in a transaction */
undo_no_t last_stmt_start; /*!< undo_no when the last sql statement wasstarted:incaseofanerror,trx
is rolled back down to this number */
trx_rsegs_t rsegs; /* rollback segments for undo logging */
undo_no_t roll_limit; /*!< least undo number to undo during
a partial rollback; 0 otherwise */ bool in_rollback; /*!< true when the transaction is
executing a partial or full rollback */
ulint pages_undone; /*!< number of undo log pages undone
since the last undo log truncation */ /*------------------------------*/
ulint n_autoinc_rows; /*!< no. of AUTO-INC rows required for anSQLstatement.Thisisusefulfor
multi-row INSERTs */ typedef small_vector<lock_t*, 4> autoinc_lock_vector; /** AUTO_INCREMENT locks held by this transaction; a subset of trx_locks,
protected by lock_sys.latch. */
autoinc_lock_vector autoinc_locks; /*------------------------------*/ bool read_only; /*!< true if transaction is flagged asaREAD-ONLYtransaction. ifauto_commit&&!will_lock thenitwillbehandledasa AC-NL-RO-SELECT(AutoCommitNon-Locking ReadOnlySelect).Areadonly transactionwillnotbeassignedan
UNDO log. */ bool auto_commit; /*!< true if it is an autocommit */ bool will_lock; /*!< set to inform trx_start_low() that
the transaction may acquire locks */ /* True if transaction has to read the undo log and
log the DML changes for online DDL table */ bool apply_online_log = false;
/*------------------------------*/
fts_trx_t* fts_trx; /*!< FTS information, or NULL if transactionhasn'tmodifiedtables
with FTS indexes (yet). */
doc_id_t fts_next_doc_id;/* The document id used for updates */ /*------------------------------*/
ib_uint32_t flush_tables; /*!< if "covering" the FLUSH TABLES",
count of tables being flushed. */
/*------------------------------*/ #ifdef UNIV_DEBUG unsigned start_line; /*!< Track where it was started from */ constchar* start_file; /*!< Filename where it was started */ #endif/* UNIV_DEBUG */
XID xid; /*!< X/Open XA transaction identificationtoidentifya
transaction branch */
trx_mod_tables_t mod_tables; /*!< List of tables that were modified
by this transaction */ /*------------------------------*/ char* detailed_error; /*!< detailed error message for last
error, or empty. */
rw_trx_hash_element_t *rw_trx_hash_element;
LF_PINS *rw_trx_hash_pins;
ulint magic_n;
/** @return whether any persistent undo log has been generated */ bool has_logged_persistent() const
{ return(rsegs.m_redo.undo);
}
/** @return whether any undo log has been generated */ bool has_logged() const
{ return(has_logged_persistent() || rsegs.m_noredo.undo);
}
/** Transition to committed state, to release implicit locks. */ inlinevoid commit_state();
/** Release any explicit locks of a committing transaction. */ inlinevoid release_locks();
/** Evict a table definition due to the rollback of ALTER TABLE. @paramtable_idtableidentifier
@param reset_only whether to only reset dict_table_t::def_trx_id */ void evict_table(table_id_t table_id, bool reset_only= false);
/** Initiate rollback. @paramsaveptpointertosavepoint;nullptr=entiretransaction
@return error code or DB_SUCCESS */
dberr_t rollback(const undo_no_t *savept= nullptr) noexcept; /** Roll back an active transaction. @paramsaveptpointertosavepoint;nullptr=entiretransaction
@return error code or DB_SUCCESS */
dberr_t rollback_low(const undo_no_t *savept= nullptr) noexcept; /** Finish rollback. @returnwhethertherollbackwascompletednormally
@retval false if the rollback was aborted by shutdown */ bool rollback_finish() noexcept; private: /** Apply any changes to tables for which online DDL is in progress. */
ATTRIBUTE_COLD void apply_log(); /** Process tables that were modified by the committing transaction. */ inlinevoid commit_tables(); /** Mark a transaction committed in the main memory data structures.
@param mtr mini-transaction */ inlinevoid commit_in_memory(mtr_t *mtr); /** Commit the transaction in the file system. */ void commit_persist() noexcept; /** Clean up the transaction after commit_in_memory()
@retval false (always) */ bool commit_cleanup() noexcept; /** Commit an empty transaction.
@param mtr mini-transaction */ void commit_empty(mtr_t *mtr); /** Commit an empty transaction.
@param mtr mini-transaction */ /** Assign the transaction its history serialisation number and write the UNDOlogtotheassignedrollbacksegment.
@param mtr mini-transaction */ inlinevoid write_serialisation_history(mtr_t *mtr); public: /** Commit the transaction.
@retval false (always) */ bool commit() noexcept; /** Disconnect a prepared transaction */ void disconnect_prepared() noexcept;
/** Try to drop a persistent table. @paramtablepersistenttable @paramfkwhethertodropFOREIGNKEYmetadata
@return error code */
dberr_t drop_table(const dict_table_t &table); /** Try to drop the foreign key constraints for a persistent table. @paramnamenameofpersistenttable
@return error code */
dberr_t drop_table_foreign(const table_name_t &name); /** Try to drop the statistics for a persistent table. @paramnamenameofpersistenttable
@return error code */
dberr_t drop_table_statistics(const table_name_t &name); /** Commit the transaction, possibly after drop_table().
@param deleted handles of data files that were deleted */ void commit(std::vector<pfs_os_file_t> &deleted);
/** This has to be invoked on SAVEPOINT or at the end of a statement. EvenifaTRX_UNDO_EMPTYrecordwaswrittenforthistabletocoveran insertintoanemptytable,subsequentoperationswillhavetobecovered byrow-levelundologrecords,sothatROLLBACKTOSAVEPOINTora rollbacktothestartofastatementwillwork.
@param table table on which any preceding bulk insert ended */ void end_bulk_insert(const dict_table_t &table)
{ auto it= mod_tables.find(const_cast<dict_table_t*>(&table)); if (it != mod_tables.end())
it->second.end_bulk_insert();
}
/** @return whether this is a non-locking autocommit transaction */ bool is_autocommit_non_locking() const { return auto_commit && !will_lock; }
/** This has to be invoked on SAVEPOINT or at the start of a statement. EvenifTRX_UNDO_EMPTYrecordswerewrittenforanytabletocoveran insertintoanemptytable,subsequentoperationswillhavetobecovered byrow-levelundologrecords,sothatROLLBACKTOSAVEPOINTora
rollback to the start of a statement will work. */ void end_bulk_insert()
{ if (bulk_insert == TRX_DDL_BULK) return; for (auto& t : mod_tables)
t.second.end_bulk_insert();
}
/** @return whether a bulk insert into empty table is in progress */ bool is_bulk_insert() const
{ switch (bulk_insert) { case TRX_NO_BULK: returnfalse; case TRX_DDL_BULK: returntrue; default:
ut_ad(bulk_insert == TRX_DML_BULK);
} if (check_unique_secondary || check_foreigns) returnfalse; for (constauto& t : mod_tables) if (t.second.is_bulk_insert()) returntrue; returnfalse;
}
/** @returnlogicalmodificationtimeofatable @retvalnullptrifthetabledoesn'thavebulkbufferor
can skip sorting for primary key */
trx_mod_table_time_t *use_bulk_buffer(dict_index_t *index) noexcept
{ if (UNIV_LIKELY(!bulk_insert)) return nullptr;
ut_ad(index->table->skip_alter_undo || !check_unique_secondary);
ut_ad(index->table->skip_alter_undo || !check_foreigns); auto it= mod_tables.find(index->table); if (it == mod_tables.end() || !it->second.bulk_buffer_exist()) return nullptr; /* Avoid using bulk buffer for load statement */ if (index->is_clust() && it->second.skip_sort_pk()) return nullptr; return &it->second;
}
/** Do the bulk insert for the buffered insert operation forthetransaction.
@return DB_SUCCESS or error code */ template<trx_bulk_insert type= TRX_DML_BULK>
dberr_t bulk_insert_apply()
{
static_assert(type != TRX_NO_BULK, ""); return bulk_insert == type ? bulk_insert_apply_low(): DB_SUCCESS;
}
/** This function used only during ALTER IGNORE TABLE command. Resettheundonoandremovetheundologfromtransaction. Bydoingthis,InnoDBdoesn'taddanyundologstopurgequeue
during transaction commit */ inlinevoid reset_and_truncate_undo() noexcept;
private: /** Apply the buffered bulk inserts. */
dberr_t bulk_insert_apply_low();
/** Rollback the bulk insert operation for the transaction */ void bulk_rollback_low(); /** Assign a rollback segment for modifying temporary tables.
@return the assigned rollback segment */
trx_rseg_t *assign_temp_rseg();
};
#define TRX_ISO_REPEATABLE_READ 2/* this is the default; allconsistentreadsinthe sametrxreadthesame snapshot; fullnext-keylockingused inlockingreadstoblock
insertions into gaps */
#define TRX_ISO_SERIALIZABLE 3/* all plain SELECTs are convertedtoLOCKINSHARE
MODE reads */
/* Treatment of duplicate values (trx->duplicates; for example, in inserts).
Multiple flags can be combined with bitwise OR. */ #define TRX_DUP_IGNORE 1U /* duplicate rows are to be updated */ #define TRX_DUP_REPLACE 2U /* duplicate rows are to be replaced */
/** Commit node states */ enum commit_node_state {
COMMIT_NODE_SEND = 1, /*!< about to send a commit signal to
the transaction */
COMMIT_NODE_WAIT /*!< commit signal sent to the transaction,
waiting for completion */
};
/** Commit command node in a query graph */ struct commit_node_t{
que_common_t common; /*!< node type: QUE_NODE_COMMIT */ enum commit_node_state
state; /*!< node execution state */
};
#include"trx0trx.inl"
#endif
Messung V0.5 in Prozent
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.32Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-10-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.