Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0e54eef

Browse files
author
Maksim Milyutin
committed
Add test case for recursive CTE
1 parentf8726be commit0e54eef

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

‎expected/pathman_basic.out

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2001,7 +2001,35 @@ EXPLAIN (COSTS OFF) SELECT * FROM test.index_on_childs WHERE c1 > 100 AND c1 < 2
20012001
Filter: (c1 < 2500)
20022002
(12 rows)
20032003

2004+
/* Test recursive CTE */
2005+
create table test.recursive_cte_test_tbl(id int not null, name text not null);
2006+
select * from create_hash_partitions('test.recursive_cte_test_tbl', 'id', 2);
2007+
create_hash_partitions
2008+
------------------------
2009+
2
2010+
(1 row)
2011+
2012+
insert into test.recursive_cte_test_tbl (id, name) select id, 'name'||id from generate_series(1,100) f(id);
2013+
insert into test.recursive_cte_test_tbl (id, name) select id, 'name'||(id + 1) from generate_series(1,100) f(id);
2014+
insert into test.recursive_cte_test_tbl (id, name) select id, 'name'||(id + 2) from generate_series(1,100) f(id);
2015+
select * from test.recursive_cte_test_tbl where id = 5;
2016+
id | name
2017+
----+-------
2018+
5 | name5
2019+
5 | name6
2020+
5 | name7
2021+
(3 rows)
2022+
2023+
with recursive test as (select min(name) as name from test.recursive_cte_test_tbl where id = 5 union all select (select min(name) from test.recursive_cte_test_tbl where id = 5 and name > test.name) from test where name is not null) select * from test;
2024+
name
2025+
-------
2026+
name5
2027+
name6
2028+
name7
2029+
2030+
(4 rows)
2031+
20042032
DROP SCHEMA test CASCADE;
2005-
NOTICE: drop cascades to48 other objects
2033+
NOTICE: drop cascades to51 other objects
20062034
DROP EXTENSION pg_pathman CASCADE;
20072035
DROP SCHEMA pathman CASCADE;

‎sql/pathman_basic.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,15 @@ SELECT set_enable_parent('test.index_on_childs', true);
517517
VACUUM ANALYZEtest.index_on_childs;
518518
EXPLAIN (COSTS OFF)SELECT*FROMtest.index_on_childsWHERE c1>100AND c1<2500AND c2=500;
519519

520+
/* Test recursive CTE*/
521+
createtabletest.recursive_cte_test_tbl(idintnot null, nametextnot null);
522+
select*from create_hash_partitions('test.recursive_cte_test_tbl','id',2);
523+
insert intotest.recursive_cte_test_tbl (id, name)select id,'name'||idfrom generate_series(1,100) f(id);
524+
insert intotest.recursive_cte_test_tbl (id, name)select id,'name'||(id+1)from generate_series(1,100) f(id);
525+
insert intotest.recursive_cte_test_tbl (id, name)select id,'name'||(id+2)from generate_series(1,100) f(id);
526+
select*fromtest.recursive_cte_test_tblwhere id=5;
527+
with recursive testas (selectmin(name)as namefromtest.recursive_cte_test_tblwhere id=5union allselect (selectmin(name)fromtest.recursive_cte_test_tblwhere id=5and name>test.name)from testwhere nameis not null)select*from test;
528+
520529
DROPSCHEMA test CASCADE;
521530
DROP EXTENSION pg_pathman CASCADE;
522531
DROPSCHEMA pathman CASCADE;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp