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
7313daef
Commit
7313daef
authored
Feb 12, 2010
by
Evgeny Potemkin
Browse files
Options
Browse Files
Download
Plain Diff
Auto-merged fix for the bug#50539.
parents
de551587
b5f40f34
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
14 deletions
+50
-14
mysql-test/r/group_min_max.result
mysql-test/r/group_min_max.result
+24
-3
mysql-test/t/group_min_max.test
mysql-test/t/group_min_max.test
+19
-0
sql/opt_range.cc
sql/opt_range.cc
+1
-11
sql/sql_select.cc
sql/sql_select.cc
+6
-0
No files found.
mysql-test/r/group_min_max.result
View file @
7313daef
...
...
@@ -2686,7 +2686,7 @@ a c COUNT(DISTINCT c, a, b)
1 1 1
1 1 1
1 1 1
2
1 1
1
1 1
2 1 1
2 1 1
2 1 1
...
...
@@ -2714,7 +2714,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL a 10 NULL 9 Using index for group-by
SELECT a, COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a;
a COUNT(DISTINCT b) SUM(DISTINCT b)
2
8 36
1
8 36
2 8 36
EXPLAIN SELECT COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra
...
...
@@ -2761,7 +2761,7 @@ SELECT 42 * (a + c + COUNT(DISTINCT c, a, b)) FROM t2 GROUP BY a, b, c;
126
126
126
1
68
1
26
168
168
168
...
...
@@ -2779,3 +2779,24 @@ SELECT (SUM(DISTINCT a) + MAX(b)) FROM t2 GROUP BY a;
10
DROP TABLE t1,t2;
# end of WL#3220 tests
#
# Bug#50539: Wrong result when loose index scan is used for an aggregate
# function with distinct
#
CREATE TABLE t1 (
f1 int(11) NOT NULL DEFAULT '0',
f2 char(1) NOT NULL DEFAULT '',
PRIMARY KEY (f1,f2)
) ;
insert into t1 values(1,'A'),(1 , 'B'), (1, 'C'), (2, 'A'),
(3, 'A'), (3, 'B'), (3, 'C'), (3, 'D');
SELECT f1, COUNT(DISTINCT f2) FROM t1 GROUP BY f1;
f1 COUNT(DISTINCT f2)
1 3
2 1
3 4
explain SELECT f1, COUNT(DISTINCT f2) FROM t1 GROUP BY f1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL PRIMARY 5 NULL 9 Using index for group-by (scanning)
drop table t1;
# End of test#50539.
mysql-test/t/group_min_max.test
View file @
7313daef
...
...
@@ -1166,3 +1166,22 @@ SELECT (SUM(DISTINCT a) + MAX(b)) FROM t2 GROUP BY a;
DROP
TABLE
t1
,
t2
;
--
echo
# end of WL#3220 tests
--
echo
#
--
echo
# Bug#50539: Wrong result when loose index scan is used for an aggregate
--
echo
# function with distinct
--
echo
#
CREATE
TABLE
t1
(
f1
int
(
11
)
NOT
NULL
DEFAULT
'0'
,
f2
char
(
1
)
NOT
NULL
DEFAULT
''
,
PRIMARY
KEY
(
f1
,
f2
)
)
;
insert
into
t1
values
(
1
,
'A'
),(
1
,
'B'
),
(
1
,
'C'
),
(
2
,
'A'
),
(
3
,
'A'
),
(
3
,
'B'
),
(
3
,
'C'
),
(
3
,
'D'
);
SELECT
f1
,
COUNT
(
DISTINCT
f2
)
FROM
t1
GROUP
BY
f1
;
explain
SELECT
f1
,
COUNT
(
DISTINCT
f2
)
FROM
t1
GROUP
BY
f1
;
drop
table
t1
;
--
echo
# End of test#50539.
sql/opt_range.cc
View file @
7313daef
...
...
@@ -10955,17 +10955,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::get_next()
}
while
((
result
==
HA_ERR_KEY_NOT_FOUND
||
result
==
HA_ERR_END_OF_FILE
)
&&
is_last_prefix
!=
0
);
if
(
result
==
0
)
{
/*
Partially mimic the behavior of end_select_send. Copy the
field data from Item_field::field into Item_field::result_field
of each non-aggregated field (the group fields, and optionally
other fields in non-ANSI SQL mode).
*/
copy_fields
(
&
join
->
tmp_table_param
);
}
else
if
(
result
==
HA_ERR_KEY_NOT_FOUND
)
if
(
result
==
HA_ERR_KEY_NOT_FOUND
)
result
=
HA_ERR_END_OF_FILE
;
DBUG_RETURN
(
result
);
...
...
sql/sql_select.cc
View file @
7313daef
...
...
@@ -12316,6 +12316,12 @@ end_send(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
if
(
!
end_of_records
)
{
int
error
;
if
(
join
->
tables
&&
join
->
join_tab
->
is_using_loose_index_scan
())
{
/* Copy non-aggregated fields when loose index scan is used. */
copy_fields
(
&
join
->
tmp_table_param
);
}
if
(
join
->
having
&&
join
->
having
->
val_int
()
==
0
)
DBUG_RETURN
(
NESTED_LOOP_OK
);
// Didn't match having
error
=
0
;
...
...
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