Skip to content

Commit e7fd6ed

Browse files
committed
MDEV-11240: Server crashes in check_view_single_update or Assertion `derived->table' failed in mysql_derived_merge_for_insert
Move table pointer for single table view (even if it is view over other view) to make the access universal.
1 parent 7e44eab commit e7fd6ed

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

mysql-test/r/view.result

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5618,6 +5618,20 @@ Warnings:
56185618
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`c` = `test`.`t1`.`b`) and (`test`.`t3`.`f` = `test`.`t1`.`a`) and (`test`.`t2`.`d` = `test`.`t3`.`e`) and (`test`.`t1`.`a` is not null) and (`test`.`t1`.`a` is not null) and (`test`.`t1`.`b` is not null))) where (`test`.`t1`.`a` < 5)
56195619
drop view v1;
56205620
drop table t1,t2,t3;
5621+
#
5622+
# MDEV-11240: Server crashes in check_view_single_update or
5623+
# Assertion `derived->table' failed in mysql_derived_merge_for_insert
5624+
#
5625+
CREATE TABLE t3 (a INT);
5626+
CREATE ALGORITHM = MERGE VIEW v1 AS SELECT t2.a FROM t3 AS t1, t3 AS t2;
5627+
CREATE ALGORITHM = MERGE VIEW v2 AS SELECT * FROM v1;
5628+
PREPARE stmt FROM 'REPLACE INTO v2 SELECT a FROM t3';
5629+
EXECUTE stmt;
5630+
ERROR HY000: Can not insert into join view 'test.v2' without fields list
5631+
EXECUTE stmt;
5632+
ERROR HY000: Can not insert into join view 'test.v2' without fields list
5633+
drop view v1,v2;
5634+
drop table t3;
56215635
# -----------------------------------------------------------------
56225636
# -- End of 5.5 tests.
56235637
# -----------------------------------------------------------------

mysql-test/t/view.test

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5565,6 +5565,22 @@ select *
55655565
drop view v1;
55665566
drop table t1,t2,t3;
55675567

5568+
--echo #
5569+
--echo # MDEV-11240: Server crashes in check_view_single_update or
5570+
--echo # Assertion `derived->table' failed in mysql_derived_merge_for_insert
5571+
--echo #
5572+
5573+
CREATE TABLE t3 (a INT);
5574+
CREATE ALGORITHM = MERGE VIEW v1 AS SELECT t2.a FROM t3 AS t1, t3 AS t2;
5575+
CREATE ALGORITHM = MERGE VIEW v2 AS SELECT * FROM v1;
5576+
PREPARE stmt FROM 'REPLACE INTO v2 SELECT a FROM t3';
5577+
--error ER_VIEW_NO_INSERT_FIELD_LIST
5578+
EXECUTE stmt;
5579+
--error ER_VIEW_NO_INSERT_FIELD_LIST
5580+
EXECUTE stmt;
5581+
drop view v1,v2;
5582+
drop table t3;
5583+
55685584
--echo # -----------------------------------------------------------------
55695585
--echo # -- End of 5.5 tests.
55705586
--echo # -----------------------------------------------------------------

sql/sql_derived.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,9 @@ bool mysql_derived_merge_for_insert(THD *thd, LEX *lex, TABLE_LIST *derived)
525525
derived->schema_table= derived->merge_underlying_list->schema_table;
526526
derived->merged_for_insert= TRUE;
527527
}
528-
}
528+
}
529+
else
530+
derived->table= derived->merge_underlying_list->table;
529531
DBUG_RETURN(FALSE);
530532
}
531533

0 commit comments

Comments
 (0)