From 859f599e1ed8a85b6c8909b32fdfa5dc223e929b Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 6 Dec 2003 23:37:24 +0400 Subject: Fix for #1992 This bug happens when a query, having subselects in the fields list, needs temporary table. Item_subselect::get_tmp_table_item isn't implemented and just returns *this. So the tmp_table_item takes value not from temporary but from original table. mysql-test/r/subselect.result: appropriate test result added mysql-test/t/subselect.test: test case added sql/item_subselect.cc: Item_subselect::get_tmp_table_item implementation sql/item_subselect.h: Item_subselect::get_tmp_table_item declaration --- sql/item_subselect.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sql/item_subselect.cc') diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 7b401b50d4c..123362b917b 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -166,6 +166,12 @@ bool Item_subselect::const_item() const return const_item_cache; } +Item *Item_subselect::get_tmp_table_item(THD *thd) +{ + if (!with_sum_func && !const_item()) + return new Item_field(result_field); + return copy_or_same(thd); +} void Item_subselect::update_used_tables() { -- cgit v1.2.1