Skip to content
Permalink
Browse files
MDEV-17781: Server crashes in next_linear_tab
For degenerate joins we may have JOIN::table_list as NULL, so instead
of using JOIN::top_join_tab_count use the function JOIN::exec_join_tab_cnt
to get the number of tables joined at the top level.
  • Loading branch information
Varun Gupta committed May 4, 2019
1 parent ce19598 commit e292c67
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
@@ -3518,5 +3518,23 @@ rank() OVER (ORDER BY 1) ROW_NUMBER() OVER (ORDER BY (EXPORT_SET(5,'Y','N',',',4
1 3
drop table t1;
#
# MDEV-17781: Server crashes in next_linear_tab
#
CREATE TABLE t1 (i1 int);
explain
(SELECT AVG(0) OVER (), MAX('2') FROM t1)
UNION ALL
(SELECT AVG(0) OVER (), MAX('2') FROM t1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
(SELECT AVG(0) OVER (), MAX('2') FROM t1)
UNION ALL
(SELECT AVG(0) OVER (), MAX('2') FROM t1);
AVG(0) OVER () MAX('2')
0.0000 NULL
0.0000 NULL
drop table t1;
#
# End of 10.2 tests
#
@@ -2265,6 +2265,20 @@ insert into t1 values (1),(2),(3);
SELECT rank() OVER (ORDER BY 1), ROW_NUMBER() OVER (ORDER BY (EXPORT_SET(5,'Y','N',',',4))) FROM t1;
drop table t1;

--echo #
--echo # MDEV-17781: Server crashes in next_linear_tab
--echo #

CREATE TABLE t1 (i1 int);
explain
(SELECT AVG(0) OVER (), MAX('2') FROM t1)
UNION ALL
(SELECT AVG(0) OVER (), MAX('2') FROM t1);
(SELECT AVG(0) OVER (), MAX('2') FROM t1)
UNION ALL
(SELECT AVG(0) OVER (), MAX('2') FROM t1);
drop table t1;

--echo #
--echo # End of 10.2 tests
--echo #
@@ -8867,7 +8867,7 @@ JOIN_TAB *next_linear_tab(JOIN* join, JOIN_TAB* tab,
}

/* If no more JOIN_TAB's on the top level */
if (++tab == join->join_tab + join->top_join_tab_count + join->aggr_tables)
if (++tab >= join->join_tab + join->exec_join_tab_cnt() + join->aggr_tables)
return NULL;

if (include_bush_roots == WITHOUT_BUSH_ROOTS && tab->bush_children)

0 comments on commit e292c67

Please sign in to comment.