From d2f08db40c90a0b0ffd8fe84cda99fbb9af0c6c9 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 30 Jun 2006 09:34:06 +0400 Subject: [PATCH] BUG#20484: "Partitions: crash with EXPLAIN and UNION" - Don't forget to produce "partitions" column for "UNION RESULT" row of EXPLAIN output mysql-test/r/partition_pruning.result: BUG#20484: Testcase mysql-test/t/partition_pruning.test: BUG#20484: Testcase --- mysql-test/r/partition_pruning.result | 7 +++++++ mysql-test/t/partition_pruning.test | 7 +++++++ sql/sql_select.cc | 3 +++ 3 files changed, 17 insertions(+) diff --git a/mysql-test/r/partition_pruning.result b/mysql-test/r/partition_pruning.result index ee294242bf7..3b08f522129 100644 --- a/mysql-test/r/partition_pruning.result +++ b/mysql-test/r/partition_pruning.result @@ -697,3 +697,10 @@ ref NULL rows 2 Extra drop table t2; +create table t1 (s1 int); +explain partitions select 1 from t1 union all select 2; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 PRIMARY t1 NULL system NULL NULL NULL NULL 0 const row not found +2 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL +drop table t1; diff --git a/mysql-test/t/partition_pruning.test b/mysql-test/t/partition_pruning.test index 976466e1578..8fdfca15eef 100644 --- a/mysql-test/t/partition_pruning.test +++ b/mysql-test/t/partition_pruning.test @@ -590,3 +590,10 @@ explain partitions select * from t2; --horizontal_results drop table t2; + +# BUG#20484 "Partitions: crash with explain and union" +create table t1 (s1 int); +explain partitions select 1 from t1 union all select 2; +drop table t1; + + diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 193a29a1fe9..e3ce2b14bf4 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -13938,6 +13938,9 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, } item_list.push_back(new Item_string(table_name_buffer, len, cs)); } + /* partitions */ + if (join->thd->lex->describe & DESCRIBE_PARTITIONS) + item_list.push_back(item_null); /* type */ item_list.push_back(new Item_string(join_type_str[JT_ALL], strlen(join_type_str[JT_ALL]),