1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

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
193896c466
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
This commit is contained in:
Daniel Black
2021-03-05 17:25:15 +11:00
parent 058484687a
commit 553ef1a78b
28 changed files with 446 additions and 43 deletions

View File

@ -177,6 +177,7 @@ struct st_join_table;
typedef struct st_reginfo { /* Extra info about reg */
struct st_join_table *join_tab; /* Used by SELECT() */
enum thr_lock_type lock_type; /* How database is used */
bool skip_locked;
bool not_exists_optimize;
/*
TRUE <=> range optimizer found that there is no rows satisfying
@ -807,13 +808,14 @@ public:
uint defined_lock:1;
uint update_lock:1;
uint defined_timeout:1;
uint skip_locked:1;
};
ulong timeout;
void empty()
{
defined_lock= update_lock= defined_timeout= FALSE;
defined_lock= update_lock= defined_timeout= skip_locked= FALSE;
timeout= 0;
}
void set_to(st_select_lex *sel);