From 0b30ce4f31cfbaad9582432d35e3c38464eba08e Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Mon, 7 Aug 2017 16:04:38 +0300 Subject: MDEV-13374: Server crashes in first_linear_tab / st_select_lex::set_explain_type - Support first_linear_tab() traversal for degenerate joins --- sql/sql_select.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'sql/sql_select.cc') diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 90f5e11dd16..ba3760dd948 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -8627,7 +8627,7 @@ JOIN_TAB *first_top_level_tab(JOIN *join, enum enum_with_const_tables const_tbls JOIN_TAB *tab= join->join_tab; if (const_tbls == WITHOUT_CONST_TABLES) { - if (join->const_tables == join->table_count) + if (join->const_tables == join->table_count || !tab) return NULL; tab += join->const_tables; } @@ -8650,6 +8650,10 @@ JOIN_TAB *first_linear_tab(JOIN *join, enum enum_with_const_tables const_tbls) { JOIN_TAB *first= join->join_tab; + + if (!first) + return NULL; + if (const_tbls == WITHOUT_CONST_TABLES) first+= join->const_tables; @@ -8736,7 +8740,7 @@ JOIN_TAB *first_depth_first_tab(JOIN* join) { JOIN_TAB* tab; /* This means we're starting the enumeration */ - if (join->const_tables == join->top_join_tab_count) + if (join->const_tables == join->top_join_tab_count || !join->join_tab) return NULL; tab= join->join_tab + join->const_tables; -- cgit v1.2.1