diff options
author | Oleg Smirnov <olernov@gmail.com> | 2023-01-02 14:46:46 +0700 |
---|---|---|
committer | Oleg Smirnov <olernov@gmail.com> | 2023-01-02 14:46:50 +0700 |
commit | 657ddf17491740f652f011458f03366e70c4728f (patch) | |
tree | b0d31279d3848424dab3a1260a59fcd2cebdc1b4 /sql/sql_select.h | |
parent | 92665b862b479f6582e3a15247bfc812e59e7e34 (diff) | |
download | mariadb-git-10.9-MDEV-16232.tar.gz |
MDEV-16232: Use fewer mini-transactions10.9-MDEV-16232
SQL Layer support #3.
Add checks of applicability for UPDATEs and DELETEs.
Rename "operations batch" to "mini transactions" to disambiguate
the term "batch" which is already used.
Temporary disable mini-transactions for SELECTs.
Diffstat (limited to 'sql/sql_select.h')
-rw-r--r-- | sql/sql_select.h | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/sql/sql_select.h b/sql/sql_select.h index 260f31c5822..40bef5caaca 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -2483,6 +2483,52 @@ void propagate_new_equalities(THD *thd, Item *cond, bool *is_simplifiable_cond); bool dbug_user_var_equals_str(THD *thd, const char *name, const char *value); -bool can_use_operations_batch(TABLE_LIST *query_tables); +bool can_use_mini_transaction(const TABLE_LIST *query_tables, + const SQL_SELECT *select, + bool has_triggers, + bool is_referenced_by_foreign_keys); + +/* + This class provides automatic call of handler::end_mini_transaction() + on destruction (going out of scope), so one doesn't have to track all the + execution paths to call end_mini_transaction() explicitly. + + Example of usage: + + { + Mini_transaction_guard mini_trx(table->file); + mini_trx.start(); // start_mini_transaction() is called + ... + if (cond) + goto label1; // end_mini_transaction() is called on mini_trx going out + // of scope and destruction + ... + } // end_mini_transaction() is called on mini_trx going out + // of scope and destruction +*/ +class Mini_transaction_guard +{ +public: + explicit Mini_transaction_guard(handler *h) : hnd(h) + {} + + Mini_transaction_guard()= delete; + + void start() + { + hnd->start_mini_transaction(); + started= true; + } + + ~Mini_transaction_guard() + { + if (started) + hnd->end_mini_transaction(); + } + +private: + handler *hnd= nullptr; + bool started= false; +}; #endif /* SQL_SELECT_INCLUDED */ |