Skip to content

Commit

Permalink
MDEV-10554: Assertion `!derived->first_select()->exclude_from_table_u…
Browse files Browse the repository at this point in the history
…nique_test || derived->outer_select()-> exclude_from_table_unique_test' failed in TABLE_LIST::set_check_merged()

Mark and check excluded because of merging derived tables and views.
  • Loading branch information
sanja-byelkin committed Feb 10, 2017
1 parent ee51f58 commit ae3072c
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 1 deletion.
18 changes: 18 additions & 0 deletions mysql-test/r/derived.result
Original file line number Diff line number Diff line change
Expand Up @@ -1064,3 +1064,21 @@ DROP TABLE t1;
#
# End of 10.1 tests
#
#
# MDEV-10554: Assertion `!derived->first_select()->
# exclude_from_table_unique_test || derived->outer_select()->
# exclude_from_table_unique_test'
# failed in TABLE_LIST::set_check_merged()
#
CREATE TABLE t1 (f INT);
CREATE ALGORITHM = TEMPTABLE VIEW v1 AS SELECT * FROM ( SELECT * FROM t1 ) AS sq;
PREPARE stmt FROM 'SELECT * FROM v1';
EXECUTE stmt;
f
EXECUTE stmt;
f
drop view v1;
drop table t1;
#
# End of 10.2 tests
#
21 changes: 21 additions & 0 deletions mysql-test/t/derived.test
Original file line number Diff line number Diff line change
Expand Up @@ -910,3 +910,24 @@ DROP TABLE t1;
--echo #
--echo # End of 10.1 tests
--echo #

--echo #
--echo # MDEV-10554: Assertion `!derived->first_select()->
--echo # exclude_from_table_unique_test || derived->outer_select()->
--echo # exclude_from_table_unique_test'
--echo # failed in TABLE_LIST::set_check_merged()
--echo #

CREATE TABLE t1 (f INT);
CREATE ALGORITHM = TEMPTABLE VIEW v1 AS SELECT * FROM ( SELECT * FROM t1 ) AS sq;

PREPARE stmt FROM 'SELECT * FROM v1';
EXECUTE stmt;
EXECUTE stmt;

drop view v1;
drop table t1;

--echo #
--echo # End of 10.2 tests
--echo #
2 changes: 2 additions & 0 deletions sql/sql_lex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2375,6 +2375,8 @@ void st_select_lex_unit::exclude_level()
if (next)
next->prev= prev;
}
// Mark it excluded
prev= NULL;
}


Expand Down
1 change: 1 addition & 0 deletions sql/sql_lex.h
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,7 @@ class st_select_lex_unit: public st_select_lex_node {
st_select_lex* return_after_parsing() { return return_to; }
void exclude_level();
void exclude_tree();
bool is_excluded() { return prev == NULL; }

/* UNION methods */
bool prepare(THD *thd, select_result *result, ulong additional_options);
Expand Down
4 changes: 3 additions & 1 deletion sql/table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5485,7 +5485,8 @@ void TABLE_LIST::set_check_merged()
It is not simple to check all, but at least this should be checked:
this select is not excluded or the exclusion came from above.
*/
DBUG_ASSERT(!derived->first_select()->exclude_from_table_unique_test ||
DBUG_ASSERT(derived->is_excluded() ||
!derived->first_select()->exclude_from_table_unique_test ||
derived->outer_select()->
exclude_from_table_unique_test);
}
Expand All @@ -5498,6 +5499,7 @@ void TABLE_LIST::set_check_materialized()
if (view)
derived= &view->unit;
DBUG_ASSERT(derived);
DBUG_ASSERT(!derived->is_excluded());
if (!derived->first_select()->exclude_from_table_unique_test)
derived->set_unique_exclude();
else
Expand Down

0 comments on commit ae3072c

Please sign in to comment.