mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
Fixed bug mdev-9754.
Each window name has to be resolved only once.
This commit is contained in:
parent
6533bd1b74
commit
84c3a20ff9
3 changed files with 69 additions and 2 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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++))
|
||||
|
|
Loading…
Reference in a new issue