summaryrefslogtreecommitdiff
path: root/sql/sql_view.cc
diff options
context:
space:
mode:
authorDyre Tjeldvoll <Dyre.Tjeldvoll@oracle.com>2015-04-30 12:56:33 +0200
committerSergey Vojtovich <svoj@mariadb.org>2018-10-17 19:59:44 +0400
commit2be83a28a2cdecad28d28f04a0dfeff2eb5ff957 (patch)
treee199d4405666b5d90d6ea505b1821f81dbb6c045 /sql/sql_view.cc
parente31e697f17f79ffa6913499e7e2d29866f24b475 (diff)
downloadmariadb-git-bb-5.5-svoj.tar.gz
BUG#19988193: ASSERTION `(*TABLES)->REGINFO.LOCK_TYPE >= TL_READ'bb-5.5-svoj
FAILED IN LOCK_EXTERNAL BUG#21198646: ASSERTION FAILED: (*TABLES)->REGINFO.LOCK_TYPE >= TL_READ FILE LOCK.CC, LINE 356 This patch addresses two related issues: Calling a procedure which creates a view from a trigger (BUG#19988193), and creating a function calling a procedure doing RENAME TABLE (BUG#21198646), could both, in certain circumstances, trigger an assert. Root cause was that prelocking of tables with lock_type==TL_IGNORE is not supported, and so triggers an assert. TL_IGNORE is only used for source tables in CREATE VIEW statements and the table of a RENAME TABLE statement. It is very unusual for these statements to be part of prelocking analysis, as both are implicit commit statements which are not permitted in triggers and stored functions/procedures. But as the test cases show; it is possible to have such statements contribute to the prelocking set, but in both cases the statement is "meaningless", in the sense that it will trigger an error during execution. Fix: In mysql_make_view(), avoid adding the backing tables to view_ref if view_ref->prelocking_placeholder==true and lock_type==TL_IGNORE. In sp_head::add_used_tables_to_table_list() skip SP_TABLES which have lock_type=TL_IGNORE. Test: New test cases added to tablelock.test
Diffstat (limited to 'sql/sql_view.cc')
-rw-r--r--sql/sql_view.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 5bd82fdd842..39d77cacf44 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -1464,8 +1464,15 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
NOTE: It is important for UPDATE/INSERT/DELETE checks to have this
tables just after VIEW instead of tail of list, to be able check that
table is unique. Also we store old next table for the same purpose.
+
+ If prelocking a view which has lock_type==TL_IGNORE we cannot add
+ the tables, as that would result in tables with
+ lock_type==TL_IGNORE being added to the prelocking set. That, in
+ turn, would lead to lock_external() being called on those tables,
+ which is not permitted (causes assert).
*/
- if (view_tables)
+ if (view_tables && !(table->prelocking_placeholder &&
+ table->lock_type == TL_IGNORE))
{
if (table->next_global)
{