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
84c3a20f
Commit
84c3a20f
authored
Mar 17, 2016
by
Igor Babaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug mdev-9754.
Each window name has to be resolved only once.
parent
6533bd1b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
1 deletion
+68
-1
mysql-test/r/win.result
mysql-test/r/win.result
+40
-0
mysql-test/t/win.test
mysql-test/t/win.test
+21
-0
sql/item_windowfunc.cc
sql/item_windowfunc.cc
+7
-1
No files found.
mysql-test/r/win.result
View file @
84c3a20f
...
...
@@ -1257,3 +1257,43 @@ a row_number() over (partition by a order by b)
3 1
3 2
drop table t1;
#
# mdev-9754: Window name resolution in prepared statement
#
create table t0 (a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t1 (pk int, c int);
insert into t1 select a+1,1 from t0;
update t1 set c=2 where pk not in (1,2,3,4);
select * from t1;
pk c
1 1
2 1
3 1
4 1
5 2
6 2
7 2
8 2
9 2
10 2
prepare stmt from
'select
pk, c,
count(*) over w1 as CNT
from t1
window w1 as (partition by c order by pk
rows between 2 preceding and 2 following)';
execute stmt;
pk c CNT
1 1 3
2 1 4
3 1 4
4 1 3
5 2 3
6 2 4
7 2 5
8 2 5
9 2 4
10 2 3
drop table t0,t1;
mysql-test/t/win.test
View file @
84c3a20f
...
...
@@ -785,7 +785,28 @@ execute stmt;
drop
table
t1
;
--
echo
#
--
echo
# mdev-9754: Window name resolution in prepared statement
--
echo
#
create
table
t0
(
a
int
);
insert
into
t0
values
(
0
),(
1
),(
2
),(
3
),(
4
),(
5
),(
6
),(
7
),(
8
),(
9
);
create
table
t1
(
pk
int
,
c
int
);
insert
into
t1
select
a
+
1
,
1
from
t0
;
update
t1
set
c
=
2
where
pk
not
in
(
1
,
2
,
3
,
4
);
select
*
from
t1
;
prepare
stmt
from
'select
pk, c,
count(*) over w1 as CNT
from t1
window w1 as (partition by c order by pk
rows between 2 preceding and 2 following)'
;
execute
stmt
;
drop
table
t0
,
t1
;
...
...
sql/item_windowfunc.cc
View file @
84c3a20f
...
...
@@ -7,6 +7,11 @@
bool
Item_window_func
::
resolve_window_name
(
THD
*
thd
)
{
if
(
window_spec
)
{
/* The window name has been already resolved */
return
false
;
}
DBUG_ASSERT
(
window_name
!=
NULL
&&
window_spec
==
NULL
);
char
*
ref_name
=
window_name
->
str
;
...
...
@@ -15,7 +20,8 @@ Item_window_func::resolve_window_name(THD *thd)
First look for the deinition of the window with 'window_name'
in the current select
*/
List
<
Window_spec
>
curr_window_specs
=
thd
->
lex
->
current_select
->
window_specs
;
List
<
Window_spec
>
curr_window_specs
=
List
<
Window_spec
>
(
thd
->
lex
->
current_select
->
window_specs
);
List_iterator_fast
<
Window_spec
>
it
(
curr_window_specs
);
Window_spec
*
win_spec
;
while
((
win_spec
=
it
++
))
...
...
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