mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
BUG
correct bug 1085 (a problem with min/max functions) add tests of bugs 833,836,1085 mysql-test/r/func_gconcat.result: add tests of bugs 833, 836, 1085 mysql-test/t/func_gconcat.test: add tests of bugs #833, 836, 1085 sql/item_sum.cc: merge sql/item_sum.h: correct bug 1085
This commit is contained in:
@@ -167,6 +167,11 @@ t2.URL_ID = t1.URL_ID group by REQ_ID;
|
||||
REQ_ID URL
|
||||
1 X
|
||||
5 X,X,X
|
||||
select REQ_ID, Group_Concat(URL) as URL, Min(t1.URL_ID) urll,
|
||||
Max(t1.URL_ID)
|
||||
urlg from t1, t2 where t2.URL_ID = t1.URL_ID group by REQ_ID;
|
||||
REQ_ID URL urll urlg
|
||||
1 X 4 4
|
||||
5 X,X,X 4 5
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
@@ -178,3 +183,16 @@ select distinct ifnull(group_concat(concat(t1.id, ':', t1.name)), 'shortname') a
|
||||
select distinct ifnull(group_concat(concat(t1.id, ':', t1.name)), 'shortname') as 'with distinct: cutoff at length of shortname' from t1;
|
||||
with distinct: cutoff at length of shortname
|
||||
1:longername,1:evenlongername
|
||||
drop table t1;
|
||||
create table t1(id int);
|
||||
create table t2(id int);
|
||||
insert into t1 values(0),(1);
|
||||
select group_concat(t1.id) FROM t1,t2;
|
||||
group_concat(t1.id)
|
||||
NULL
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
create table t1 (bar varchar(32));
|
||||
insert into t1 values('test'),('test2');
|
||||
select * from t1 having group_concat(bar)='';
|
||||
bar
|
||||
|
@@ -91,6 +91,11 @@ insert into t2 values (1,4), (5,4), (5,5);
|
||||
--replace_result www.help.com X www.host.com X www.google.com X
|
||||
select REQ_ID, Group_Concat(URL) as URL from t1, t2 where
|
||||
t2.URL_ID = t1.URL_ID group by REQ_ID;
|
||||
# check min/max function
|
||||
--replace_result www.help.com X www.host.com X www.google.com X
|
||||
select REQ_ID, Group_Concat(URL) as URL, Min(t1.URL_ID) urll,
|
||||
Max(t1.URL_ID)
|
||||
urlg from t1, t2 where t2.URL_ID = t1.URL_ID group by REQ_ID;
|
||||
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
@@ -99,3 +104,19 @@ insert into t1 values (1,'longername'),(1,'evenlongername');
|
||||
insert into t1 values (1,'longername'),(1,'evenlongername');
|
||||
select ifnull(group_concat(concat(t1.id, ':', t1.name)), 'shortname') as 'without distinct: how it should be' from t1;
|
||||
select distinct ifnull(group_concat(concat(t1.id, ':', t1.name)), 'shortname') as 'with distinct: cutoff at length of shortname' from t1;
|
||||
drop table t1;
|
||||
|
||||
# check zero rows
|
||||
create table t1(id int);
|
||||
create table t2(id int);
|
||||
insert into t1 values(0),(1);
|
||||
select group_concat(t1.id) FROM t1,t2;
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
|
||||
# check having
|
||||
create table t1 (bar varchar(32));
|
||||
insert into t1 values('test'),('test2');
|
||||
select * from t1 having group_concat(bar)='';
|
||||
drop table t1;
|
||||
|
||||
|
@@ -1460,7 +1460,7 @@ int group_concat_key_cmp_with_distinct(void* arg, byte* key1,
|
||||
for (uint i= 0; i < item->arg_count_field; i++)
|
||||
{
|
||||
Item *field_item= item->args[i];
|
||||
Field *field= field_item->real_item()->tmp_table_field();
|
||||
Field *field= field_item->real_item()->get_tmp_table_field();
|
||||
if (field)
|
||||
{
|
||||
uint offset= field->abs_offset;
|
||||
@@ -1491,7 +1491,7 @@ int group_concat_key_cmp_with_order(void* arg, byte* key1, byte* key2)
|
||||
{
|
||||
ORDER *order_item= item->order[i];
|
||||
Item *item= *order_item->item;
|
||||
Field *field= item->real_item()->tmp_table_field();
|
||||
Field *field= item->real_item()->get_tmp_table_field();
|
||||
if (field)
|
||||
{
|
||||
uint offset= field->abs_offset;
|
||||
@@ -1542,7 +1542,7 @@ int dump_leaf_key(byte* key, uint32 count __attribute__((unused)),
|
||||
Item *show_item= group_concat_item->args[i];
|
||||
if (!show_item->const_item())
|
||||
{
|
||||
Field *f= show_item->real_item()->tmp_table_field();
|
||||
Field *f= show_item->real_item()->get_tmp_table_field();
|
||||
char *sv= f->ptr;
|
||||
f->ptr= (char *)key + f->abs_offset;
|
||||
String *res= f->val_str(&tmp,&tmp2);
|
||||
@@ -1709,7 +1709,7 @@ bool Item_func_group_concat::add()
|
||||
Item *show_item= args[i];
|
||||
if (!show_item->const_item())
|
||||
{
|
||||
Field *f= show_item->real_item()->tmp_table_field();
|
||||
Field *f= show_item->real_item()->get_tmp_table_field();
|
||||
if (!f->is_null())
|
||||
{
|
||||
record_is_null= FALSE;
|
||||
|
@@ -386,8 +386,8 @@ class Item_sum_hybrid :public Item_sum
|
||||
Item_sum_hybrid(THD *thd, Item_sum_hybrid &item):
|
||||
Item_sum(thd, item), value(item.value), tmp_value(item.tmp_value),
|
||||
sum(item.sum), sum_int(item.sum_int), hybrid_type(item.hybrid_type),
|
||||
cmp_sign(item.cmp_sign), used_table_cache(used_table_cache),
|
||||
cmp_charset(item.cmp_charset) {}
|
||||
hybrid_field_type(item.hybrid_field_type),cmp_sign(item.cmp_sign),
|
||||
used_table_cache(used_table_cache), cmp_charset(item.cmp_charset) {}
|
||||
bool fix_fields(THD *, TABLE_LIST *, Item **);
|
||||
table_map used_tables() const { return used_table_cache; }
|
||||
bool const_item() const { return !used_table_cache; }
|
||||
|
Reference in New Issue
Block a user