Commit 152d634f authored by unknown's avatar unknown

Fix for BUG#11821 manually merged


sql/item.cc:
  Auto merged
parents 584d8e7b ceea89c0
...@@ -2837,3 +2837,9 @@ WHERE select_id = 0 OR select_id = 1); ...@@ -2837,3 +2837,9 @@ WHERE select_id = 0 OR select_id = 1);
values_id values_id
1 1
DROP TABLE t1, t2; DROP TABLE t1, t2;
create table t1 (fld enum('0','1'));
insert into t1 values ('1');
select * from (select max(fld) from t1) as foo;
max(fld)
1
drop table t1;
...@@ -1859,3 +1859,11 @@ WHERE values_id IN (SELECT values_id FROM t2 ...@@ -1859,3 +1859,11 @@ WHERE values_id IN (SELECT values_id FROM t2
WHERE select_id = 0 OR select_id = 1); WHERE select_id = 0 OR select_id = 1);
DROP TABLE t1, t2; DROP TABLE t1, t2;
# BUG#11821 : Select from subselect using aggregate function on an enum
# segfaults:
create table t1 (fld enum('0','1'));
insert into t1 values ('1');
select * from (select max(fld) from t1) as foo;
drop table t1;
...@@ -5421,9 +5421,13 @@ void Item_type_holder::get_full_info(Item *item) ...@@ -5421,9 +5421,13 @@ void Item_type_holder::get_full_info(Item *item)
if (fld_type == MYSQL_TYPE_ENUM || if (fld_type == MYSQL_TYPE_ENUM ||
fld_type == MYSQL_TYPE_SET) fld_type == MYSQL_TYPE_SET)
{ {
if (item->type() == Item::SUM_FUNC_ITEM &&
(((Item_sum*)item)->sum_func() == Item_sum::MAX_FUNC ||
((Item_sum*)item)->sum_func() == Item_sum::MIN_FUNC))
item = ((Item_sum*)item)->args[0];
/* /*
We can have enum/set type after merging only if we have one enum/set We can have enum/set type after merging only if we have one enum|set
field and number of NULL fields field (or MIN|MAX(enum|set field)) and number of NULL fields
*/ */
DBUG_ASSERT((enum_set_typelib && DBUG_ASSERT((enum_set_typelib &&
get_real_type(item) == MYSQL_TYPE_NULL) || get_real_type(item) == MYSQL_TYPE_NULL) ||
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment