forked from openGauss-Ecosystem/openGauss-server
!2706 修复列存子连接包含rownum和one time filter时找不到var的问题
Merge pull request !2706 from pengjiong/fix_date
This commit is contained in:
commit
7620f26d8a
|
@ -1411,7 +1411,7 @@ static void adjust_scan_targetlist(ResultPath* best_path, Plan* subplan)
|
|||
sub_targetlist = lappend(sub_targetlist, entry);
|
||||
}
|
||||
subplan->targetlist = sub_targetlist;
|
||||
if (IsA(subplan, PartIterator)) {
|
||||
if (IsA(subplan, PartIterator) || IsA(subplan, BaseResult)) {
|
||||
subplan->lefttree->targetlist = subplan->targetlist;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2061,6 +2061,78 @@ select * from (select rownum, max(id) as max_id from student_cstore1 group by ro
|
|||
10 | 10
|
||||
(10 rows)
|
||||
|
||||
-- test rownum with base result plan
|
||||
create table tab_1110306_1 (a1 int, b1 int, c1 int, d1 int,e1 text,f1 date) with (orientation=column) ;
|
||||
insert into tab_1110306_1 values
|
||||
(1, 1, 1, 1,'A10Z','2000-03-01')
|
||||
,(1, 1, 1, 2,'A1Z' ,'2000-03-02')
|
||||
,(1, 1, 2, 1,'A11Z','2000-03-05')
|
||||
,(1, 1, 2, 2,'A2Z' ,'2000-03-04')
|
||||
,(1, 2, 1, 1,'A13Z','2000-03-05')
|
||||
,(1, 2, 1, 2,'A3Z' ,'2000-03-19')
|
||||
,(1, 2, 2, 1,'A15Z','2000-03-05')
|
||||
,(1, 2, 2, 2,'A4Z' ,'2000-03-19')
|
||||
,(1, 3, 3, 3,'A10Z','2000-03-05')
|
||||
,(2, 5, 5, 5,'A5Z' ,'2000-03-10')
|
||||
,(2, NULL, 6, 6,null,'2000-04-01')
|
||||
,(2, 6, NULL, 6,'A15Z','2000-05-01')
|
||||
,(null, 6, 6, NULL,'A6Z','2000-03-11')
|
||||
,(2, NULL, NULL, 7,'A5Z','2000-03-02')
|
||||
,(2, NULL, 7, NULL,'A7Z','2000-03-03')
|
||||
,(2, 7, NULL, NULL,'A10Z','2000-03-10')
|
||||
,(3, NULL, NULL, NULL,'A9Z','2000-03-05')
|
||||
;
|
||||
explain (verbose, costs off)select 1
|
||||
from (select transaction_timestamp() as aa
|
||||
from tab_1110306_1
|
||||
where f1 <=to_date('2010-01-02')
|
||||
and c1 > 12
|
||||
or statement_timestamp() >=current_timestamp
|
||||
and rownum < 6
|
||||
group by c1) t1
|
||||
group by t1.aa
|
||||
having t1.aa <=transaction_timestamp();
|
||||
QUERY PLAN
|
||||
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
HashAggregate
|
||||
Output: 1, t1.aa
|
||||
Group By Key: t1.aa
|
||||
-> Subquery Scan on t1
|
||||
Output: t1.aa
|
||||
-> Group
|
||||
Output: transaction_timestamp(), tab_1110306_1.c1
|
||||
Group By Key: tab_1110306_1.c1
|
||||
-> Sort
|
||||
Output: tab_1110306_1.c1
|
||||
Sort Key: tab_1110306_1.c1
|
||||
-> Result
|
||||
Output: tab_1110306_1.c1
|
||||
Filter: (((tab_1110306_1.f1 <= to_date('2010-01-02'::text)) AND (tab_1110306_1.c1 > 12)) OR ((statement_timestamp() >= pg_systimestamp()) AND (ROWNUM < 6)))
|
||||
-> Result
|
||||
Output: tab_1110306_1.c1, tab_1110306_1.f1
|
||||
One-Time Filter: (transaction_timestamp() <= transaction_timestamp())
|
||||
-> Row Adapter
|
||||
Output: tab_1110306_1.c1, tab_1110306_1.f1
|
||||
-> CStore Scan on public.tab_1110306_1
|
||||
Output: tab_1110306_1.c1, tab_1110306_1.f1
|
||||
(21 rows)
|
||||
|
||||
select 1
|
||||
from (select transaction_timestamp() as aa
|
||||
from tab_1110306_1
|
||||
where f1 <=to_date('2010-01-02')
|
||||
and c1 > 12
|
||||
or statement_timestamp() >=current_timestamp
|
||||
and rownum < 6
|
||||
group by c1) t1
|
||||
group by t1.aa
|
||||
having t1.aa <=transaction_timestamp();
|
||||
?column?
|
||||
----------
|
||||
1
|
||||
(1 row)
|
||||
|
||||
drop table tab_1110306_1;
|
||||
drop table student_cstore1;
|
||||
drop table student_cstore2;
|
||||
drop table student;
|
||||
|
|
|
@ -527,6 +527,52 @@ select rownum, sc1.stuname, sc2.id from student_cstore2 as sc1, student_cstore2
|
|||
-- test rownum for agg
|
||||
select * from (select rownum, max(id) as max_id from student_cstore1 group by rownum) as t order by max_id;
|
||||
|
||||
-- test rownum with base result plan
|
||||
create table tab_1110306_1 (a1 int, b1 int, c1 int, d1 int,e1 text,f1 date) with (orientation=column) ;
|
||||
|
||||
insert into tab_1110306_1 values
|
||||
(1, 1, 1, 1,'A10Z','2000-03-01')
|
||||
,(1, 1, 1, 2,'A1Z' ,'2000-03-02')
|
||||
,(1, 1, 2, 1,'A11Z','2000-03-05')
|
||||
,(1, 1, 2, 2,'A2Z' ,'2000-03-04')
|
||||
,(1, 2, 1, 1,'A13Z','2000-03-05')
|
||||
,(1, 2, 1, 2,'A3Z' ,'2000-03-19')
|
||||
,(1, 2, 2, 1,'A15Z','2000-03-05')
|
||||
,(1, 2, 2, 2,'A4Z' ,'2000-03-19')
|
||||
,(1, 3, 3, 3,'A10Z','2000-03-05')
|
||||
,(2, 5, 5, 5,'A5Z' ,'2000-03-10')
|
||||
,(2, NULL, 6, 6,null,'2000-04-01')
|
||||
,(2, 6, NULL, 6,'A15Z','2000-05-01')
|
||||
,(null, 6, 6, NULL,'A6Z','2000-03-11')
|
||||
,(2, NULL, NULL, 7,'A5Z','2000-03-02')
|
||||
,(2, NULL, 7, NULL,'A7Z','2000-03-03')
|
||||
,(2, 7, NULL, NULL,'A10Z','2000-03-10')
|
||||
,(3, NULL, NULL, NULL,'A9Z','2000-03-05')
|
||||
;
|
||||
|
||||
explain (verbose, costs off)select 1
|
||||
from (select transaction_timestamp() as aa
|
||||
from tab_1110306_1
|
||||
where f1 <=to_date('2010-01-02')
|
||||
and c1 > 12
|
||||
or statement_timestamp() >=current_timestamp
|
||||
and rownum < 6
|
||||
group by c1) t1
|
||||
group by t1.aa
|
||||
having t1.aa <=transaction_timestamp();
|
||||
|
||||
select 1
|
||||
from (select transaction_timestamp() as aa
|
||||
from tab_1110306_1
|
||||
where f1 <=to_date('2010-01-02')
|
||||
and c1 > 12
|
||||
or statement_timestamp() >=current_timestamp
|
||||
and rownum < 6
|
||||
group by c1) t1
|
||||
group by t1.aa
|
||||
having t1.aa <=transaction_timestamp();
|
||||
|
||||
drop table tab_1110306_1;
|
||||
drop table student_cstore1;
|
||||
drop table student_cstore2;
|
||||
drop table student;
|
||||
|
|
Loading…
Reference in New Issue