summaryrefslogtreecommitdiff
path: root/sql/sql_parse.cc
diff options
context:
space:
mode:
authorDaniel Black <daniel@mariadb.org>2021-03-05 17:25:15 +1100
committerDaniel Black <daniel@mariadb.org>2021-04-08 16:51:36 +1000
commit553ef1a78ba7ba6961c3c99887d405694a04e91b (patch)
tree930ce270376bbaa0b52fe22576a83afbb1109ff7 /sql/sql_parse.cc
parent058484687aa49326b8a7909499e7a8d1aba02953 (diff)
downloadmariadb-git-553ef1a78ba7ba6961c3c99887d405694a04e91b.tar.gz
MDEV-13115: Implement SELECT SKIP LOCKED
Adds an implementation for SELECT ... FOR UPDATE SKIP LOCKED / SELECT ... LOCK IN SHARED MODE SKIP LOCKED This is implemented only InnoDB at the moment, not in RockDB yet. This adds a new hander flag HA_CAN_SKIP_LOCKED than will be used when the storage engine advertises the flag. When a storage engine indicates this flag it will get TL_WRITE_SKIP_LOCKED and TL_READ_SKIP_LOCKED transaction types. The Lex structure has been updated to store both the FOR UPDATE/LOCK IN SHARE as well as the SKIP LOCKED so the SHOW CREATE VIEW implementation is simplier. "SELECT FOR UPDATE ... SKIP LOCKED" combined with CREATE TABLE AS or INSERT.. SELECT on the result set is not safe for STATEMENT based replication. MIXED replication will replicate this as row based events." Thanks to guidance from Facebook commit https://github.com/facebook/mysql-5.6/commit/193896c466d43fd905a62a60f1d73fd9c551a6e4 This helped verify basic test case, and components that need implementing (even though every part was implemented differently). Thanks Marko for guidance on simplier InnoDB implementation. Reviewers: Marko, Monty
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r--sql/sql_parse.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 1ce4b589d7b..cca08c9007f 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -8875,7 +8875,8 @@ bool st_select_lex::add_window_spec(THD *thd,
/**
Set lock for all tables in current select level.
- @param lock_type Lock to set for tables
+ @param lock_type Lock to set for tables
+ @param skip_locked (SELECT {FOR UPDATE/LOCK IN SHARED MODE} SKIP LOCKED)
@note
If lock is a write lock, then tables->updating is set 1
@@ -8883,16 +8884,19 @@ bool st_select_lex::add_window_spec(THD *thd,
query
*/
-void st_select_lex::set_lock_for_tables(thr_lock_type lock_type, bool for_update)
+void st_select_lex::set_lock_for_tables(thr_lock_type lock_type, bool for_update,
+ bool skip_locked_arg)
{
DBUG_ENTER("set_lock_for_tables");
- DBUG_PRINT("enter", ("lock_type: %d for_update: %d", lock_type,
- for_update));
+ DBUG_PRINT("enter", ("lock_type: %d for_update: %d skip_locked %d",
+ lock_type, for_update, skip_locked));
+ skip_locked= skip_locked_arg;
for (TABLE_LIST *tables= table_list.first;
tables;
tables= tables->next_local)
{
tables->lock_type= lock_type;
+ tables->skip_locked= skip_locked;
tables->updating= for_update;
tables->mdl_request.set_type((lock_type >= TL_FIRST_WRITE) ?
MDL_SHARED_WRITE : MDL_SHARED_READ);