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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
b34c3934
Commit
b34c3934
authored
Sep 04, 2003
by
wax@kishkin.ru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BUG
correct bug 1085 (a problem with min/max functions) add tests of bugs 833,836,1085
parent
f053ce32
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
6 deletions
+45
-6
mysql-test/r/func_gconcat.result
mysql-test/r/func_gconcat.result
+18
-0
mysql-test/t/func_gconcat.test
mysql-test/t/func_gconcat.test
+21
-0
sql/item_sum.cc
sql/item_sum.cc
+4
-4
sql/item_sum.h
sql/item_sum.h
+2
-2
No files found.
mysql-test/r/func_gconcat.result
View file @
b34c3934
...
@@ -167,6 +167,11 @@ t2.URL_ID = t1.URL_ID group by REQ_ID;
...
@@ -167,6 +167,11 @@ t2.URL_ID = t1.URL_ID group by REQ_ID;
REQ_ID URL
REQ_ID URL
1 X
1 X
5 X,X,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 t1;
drop table t2;
drop table t2;
create table t1 (id int, name varchar(16));
create table t1 (id int, name varchar(16));
...
@@ -178,3 +183,16 @@ select distinct ifnull(group_concat(concat(t1.id, ':', t1.name)), 'shortname') a
...
@@ -178,3 +183,16 @@ select distinct ifnull(group_concat(concat(t1.id, ':', t1.name)), 'shortname') a
with distinct: cutoff at length of shortname
with distinct: cutoff at length of shortname
1:longername,1:evenlongername
1:longername,1:evenlongername
drop table t1;
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
drop table t1;
...
...
mysql-test/t/func_gconcat.test
View file @
b34c3934
...
@@ -91,6 +91,11 @@ insert into t2 values (1,4), (5,4), (5,5);
...
@@ -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
--
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
select
REQ_ID
,
Group_Concat
(
URL
)
as
URL
from
t1
,
t2
where
t2
.
URL_ID
=
t1
.
URL_ID
group
by
REQ_ID
;
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
t1
;
drop
table
t2
;
drop
table
t2
;
...
@@ -99,3 +104,19 @@ insert into t1 values (1,'longername'),(1,'evenlongername');
...
@@ -99,3 +104,19 @@ 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
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
;
select
distinct
ifnull
(
group_concat
(
concat
(
t1
.
id
,
':'
,
t1
.
name
)),
'shortname'
)
as
'with distinct: cutoff at length of shortname'
from
t1
;
drop
table
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
;
...
...
sql/item_sum.cc
View file @
b34c3934
...
@@ -1460,7 +1460,7 @@ int group_concat_key_cmp_with_distinct(void* arg, byte* key1,
...
@@ -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
++
)
for
(
uint
i
=
0
;
i
<
item
->
arg_count_field
;
i
++
)
{
{
Item
*
field_item
=
item
->
args
[
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
)
if
(
field
)
{
{
uint
offset
=
field
->
abs_offset
;
uint
offset
=
field
->
abs_offset
;
...
@@ -1491,7 +1491,7 @@ int group_concat_key_cmp_with_order(void* arg, byte* key1, byte* key2)
...
@@ -1491,7 +1491,7 @@ int group_concat_key_cmp_with_order(void* arg, byte* key1, byte* key2)
{
{
ORDER
*
order_item
=
item
->
order
[
i
];
ORDER
*
order_item
=
item
->
order
[
i
];
Item
*
item
=
*
order_item
->
item
;
Item
*
item
=
*
order_item
->
item
;
Field
*
field
=
item
->
real_item
()
->
tmp_table_field
();
Field
*
field
=
item
->
real_item
()
->
get_
tmp_table_field
();
if
(
field
)
if
(
field
)
{
{
uint
offset
=
field
->
abs_offset
;
uint
offset
=
field
->
abs_offset
;
...
@@ -1542,7 +1542,7 @@ int dump_leaf_key(byte* key, uint32 count __attribute__((unused)),
...
@@ -1542,7 +1542,7 @@ int dump_leaf_key(byte* key, uint32 count __attribute__((unused)),
Item
*
show_item
=
group_concat_item
->
args
[
i
];
Item
*
show_item
=
group_concat_item
->
args
[
i
];
if
(
!
show_item
->
const_item
())
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
;
char
*
sv
=
f
->
ptr
;
f
->
ptr
=
(
char
*
)
key
+
f
->
abs_offset
;
f
->
ptr
=
(
char
*
)
key
+
f
->
abs_offset
;
String
*
res
=
f
->
val_str
(
&
tmp
,
&
tmp2
);
String
*
res
=
f
->
val_str
(
&
tmp
,
&
tmp2
);
...
@@ -1709,7 +1709,7 @@ bool Item_func_group_concat::add()
...
@@ -1709,7 +1709,7 @@ bool Item_func_group_concat::add()
Item
*
show_item
=
args
[
i
];
Item
*
show_item
=
args
[
i
];
if
(
!
show_item
->
const_item
())
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
())
if
(
!
f
->
is_null
())
{
{
record_is_null
=
FALSE
;
record_is_null
=
FALSE
;
...
...
sql/item_sum.h
View file @
b34c3934
...
@@ -386,8 +386,8 @@ class Item_sum_hybrid :public Item_sum
...
@@ -386,8 +386,8 @@ class Item_sum_hybrid :public Item_sum
Item_sum_hybrid
(
THD
*
thd
,
Item_sum_hybrid
&
item
)
:
Item_sum_hybrid
(
THD
*
thd
,
Item_sum_hybrid
&
item
)
:
Item_sum
(
thd
,
item
),
value
(
item
.
value
),
tmp_value
(
item
.
tmp_value
),
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
),
sum
(
item
.
sum
),
sum_int
(
item
.
sum_int
),
hybrid_type
(
item
.
hybrid_type
),
cmp_sign
(
item
.
cmp_sign
),
used_table_cache
(
used_table_cache
),
hybrid_field_type
(
item
.
hybrid_field_type
),
cmp_sign
(
item
.
cmp_sign
),
cmp_charset
(
item
.
cmp_charset
)
{}
used_table_cache
(
used_table_cache
),
cmp_charset
(
item
.
cmp_charset
)
{}
bool
fix_fields
(
THD
*
,
TABLE_LIST
*
,
Item
**
);
bool
fix_fields
(
THD
*
,
TABLE_LIST
*
,
Item
**
);
table_map
used_tables
()
const
{
return
used_table_cache
;
}
table_map
used_tables
()
const
{
return
used_table_cache
;
}
bool
const_item
()
const
{
return
!
used_table_cache
;
}
bool
const_item
()
const
{
return
!
used_table_cache
;
}
...
...
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