summaryrefslogtreecommitdiff
path: root/sql/sql_union.cc
diff options
context:
space:
mode:
authorgluh@gluh.mysql.r18.ru <>2005-02-04 15:31:36 +0300
committergluh@gluh.mysql.r18.ru <>2005-02-04 15:31:36 +0300
commit34915f7a91b7ba56f5bbb4ac6d6301f847a7d48b (patch)
treebbb0e40bc45b0aa18e65ab56858a6d4d78bd8c06 /sql/sql_union.cc
parent7213ca46add8cd1674c196851ef1073046ce03d5 (diff)
downloadmariadb-git-34915f7a91b7ba56f5bbb4ac6d6301f847a7d48b.tar.gz
A fix: bug#6931: Date Type column problem when using UNION-Table
bug#7833: Wrong datatype of aggregate column is returned
Diffstat (limited to 'sql/sql_union.cc')
-rw-r--r--sql/sql_union.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index 027a21db7ac..882316d57d7 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -148,6 +148,7 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
SELECT_LEX *sl, *first_select;
select_result *tmp_result;
bool is_union;
+ TABLE *empty_table= 0;
DBUG_ENTER("st_select_lex_unit::prepare");
describe= test(additional_options & SELECT_DESCRIBE);
@@ -239,13 +240,21 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
goto err;
if (sl == first_select)
{
+ /*
+ We need to create an empty table object. It is used
+ to create tmp_table fields in Item_type_holder.
+ The main reason of this is that we can't create
+ field object without table.
+ */
+ DBUG_ASSERT(!empty_table);
+ empty_table= (TABLE*) thd->calloc(sizeof(TABLE));
types.empty();
List_iterator_fast<Item> it(sl->item_list);
Item *item_tmp;
while ((item_tmp= it++))
{
/* Error's in 'new' will be detected after loop */
- types.push_back(new Item_type_holder(thd_arg, item_tmp));
+ types.push_back(new Item_type_holder(thd_arg, item_tmp, empty_table));
}
if (thd_arg->is_fatal_error)
@@ -264,7 +273,8 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
Item *type, *item_tmp;
while ((type= tp++, item_tmp= it++))
{
- if (((Item_type_holder*)type)->join_types(thd_arg, item_tmp))
+ if (((Item_type_holder*)type)->join_types(thd_arg, item_tmp,
+ empty_table))
DBUG_RETURN(-1);
}
}