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
bf64b09a
Commit
bf64b09a
authored
Jun 15, 2004
by
lenz@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge lgrimmer@build.mysql.com:/home/bk/mysql-4.1
into mysql.com:/space/my/mysql-4.1
parents
f8a0ddb6
56479967
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
31 deletions
+31
-31
mysql-test/r/func_gconcat.result
mysql-test/r/func_gconcat.result
+11
-3
mysql-test/t/func_gconcat.test
mysql-test/t/func_gconcat.test
+12
-0
sql/item_strfunc.cc
sql/item_strfunc.cc
+4
-11
sql/item_sum.cc
sql/item_sum.cc
+4
-16
sql/item_sum.h
sql/item_sum.h
+0
-1
No files found.
mysql-test/r/func_gconcat.result
View file @
bf64b09a
...
...
@@ -157,11 +157,8 @@ grp group_concat(c)
3 D,D,E
4
5 NULL
Warnings:
Warning 1260 1 line(s) was(were) cut by group_concat()
show warnings;
Level Code Message
Warning 1260 1 line(s) was(were) cut by group_concat()
set group_concat_max_len = 1024;
select group_concat(sum(a)) from t1 group by grp;
ERROR HY000: Invalid use of group function
...
...
@@ -310,3 +307,14 @@ GROUP_CONCAT(t1.a*t2.a ORDER BY t2.a)
1,2
2,4
DROP TABLE t1, t2;
CREATE TABLE t1 (a char(4));
INSERT INTO t1 VALUES ('John'), ('Anna'), ('Bill');
SELECT GROUP_CONCAT(a SEPARATOR '||') AS names FROM t1
HAVING names LIKE '%An%';
names
John||Anna||Bill
SELECT GROUP_CONCAT(a SEPARATOR '###') AS names FROM t1
HAVING LEFT(names, 1) ='J';
names
John###Anna###Bill
DROP TABLE t1;
mysql-test/t/func_gconcat.test
View file @
bf64b09a
...
...
@@ -189,3 +189,15 @@ INSERT INTO t1 VALUES (1), (2);
INSERT
INTO
t2
VALUES
(
1
),
(
2
);
SELECT
GROUP_CONCAT
(
t1
.
a
*
t2
.
a
ORDER
BY
t2
.
a
)
FROM
t1
,
t2
GROUP
BY
t1
.
a
;
DROP
TABLE
t1
,
t2
;
#
# Bug #4035: group_concat() and HAVING
#
CREATE
TABLE
t1
(
a
char
(
4
));
INSERT
INTO
t1
VALUES
(
'John'
),
(
'Anna'
),
(
'Bill'
);
SELECT
GROUP_CONCAT
(
a
SEPARATOR
'||'
)
AS
names
FROM
t1
HAVING
names
LIKE
'%An%'
;
SELECT
GROUP_CONCAT
(
a
SEPARATOR
'###'
)
AS
names
FROM
t1
HAVING
LEFT
(
names
,
1
)
=
'J'
;
DROP
TABLE
t1
;
sql/item_strfunc.cc
View file @
bf64b09a
...
...
@@ -950,17 +950,10 @@ String *Item_func_left::val_str(String *str)
return
0
;
if
(
length
<=
0
)
return
&
my_empty_string
;
length
=
res
->
charpos
(
length
);
if
(
res
->
length
()
>
(
ulong
)
length
)
{
// Safe even if const arg
if
(
!
res
->
alloced_length
())
{
// Don't change const str
str_value
=
*
res
;
// Not malloced string
res
=
&
str_value
;
}
res
->
length
((
uint
)
length
);
}
return
res
;
if
(
res
->
length
()
<=
(
uint
)
length
)
return
res
;
str_value
.
set
(
*
res
,
0
,
res
->
charpos
(
length
));
return
&
str_value
;
}
...
...
sql/item_sum.cc
View file @
bf64b09a
...
...
@@ -1685,6 +1685,9 @@ int dump_leaf_key(byte* key, uint32 count __attribute__((unused)),
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
);
tmp
.
length
(
0
);
for
(
uint
i
=
0
;
i
<
item
->
arg_count_field
;
i
++
)
...
...
@@ -1714,14 +1717,6 @@ int dump_leaf_key(byte* key, uint32 count __attribute__((unused)),
item
->
result
.
append
(
*
res
);
}
}
if
(
item
->
tree_mode
)
// Last item of tree
{
item
->
show_elements
++
;
if
(
item
->
show_elements
<
item
->
tree
->
elements_in_tree
)
item
->
result
.
append
(
*
item
->
separator
);
}
else
item
->
result
.
append
(
*
item
->
separator
);
/* stop if length of result more than group_concat_max_len */
if
(
item
->
result
.
length
()
>
item
->
group_concat_max_len
)
...
...
@@ -1752,7 +1747,7 @@ Item_func_group_concat::Item_func_group_concat(bool is_distinct,
tree_mode
(
0
),
distinct
(
is_distinct
),
warning_for_row
(
0
),
separator
(
is_separator
),
tree
(
&
tree_base
),
table
(
0
),
order
(
0
),
tables_list
(
0
),
show_elements
(
0
),
arg_count_order
(
0
),
arg_count_field
(
0
),
arg_count_order
(
0
),
arg_count_field
(
0
),
count_cut_values
(
0
)
{
Item
*
item_select
;
...
...
@@ -1818,7 +1813,6 @@ Item_func_group_concat::Item_func_group_concat(THD *thd,
order
(
item
->
order
),
tables_list
(
item
->
tables_list
),
group_concat_max_len
(
item
->
group_concat_max_len
),
show_elements
(
item
->
show_elements
),
arg_count_order
(
item
->
arg_count_order
),
arg_count_field
(
item
->
arg_count_field
),
field_list_offset
(
item
->
field_list_offset
),
...
...
@@ -2126,15 +2120,9 @@ String* Item_func_group_concat::val_str(String* str)
return
0
;
if
(
tree_mode
)
{
show_elements
=
0
;
tree_walk
(
tree
,
(
tree_walk_action
)
&
dump_leaf_key
,
(
void
*
)
this
,
left_root_right
);
}
else
{
if
(
!
warning_for_row
)
result
.
length
(
result
.
length
()
-
separator
->
length
());
}
if
(
count_cut_values
&&
!
warning_available
)
{
warning_available
=
TRUE
;
...
...
sql/item_sum.h
View file @
bf64b09a
...
...
@@ -696,7 +696,6 @@ class Item_func_group_concat : public Item_sum
ORDER
**
order
;
TABLE_LIST
*
tables_list
;
ulong
group_concat_max_len
;
uint
show_elements
;
uint
arg_count_order
;
uint
arg_count_field
;
uint
field_list_offset
;
...
...
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