Commit 5833a5e5 authored by igor@rurik.mysql.com's avatar igor@rurik.mysql.com

Merge rurik.mysql.com:/home/igor/mysql-5.0

into rurik.mysql.com:/home/igor/dev/mysql-5.0-0
parents 96ee8cc0 1d976dcb
...@@ -711,3 +711,14 @@ select min(b) from t1; ...@@ -711,3 +711,14 @@ select min(b) from t1;
min(b) min(b)
3000000000 3000000000
drop table t1; drop table t1;
CREATE TABLE t1 (id int PRIMARY KEY, user_id int, hostname longtext);
INSERT INTO t1 VALUES
(1, 7, 'cache-dtc-af05.proxy.aol.com'),
(2, 3, 'what.ever.com'),
(3, 7, 'cache-dtc-af05.proxy.aol.com'),
(4, 7, 'cache-dtc-af05.proxy.aol.com');
SELECT hostname, COUNT(DISTINCT user_id) as no FROM t1
WHERE hostname LIKE '%aol%'
GROUP BY hostname;
hostname no
cache-dtc-af05.proxy.aol.com 1
...@@ -522,3 +522,20 @@ insert into t1 values(3000000000); ...@@ -522,3 +522,20 @@ insert into t1 values(3000000000);
select * from t1; select * from t1;
select min(b) from t1; select min(b) from t1;
drop table t1; drop table t1;
#
# Test for bug #11088: GROUP BY a BLOB colimn with COUNT(DISTINCT column1)
#
CREATE TABLE t1 (id int PRIMARY KEY, user_id int, hostname longtext);
INSERT INTO t1 VALUES
(1, 7, 'cache-dtc-af05.proxy.aol.com'),
(2, 3, 'what.ever.com'),
(3, 7, 'cache-dtc-af05.proxy.aol.com'),
(4, 7, 'cache-dtc-af05.proxy.aol.com');
SELECT hostname, COUNT(DISTINCT user_id) as no FROM t1
WHERE hostname LIKE '%aol%'
GROUP BY hostname;
...@@ -1503,7 +1503,7 @@ class Item_str_buff :public Item_buff ...@@ -1503,7 +1503,7 @@ class Item_str_buff :public Item_buff
Item *item; Item *item;
String value,tmp_value; String value,tmp_value;
public: public:
Item_str_buff(Item *arg) :item(arg),value(arg->max_length) {} Item_str_buff(THD *thd, Item *arg);
bool cmp(void); bool cmp(void);
~Item_str_buff(); // Deallocate String:s ~Item_str_buff(); // Deallocate String:s
}; };
...@@ -1872,7 +1872,7 @@ void mark_select_range_as_dependent(THD *thd, ...@@ -1872,7 +1872,7 @@ void mark_select_range_as_dependent(THD *thd,
Field *found_field, Item *found_item, Field *found_field, Item *found_item,
Item_ident *resolved_item); Item_ident *resolved_item);
extern Item_buff *new_Item_buff(Item *item); extern Item_buff *new_Item_buff(THD *thd, Item *item);
extern Item_result item_cmp_type(Item_result a,Item_result b); extern Item_result item_cmp_type(Item_result a,Item_result b);
extern void resolve_const_item(THD *thd, Item **ref, Item *cmp_item); extern void resolve_const_item(THD *thd, Item **ref, Item *cmp_item);
extern bool field_is_equal_to_item(Field *field,Item *item); extern bool field_is_equal_to_item(Field *field,Item *item);
...@@ -23,14 +23,14 @@ ...@@ -23,14 +23,14 @@
** Create right type of item_buffer for an item ** Create right type of item_buffer for an item
*/ */
Item_buff *new_Item_buff(Item *item) Item_buff *new_Item_buff(THD *thd, Item *item)
{ {
if (item->type() == Item::FIELD_ITEM && if (item->type() == Item::FIELD_ITEM &&
!(((Item_field *) item)->field->flags & BLOB_FLAG)) !(((Item_field *) item)->field->flags & BLOB_FLAG))
return new Item_field_buff((Item_field *) item); return new Item_field_buff((Item_field *) item);
switch (item->result_type()) { switch (item->result_type()) {
case STRING_RESULT: case STRING_RESULT:
return new Item_str_buff((Item_field *) item); return new Item_str_buff(thd, (Item_field *) item);
case INT_RESULT: case INT_RESULT:
return new Item_int_buff((Item_field *) item); return new Item_int_buff((Item_field *) item);
case REAL_RESULT: case REAL_RESULT:
...@@ -51,12 +51,17 @@ Item_buff::~Item_buff() {} ...@@ -51,12 +51,17 @@ Item_buff::~Item_buff() {}
** Return true if values have changed ** Return true if values have changed
*/ */
Item_str_buff::Item_str_buff(THD *thd, Item *arg)
:item(arg), value(min(arg->max_length, thd->variables. max_sort_length))
{}
bool Item_str_buff::cmp(void) bool Item_str_buff::cmp(void)
{ {
String *res; String *res;
bool tmp; bool tmp;
res=item->val_str(&tmp_value); res=item->val_str(&tmp_value);
res->length(min(res->length(), value.alloced_length()));
if (null_value != item->null_value) if (null_value != item->null_value)
{ {
if ((null_value= item->null_value)) if ((null_value= item->null_value))
......
...@@ -12281,7 +12281,7 @@ alloc_group_fields(JOIN *join,ORDER *group) ...@@ -12281,7 +12281,7 @@ alloc_group_fields(JOIN *join,ORDER *group)
{ {
for (; group ; group=group->next) for (; group ; group=group->next)
{ {
Item_buff *tmp=new_Item_buff(*group->item); Item_buff *tmp=new_Item_buff(join->thd, *group->item);
if (!tmp || join->group_fields.push_front(tmp)) if (!tmp || join->group_fields.push_front(tmp))
return TRUE; return TRUE;
} }
......
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