Skip to content

Commit ae3072c

Browse files
committed
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()
Mark and check excluded because of merging derived tables and views.
1 parent ee51f58 commit ae3072c

File tree

5 files changed

+45
-1
lines changed

5 files changed

+45
-1
lines changed

mysql-test/r/derived.result

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,3 +1064,21 @@ DROP TABLE t1;
10641064
#
10651065
# End of 10.1 tests
10661066
#
1067+
#
1068+
# MDEV-10554: Assertion `!derived->first_select()->
1069+
# exclude_from_table_unique_test || derived->outer_select()->
1070+
# exclude_from_table_unique_test'
1071+
# failed in TABLE_LIST::set_check_merged()
1072+
#
1073+
CREATE TABLE t1 (f INT);
1074+
CREATE ALGORITHM = TEMPTABLE VIEW v1 AS SELECT * FROM ( SELECT * FROM t1 ) AS sq;
1075+
PREPARE stmt FROM 'SELECT * FROM v1';
1076+
EXECUTE stmt;
1077+
f
1078+
EXECUTE stmt;
1079+
f
1080+
drop view v1;
1081+
drop table t1;
1082+
#
1083+
# End of 10.2 tests
1084+
#

mysql-test/t/derived.test

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,3 +910,24 @@ DROP TABLE t1;
910910
--echo #
911911
--echo # End of 10.1 tests
912912
--echo #
913+
914+
--echo #
915+
--echo # MDEV-10554: Assertion `!derived->first_select()->
916+
--echo # exclude_from_table_unique_test || derived->outer_select()->
917+
--echo # exclude_from_table_unique_test'
918+
--echo # failed in TABLE_LIST::set_check_merged()
919+
--echo #
920+
921+
CREATE TABLE t1 (f INT);
922+
CREATE ALGORITHM = TEMPTABLE VIEW v1 AS SELECT * FROM ( SELECT * FROM t1 ) AS sq;
923+
924+
PREPARE stmt FROM 'SELECT * FROM v1';
925+
EXECUTE stmt;
926+
EXECUTE stmt;
927+
928+
drop view v1;
929+
drop table t1;
930+
931+
--echo #
932+
--echo # End of 10.2 tests
933+
--echo #

sql/sql_lex.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2375,6 +2375,8 @@ void st_select_lex_unit::exclude_level()
23752375
if (next)
23762376
next->prev= prev;
23772377
}
2378+
// Mark it excluded
2379+
prev= NULL;
23782380
}
23792381

23802382

sql/sql_lex.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,7 @@ class st_select_lex_unit: public st_select_lex_node {
698698
st_select_lex* return_after_parsing() { return return_to; }
699699
void exclude_level();
700700
void exclude_tree();
701+
bool is_excluded() { return prev == NULL; }
701702

702703
/* UNION methods */
703704
bool prepare(THD *thd, select_result *result, ulong additional_options);

sql/table.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5485,7 +5485,8 @@ void TABLE_LIST::set_check_merged()
54855485
It is not simple to check all, but at least this should be checked:
54865486
this select is not excluded or the exclusion came from above.
54875487
*/
5488-
DBUG_ASSERT(!derived->first_select()->exclude_from_table_unique_test ||
5488+
DBUG_ASSERT(derived->is_excluded() ||
5489+
!derived->first_select()->exclude_from_table_unique_test ||
54895490
derived->outer_select()->
54905491
exclude_from_table_unique_test);
54915492
}
@@ -5498,6 +5499,7 @@ void TABLE_LIST::set_check_materialized()
54985499
if (view)
54995500
derived= &view->unit;
55005501
DBUG_ASSERT(derived);
5502+
DBUG_ASSERT(!derived->is_excluded());
55015503
if (!derived->first_select()->exclude_from_table_unique_test)
55025504
derived->set_unique_exclude();
55035505
else

0 commit comments

Comments
 (0)