Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
cc0061a1
Commit
cc0061a1
authored
May 31, 2005
by
ramil@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
a fix (bug #7405: group_concat with distinct and rollup => ignores distinct in some rows).
parent
e8a6fa42
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
29 deletions
+49
-29
mysql-test/r/func_gconcat.result
mysql-test/r/func_gconcat.result
+23
-0
mysql-test/t/func_gconcat.test
mysql-test/t/func_gconcat.test
+12
-0
sql/item_sum.cc
sql/item_sum.cc
+14
-29
No files found.
mysql-test/r/func_gconcat.result
View file @
cc0061a1
...
...
@@ -469,3 +469,26 @@ x (select group_concat(x) from r2)
1 1,1
2 2,2
drop table r2;
create table t1 (d int, a int, b int, c int);
insert into t1(a,b) values (1,3), (1,4), (1,2), (2,7), (1,1), (1,2), (2,3), (2,3);
select a, group_concat(b) from t1 group by a with rollup;
a group_concat(b)
1 3,4,2,1,2
2 7,3,3
NULL 3,4,2,1,2,7,3,3
select a, group_concat(distinct b) from t1 group by a with rollup;
a group_concat(distinct b)
1 3,4,2,1
2 7,3
NULL 3,4,2,1,7
select a, group_concat(b order by b) from t1 group by a with rollup;
a group_concat(b order by b)
1 1,2,2,3,4
2 3,3,7
NULL 1,2,2,3,3,3,4,7
select a, group_concat(distinct b order by b) from t1 group by a with rollup;
a group_concat(distinct b order by b)
1 1,2,3,4
2 3,7
NULL 1,2,3,4,7
drop table t1;
mysql-test/t/func_gconcat.test
View file @
cc0061a1
...
...
@@ -292,3 +292,15 @@ create table r2 (a int, b int);
insert
into
r2
values
(
1
,
1
),
(
2
,
2
);
select
b
x
,
(
select
group_concat
(
x
)
from
r2
)
from
r2
;
drop
table
r2
;
#
# Bug #7405: problems with rollup
#
create
table
t1
(
d
int
,
a
int
,
b
int
,
c
int
);
insert
into
t1
(
a
,
b
)
values
(
1
,
3
),
(
1
,
4
),
(
1
,
2
),
(
2
,
7
),
(
1
,
1
),
(
1
,
2
),
(
2
,
3
),
(
2
,
3
);
select
a
,
group_concat
(
b
)
from
t1
group
by
a
with
rollup
;
select
a
,
group_concat
(
distinct
b
)
from
t1
group
by
a
with
rollup
;
select
a
,
group_concat
(
b
order
by
b
)
from
t1
group
by
a
with
rollup
;
select
a
,
group_concat
(
distinct
b
order
by
b
)
from
t1
group
by
a
with
rollup
;
drop
table
t1
;
sql/item_sum.cc
View file @
cc0061a1
...
...
@@ -1566,7 +1566,6 @@ int group_concat_key_cmp_with_distinct(void* arg, byte* key1,
{
Item_func_group_concat
*
grp_item
=
(
Item_func_group_concat
*
)
arg
;
Item
**
field_item
,
**
end
;
char
*
record
=
(
char
*
)
grp_item
->
table
->
record
[
0
];
for
(
field_item
=
grp_item
->
args
,
end
=
field_item
+
grp_item
->
arg_count_field
;
field_item
<
end
;
...
...
@@ -1581,7 +1580,7 @@ int group_concat_key_cmp_with_distinct(void* arg, byte* key1,
if
(
field
)
{
int
res
;
uint
offset
=
(
uint
)
(
field
->
ptr
-
record
);
uint
offset
=
field
->
offset
(
);
if
((
res
=
field
->
key_cmp
(
key1
+
offset
,
key2
+
offset
)))
return
res
;
}
...
...
@@ -1599,7 +1598,6 @@ int group_concat_key_cmp_with_order(void* arg, byte* key1, byte* key2)
{
Item_func_group_concat
*
grp_item
=
(
Item_func_group_concat
*
)
arg
;
ORDER
**
order_item
,
**
end
;
char
*
record
=
(
char
*
)
grp_item
->
table
->
record
[
0
];
for
(
order_item
=
grp_item
->
order
,
end
=
order_item
+
grp_item
->
arg_count_order
;
order_item
<
end
;
...
...
@@ -1615,7 +1613,7 @@ int group_concat_key_cmp_with_order(void* arg, byte* key1, byte* key2)
if
(
field
)
{
int
res
;
uint
offset
=
(
uint
)
(
field
->
ptr
-
record
);
uint
offset
=
field
->
offset
(
);
if
((
res
=
field
->
key_cmp
(
key1
+
offset
,
key2
+
offset
)))
return
(
*
order_item
)
->
asc
?
res
:
-
res
;
}
...
...
@@ -1657,7 +1655,6 @@ int dump_leaf_key(byte* key, uint32 count __attribute__((unused)),
{
char
buff
[
MAX_FIELD_WIDTH
];
String
tmp
((
char
*
)
&
buff
,
sizeof
(
buff
),
default_charset_info
),
tmp2
;
char
*
record
=
(
char
*
)
item
->
table
->
record
[
0
];
if
(
item
->
result
.
length
())
item
->
result
.
append
(
*
item
->
separator
);
...
...
@@ -1677,9 +1674,8 @@ int dump_leaf_key(byte* key, uint32 count __attribute__((unused)),
Field
*
field
=
show_item
->
get_tmp_table_field
();
String
*
res
;
char
*
save_ptr
=
field
->
ptr
;
uint
offset
=
(
uint
)
(
save_ptr
-
record
);
DBUG_ASSERT
(
offset
<
item
->
table
->
reclength
);
field
->
ptr
=
(
char
*
)
key
+
offset
;
DBUG_ASSERT
(
field
->
offset
()
<
item
->
table
->
reclength
);
field
->
ptr
=
(
char
*
)
key
+
field
->
offset
();
res
=
field
->
val_str
(
&
tmp
,
&
tmp2
);
item
->
result
.
append
(
*
res
);
field
->
ptr
=
save_ptr
;
...
...
@@ -1852,12 +1848,6 @@ void Item_func_group_concat::clear()
result
.
copy
();
null_value
=
TRUE
;
warning_for_row
=
FALSE
;
if
(
table
)
{
table
->
file
->
extra
(
HA_EXTRA_NO_CACHE
);
table
->
file
->
delete_all_rows
();
table
->
file
->
extra
(
HA_EXTRA_WRITE_CACHE
);
}
if
(
tree_mode
)
reset_tree
(
tree
);
}
...
...
@@ -1870,20 +1860,14 @@ bool Item_func_group_concat::add()
copy_fields
(
tmp_table_param
);
copy_funcs
(
tmp_table_param
->
items_to_copy
);
for
(
uint
i
=
0
;
i
<
arg_count_field
;
i
++
)
{
Item
*
show_item
=
args
[
i
];
if
(
!
show_item
->
const_item
())
for
(
Item
**
arg
=
args
,
**
arg_end
=
args
+
arg_count_field
;
arg
<
arg_end
;
arg
++
)
{
/*
Here we use real_item as we want the original field data that should
be written to table->record[0]
*/
Field
*
f
=
show_item
->
real_item
()
->
get_tmp_table_field
();
if
(
f
->
is_null
())
if
(
!
(
*
arg
)
->
const_item
()
&&
(
*
arg
)
->
get_tmp_table_field
()
->
is_null_in_record
(
(
const
uchar
*
)
table
->
record
[
0
]))
return
0
;
// Skip row if it contains null
}
}
null_value
=
FALSE
;
...
...
@@ -1945,10 +1929,6 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
null_value
=
1
;
max_length
=
group_concat_max_len
;
thd
->
allow_sum_func
=
1
;
if
(
!
(
tmp_table_param
=
new
TMP_TABLE_PARAM
))
return
1
;
/* We'll convert all blobs to varchar fields in the temporary table */
tmp_table_param
->
convert_blob_length
=
group_concat_max_len
;
tables_list
=
tables
;
fixed
=
1
;
return
0
;
...
...
@@ -1967,6 +1947,11 @@ bool Item_func_group_concat::setup(THD *thd)
if
(
select_lex
->
linkage
==
GLOBAL_OPTIONS_TYPE
)
DBUG_RETURN
(
1
);
if
(
!
(
tmp_table_param
=
new
TMP_TABLE_PARAM
))
return
1
;
/* We'll convert all blobs to varchar fields in the temporary table */
tmp_table_param
->
convert_blob_length
=
group_concat_max_len
;
/*
push all not constant fields to list and create temp table
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment