Commit b0d11675 authored by unknown's avatar unknown

Fix of MDEV-589.

The problem was in incorrect detection of merged views in tem_direct_view_ref::used_tables() .
parent c56fd181
......@@ -4567,6 +4567,27 @@ id id bbb iddqd val1
30631 NULL NULL NULL NULL
drop view v2;
drop table t1,t2;
#
# MDEV-589 (LP BUG#1007647) :
# Assertion `vcol_table == 0 || vcol_table == table' failed in
# fill_record(THD*, List<Item>&, List<Item>&, bool)
#
CREATE TABLE t1 (f1 INT, f2 INT);
CREATE TABLE t2 (f1 INT, f2 INT);
CREATE ALGORITHM=MERGE VIEW v1 AS SELECT a1.f1, a2.f2 FROM t1 AS a1, t1 AS a2;
CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM v1;
CREATE ALGORITHM=MERGE VIEW v3 AS SELECT a1.f1, a2.f2 FROM t1 AS a1, t2 AS a2;
CREATE ALGORITHM=MERGE VIEW v4 AS SELECT * FROM v3;
INSERT INTO v3 (f1, f2) VALUES (1, 2);
ERROR HY000: Can not modify more than one base table through a join view 'test.v3'
INSERT INTO v1 (f1, f2) VALUES (1, 2);
ERROR HY000: Can not modify more than one base table through a join view 'test.v1'
INSERT INTO v4 (f1, f2) VALUES (1, 2);
ERROR HY000: Can not modify more than one base table through a join view 'test.v4'
INSERT INTO v2 (f1, f2) VALUES (1, 2);
ERROR HY000: Can not modify more than one base table through a join view 'test.v2'
drop view v4,v3,v2,v1;
drop table t1,t2;
# -----------------------------------------------------------------
# -- End of 5.3 tests.
# -----------------------------------------------------------------
......
......@@ -4503,6 +4503,29 @@ create algorithm=MERGE view v2 as select 2 as id, id is null as bbb, id as iddqd
select t1.*, v2.* from t1 left join v2 on t1.id = v2.id;
drop view v2;
drop table t1,t2;
--echo #
--echo # MDEV-589 (LP BUG#1007647) :
--echo # Assertion `vcol_table == 0 || vcol_table == table' failed in
--echo # fill_record(THD*, List<Item>&, List<Item>&, bool)
--echo #
CREATE TABLE t1 (f1 INT, f2 INT);
CREATE TABLE t2 (f1 INT, f2 INT);
CREATE ALGORITHM=MERGE VIEW v1 AS SELECT a1.f1, a2.f2 FROM t1 AS a1, t1 AS a2;
CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM v1;
CREATE ALGORITHM=MERGE VIEW v3 AS SELECT a1.f1, a2.f2 FROM t1 AS a1, t2 AS a2;
CREATE ALGORITHM=MERGE VIEW v4 AS SELECT * FROM v3;
--error ER_VIEW_MULTIUPDATE
INSERT INTO v3 (f1, f2) VALUES (1, 2);
--error ER_VIEW_MULTIUPDATE
INSERT INTO v1 (f1, f2) VALUES (1, 2);
--error ER_VIEW_MULTIUPDATE
INSERT INTO v4 (f1, f2) VALUES (1, 2);
--error ER_VIEW_MULTIUPDATE
INSERT INTO v2 (f1, f2) VALUES (1, 2);
drop view v4,v3,v2,v1;
drop table t1,t2;
--echo # -----------------------------------------------------------------
--echo # -- End of 5.3 tests.
--echo # -----------------------------------------------------------------
......
......@@ -9175,7 +9175,7 @@ table_map Item_direct_view_ref::used_tables() const
{
return get_depended_from() ?
OUTER_REF_TABLE_BIT :
((view->merged || !view->table) ?
((view->is_merged_derived() || view->merged || !view->table) ?
(*ref)->used_tables() :
view->table->map);
}
......@@ -9184,7 +9184,7 @@ table_map Item_direct_view_ref::not_null_tables() const
{
return get_depended_from() ?
0 :
((view->merged || !view->table) ?
((view->is_merged_derived() || view->merged || !view->table) ?
(*ref)->not_null_tables() :
view->table->map);
}
......
......@@ -1600,6 +1600,7 @@ struct TABLE_LIST
/* TRUE <=> derived table should be filled right after optimization. */
bool fill_me;
/* TRUE <=> view/DT is merged. */
/* TODO: replace with derived_type */
bool merged;
bool merged_for_insert;
/* TRUE <=> don't prepare this derived table/view as it should be merged.*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment