summaryrefslogtreecommitdiff
path: root/sql/table.h
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2020-05-05 14:55:05 +0200
committerSergei Golubchik <serg@mariadb.org>2020-05-06 20:24:48 +0200
commit0fcc3abf4a0b64932dbd5fb2a3a8d466c9a5f4a9 (patch)
tree23e8c9f7566f83c2cfe5b3cb18e8d2ef8f5ec2db /sql/table.h
parent10aaa77509869153b998898d46943ec0949b5784 (diff)
downloadmariadb-git-0fcc3abf4a0b64932dbd5fb2a3a8d466c9a5f4a9.tar.gz
MDEV-22180 Planner opens unnecessary tables when updated table is referenced by foreign keys
only MDL-prelock but do not open FK child tables for read-only (RESTRICT) FK actions. Tables still needs to be opened for CASCADE actions, see 9180e8666b8
Diffstat (limited to 'sql/table.h')
-rw-r--r--sql/table.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/sql/table.h b/sql/table.h
index 44803b5aacd..29b4cfdbcf3 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -1813,6 +1813,9 @@ struct TABLE_LIST
open_type= routine ? OT_TEMPORARY_OR_BASE : OT_BASE_ONLY;
belong_to_view= belong_to_view_arg;
trg_event_map= trg_event_map_arg;
+ /* MDL is enough for read-only FK checks, we don't need the table */
+ if (prelocking_placeholder == FK && lock_type < TL_WRITE_ALLOW_WRITE)
+ open_strategy= OPEN_STUB;
**last_ptr= this;
prev_global= *last_ptr;