summaryrefslogtreecommitdiff
path: root/sql/sql_base.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2018-07-18 19:04:51 +0200
committerSergei Golubchik <serg@mariadb.org>2018-09-04 09:49:52 +0200
commitdd74332d2c5953e861780c1d0de61673406c9653 (patch)
treeeb0b24f15d7730a0432190622ff027034c201da1 /sql/sql_base.cc
parent710093ccb032fa9247e87e6174c91abc40bc567f (diff)
downloadmariadb-git-dd74332d2c5953e861780c1d0de61673406c9653.tar.gz
MDEV-12669 Circular foreign keys cause a loop and OOM upon LOCK TABLE
table_already_fk_prelocked() was looking for a table in the wrong list (not the complete list of prelocked tables, but only in its tail, starting from the current table - which is always empty for the last added table), so for circular FKs it kept adding same tables to the list indefinitely. Backport of d6d7e169fbf
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r--sql/sql_base.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index a1ffa239ef4..be87ad27d6b 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -4893,8 +4893,9 @@ handle_table(THD *thd, Query_tables_list *prelocking_ctx,
else
lock_type= TL_READ;
- if (table_already_fk_prelocked(table_list, fk->foreign_db,
- fk->foreign_table, lock_type))
+ if (table_already_fk_prelocked(prelocking_ctx->query_tables,
+ fk->foreign_db, fk->foreign_table,
+ lock_type))
continue;
TABLE_LIST *tl= (TABLE_LIST *) thd->alloc(sizeof(TABLE_LIST));