/** Comparator action for deciding how to treat a record */ enumclass RecordCompareAction
{ /** Process this record via process_record */
PROCESS, /** Do not process this record, continue traversal */
SKIP, /** Stop traversal immediately */
STOP
};
using RecordProcessor= std::function<dberr_t( const rec_t*, const dict_index_t*, const rec_offs*)>;
/** Record processing callback interface using std::function. CanbeusedbyFTS,statsinfrastructure,andothercomponents thatneedtoprocessdatabaserecordswithcustomlogic. Whatthisreplaces,inSQLterms: Theoldinternal-parserpathexpressedeachscanas SELECT<columns>FROM<table>WHERE<comparatorpredicate> andranagraph-nodeFETCHthatinvokedarow-consumercallbackfor everyvisiblerow.RecordCallbackcollapsesbothpiecesintoone C++object: -compare_record()istheWHEREpredicate,returning PROCESS/SKIP/STOPforthecurrentcandidate. -process_record()istherowconsumer. TheB-treetraversalthattheoldgraphrunnerdroveisnowdriven byrow_search_mvcc_callback()directly,withnoSQLstringparsing
and no graph allocation per call. */ class RecordCallback
{ public: /** Constructor with processor function and optional comparator @paramprocessorFunctiontoprocesseachrecord
@param comparator Optional function to filter records */
RecordCallback(
RecordProcessor processor,
RecordComparator comparator= nullptr)
: process_record(std::move(processor)),
compare_record(std::move(comparator)) {}
virtual ~RecordCallback()= default;
/** Called for each matching record */ const RecordProcessor process_record;
/** Comparison function for custom filtering */ const RecordComparator compare_record;
};
/** General-purpose MVCC-aware record traversal and basic DMLexecutor.ProvidesathinabstractionoverB-treecursorsfor readingandmutatingrecordswithconsistent-read(MVCC)handling, andcallbackAPI. -Openanditerateclustered/secondaryindexeswithpagecursors. -Buildconsistent-readversionswhenneededviatransaction readviews. -FilterandprocessrecordsusingRecordCallback: -compare_record:decideSKIP/PROCESS/STOPforeachrecord -process_record:handlevisiblerecords;returnDB_SUCCESStocontinue,DB_SUCCESS_LOCKED_RECtostop -BasicDMLhelpers(insert/delete/replace)andtablelocking.
/** Insert a record in clustered index of the table @paramtabletabletobeinserted @paramtupletupletobeinserted
@return DB_SUCCESS on success, error code on failure */
dberr_t insert_record(dict_table_t *table, dtuple_t *tuple) noexcept;
/** Delete a record from the clustered index of the table @paramtabletabletobeinserted @paramtupletupletobeinserted
@return DB_SUCCESS on success, error code on failure */
dberr_t delete_record(dict_table_t *table, dtuple_t *tuple) noexcept;
/** Delete all records from the clustered index of the table @paramtabletablebebedeleted
@return DB_SUCCESS on success, error code on failure */
dberr_t delete_all(dict_table_t *table) noexcept;
/** Acquire and lock a single clustered record for update Performsakeyedlookupontheclusteredindex,validatesMVCCvisibility, andacquiresanXlockonthematchingrecord. @param[in]tableTablecontainingtherecord @param[in]search_tupleExactkeyforclusteredindexlookup @param[in]callbackOptionalrecordcallback @returnDB_SUCCESSonsuccessfullock DB_RECORD_NOT_FOUNDifnovisiblematchingrecord DB_LOCK_WAITifwaitingwasrequired
error code on failure */
dberr_t select_for_update(dict_table_t *table, dtuple_t *search_tuple,
RecordCallback *callback= nullptr) noexcept;
/** Update the currently selected clustered record within an active mtr. Attemptsin-placeupdate;fallsbacktooptimistic/pessimisticupdateifneeded, includingexternalfieldstoragewhenrequired. select_for_update()haspositionedandlockedm_pcuronthetargetrow.
/** Try to update a record by key or insert if not found. PerformsaSELECT...FORUPDATEusingsearch_tuple; iffound,updatestherow;otherwiseinsertsanewrecord. Note: Onupdatepath,commitsorrollsbacktheactivemtrasneeded. Oninsertpath,noactivemtrremainsuponreturn @param[in]tabletargettable @param[in]search_tuplekeyidentifyingthetargetrow @param[in]updateupdatedescriptor(appliedwhenfound) @param[in]insert_tupletupletoinsertwhennotfound @returnDB_SUCCESSonsuccessfulupdateorinsert @retvalDB_LOCK_WAITtoberetried,
@return error code on failure */
dberr_t replace_record(dict_table_t *table, dtuple_t *search_tuple, const upd_t *update, dtuple_t *insert_tuple) noexcept;
/** Iterate clustered index records and process via callback. Handlesfulltablescanandindexscanforrange/selectqueries Callscallback.compare_record()todecideSKIP/PROCESS/STOPfor eachmatchingrecord.OnPROCESS,invokes callback.process_record()onanMVCC-visibleversion. @paramtabletabletoread @paramtupleoptionalsearchkey(range/point).nullptr=>fullscan @parammodeB-treesearchmode(e.g.,PAGE_CUR_GE) @paramcallbackrecordcomparator/processor @returnDB_SUCCESSifatleastonerecordwasprocessed @retvalDB_RECORD_NOT_FOUNDifnorecordmatched
@return error code on failure */
dberr_t read(dict_table_t *table, const dtuple_t *tuple,
page_cur_mode_t mode,
RecordCallback& callback) noexcept;
/** Read records via a secondary index and process corresponding clusteredrows.Performsarangeorpointscanonthegivensecondaryindex, filterssecondaryrecordswithcallback.compare_record(),thenlooksup thematchingclusteredrecordandinvokescallback.process_record() onaMVCC-visibleversion.
/** Acquire a table lock in the given mode for transaction. @paramtabletabletolock @parammodelockmode
@return DB_SUCCESS, DB_LOCK_WAIT or error code */
dberr_t lock_table(dict_table_t *table, lock_mode mode) noexcept;
/** Handle a lock wait for the current transaction and thread context. @paramerrthelock-relatederrortohandle(e.g.,DB_LOCK_WAIT) @paramtable_locktrueifthewaitoriginatedfromtablelock,elserowlock @returnDB_SUCCESSifthewaitcompletedsuccessfullyandlockwasgranted
@retval DB_LOCK_WAIT_TIMEOUT if timed out */
dberr_t handle_wait(dberr_t err, bool table_lock) noexcept;
mem_heap_t *get_heap() const { return m_heap; }
trx_t *get_trx() const { return m_trx; } void commit_mtr() noexcept
{ if (m_mtr)
m_mtr->commit();
}
};
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.6 Sekunden
(vorverarbeitet am 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.