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
37925c6c
Commit
37925c6c
authored
Feb 15, 2017
by
Igor Babaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug mdev-9924.
Supported queries with window functions when GROUP BY could be optimized away.
parent
e688d814
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
1 deletion
+41
-1
mysql-test/r/win.result
mysql-test/r/win.result
+21
-0
mysql-test/t/win.test
mysql-test/t/win.test
+16
-0
sql/sql_select.cc
sql/sql_select.cc
+4
-1
No files found.
mysql-test/r/win.result
View file @
37925c6c
...
@@ -3075,3 +3075,24 @@ select count(distinct s) from (select sum(d) as s from t group by a) Z where s >
...
@@ -3075,3 +3075,24 @@ select count(distinct s) from (select sum(d) as s from t group by a) Z where s >
count(distinct s)
count(distinct s)
1
1
drop table t;
drop table t;
#
# MDEV-9924: window function in query with group by optimized away
#
create table t1 (i int);
insert into t1 values (2),(3),(1);
select row_number() over () from t1 group by 1+2;
row_number() over ()
1
select max(i), row_number() over () from t1 group by 1+2;
max(i) row_number() over ()
3 1
select rank() over (order by max(i)) from t1 group by 1+2;
rank() over (order by max(i))
1
select i, row_number() over () from t1 group by 1+2;
i row_number() over ()
2 1
select i, rank() over (order by i) rnk from t1 group by 1+2;
i rnk
2 1
drop table t1;
mysql-test/t/win.test
View file @
37925c6c
...
@@ -1793,3 +1793,19 @@ select count(distinct s) from (select sum(d) over(partition by a) as s from t) Z
...
@@ -1793,3 +1793,19 @@ select count(distinct s) from (select sum(d) over(partition by a) as s from t) Z
select
count
(
distinct
s
)
from
(
select
sum
(
d
)
as
s
from
t
group
by
a
)
Z
where
s
>
0
;
select
count
(
distinct
s
)
from
(
select
sum
(
d
)
as
s
from
t
group
by
a
)
Z
where
s
>
0
;
drop
table
t
;
drop
table
t
;
--
echo
#
--
echo
# MDEV-9924: window function in query with group by optimized away
--
echo
#
create
table
t1
(
i
int
);
insert
into
t1
values
(
2
),(
3
),(
1
);
select
row_number
()
over
()
from
t1
group
by
1
+
2
;
select
max
(
i
),
row_number
()
over
()
from
t1
group
by
1
+
2
;
select
rank
()
over
(
order
by
max
(
i
))
from
t1
group
by
1
+
2
;
select
i
,
row_number
()
over
()
from
t1
group
by
1
+
2
;
select
i
,
rank
()
over
(
order
by
i
)
rnk
from
t1
group
by
1
+
2
;
drop
table
t1
;
sql/sql_select.cc
View file @
37925c6c
...
@@ -2226,6 +2226,9 @@ bool JOIN::make_aggr_tables_info()
...
@@ -2226,6 +2226,9 @@ bool JOIN::make_aggr_tables_info()
sort_and_group_aggr_tab
=
NULL
;
sort_and_group_aggr_tab
=
NULL
;
if
(
group_optimized_away
)
implicit_grouping
=
true
;
bool
implicit_grouping_with_window_funcs
=
implicit_grouping
&&
bool
implicit_grouping_with_window_funcs
=
implicit_grouping
&&
select_lex
->
have_window_funcs
();
select_lex
->
have_window_funcs
();
...
@@ -2574,7 +2577,7 @@ bool JOIN::make_aggr_tables_info()
...
@@ -2574,7 +2577,7 @@ bool JOIN::make_aggr_tables_info()
tmp_table_param
.
copy_field
=
tmp_table_param
.
copy_field_end
=
0
;
tmp_table_param
.
copy_field
=
tmp_table_param
.
copy_field_end
=
0
;
first_record
=
sort_and_group
=
0
;
first_record
=
sort_and_group
=
0
;
if
(
!
group_optimized_away
)
if
(
!
group_optimized_away
||
implicit_grouping_with_window_funcs
)
{
{
group
=
false
;
group
=
false
;
}
}
...
...
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