Skip to content

Commit

Permalink
MDEV-11240: Server crashes in check_view_single_update or Assertion `…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
sanja-byelkin committed Jul 18, 2017
1 parent 7e44eab commit e7fd6ed
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
14 changes: 14 additions & 0 deletions mysql-test/r/view.result
Original file line number Diff line number Diff line change
Expand Up @@ -5618,6 +5618,20 @@ Warnings:
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)
drop view v1;
drop table t1,t2,t3;
#
# MDEV-11240: Server crashes in check_view_single_update or
# Assertion `derived->table' failed in mysql_derived_merge_for_insert
#
CREATE TABLE t3 (a INT);
CREATE ALGORITHM = MERGE VIEW v1 AS SELECT t2.a FROM t3 AS t1, t3 AS t2;
CREATE ALGORITHM = MERGE VIEW v2 AS SELECT * FROM v1;
PREPARE stmt FROM 'REPLACE INTO v2 SELECT a FROM t3';
EXECUTE stmt;
ERROR HY000: Can not insert into join view 'test.v2' without fields list
EXECUTE stmt;
ERROR HY000: Can not insert into join view 'test.v2' without fields list
drop view v1,v2;
drop table t3;
# -----------------------------------------------------------------
# -- End of 5.5 tests.
# -----------------------------------------------------------------
Expand Down
16 changes: 16 additions & 0 deletions mysql-test/t/view.test
Original file line number Diff line number Diff line change
Expand Up @@ -5565,6 +5565,22 @@ select *
drop view v1;
drop table t1,t2,t3;

--echo #
--echo # MDEV-11240: Server crashes in check_view_single_update or
--echo # Assertion `derived->table' failed in mysql_derived_merge_for_insert
--echo #

CREATE TABLE t3 (a INT);
CREATE ALGORITHM = MERGE VIEW v1 AS SELECT t2.a FROM t3 AS t1, t3 AS t2;
CREATE ALGORITHM = MERGE VIEW v2 AS SELECT * FROM v1;
PREPARE stmt FROM 'REPLACE INTO v2 SELECT a FROM t3';
--error ER_VIEW_NO_INSERT_FIELD_LIST
EXECUTE stmt;
--error ER_VIEW_NO_INSERT_FIELD_LIST
EXECUTE stmt;
drop view v1,v2;
drop table t3;

--echo # -----------------------------------------------------------------
--echo # -- End of 5.5 tests.
--echo # -----------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion sql/sql_derived.cc
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,9 @@ bool mysql_derived_merge_for_insert(THD *thd, LEX *lex, TABLE_LIST *derived)
derived->schema_table= derived->merge_underlying_list->schema_table;
derived->merged_for_insert= TRUE;
}
}
}
else
derived->table= derived->merge_underlying_list->table;
DBUG_RETURN(FALSE);
}

Expand Down

0 comments on commit e7fd6ed

Please sign in to comment.