@@ -2392,7 +2392,45 @@ EXPLAIN (COSTS OFF) SELECT * FROM test.index_on_childs WHERE c1 > 100 AND c1 < 2
2392
2392
Filter: (c1 < 2500)
2393
2393
(12 rows)
2394
2394
2395
+ /* Test recursive CTE */
2396
+ CREATE TABLE test.recursive_cte_test_tbl(id INT NOT NULL, name TEXT NOT NULL);
2397
+ SELECT * FROM create_hash_partitions('test.recursive_cte_test_tbl', 'id', 2);
2398
+ create_hash_partitions
2399
+ ------------------------
2400
+ 2
2401
+ (1 row)
2402
+
2403
+ INSERT INTO test.recursive_cte_test_tbl (id, name) SELECT id, 'name'||id FROM generate_series(1,100) f(id);
2404
+ INSERT INTO test.recursive_cte_test_tbl (id, name) SELECT id, 'name'||(id + 1) FROM generate_series(1,100) f(id);
2405
+ INSERT INTO test.recursive_cte_test_tbl (id, name) SELECT id, 'name'||(id + 2) FROM generate_series(1,100) f(id);
2406
+ SELECT * FROM test.recursive_cte_test_tbl WHERE id = 5;
2407
+ id | name
2408
+ ----+-------
2409
+ 5 | name5
2410
+ 5 | name6
2411
+ 5 | name7
2412
+ (3 rows)
2413
+
2414
+ WITH RECURSIVE test AS (
2415
+ SELECT min(name) AS name
2416
+ FROM test.recursive_cte_test_tbl
2417
+ WHERE id = 5
2418
+ UNION ALL
2419
+ SELECT (SELECT min(name)
2420
+ FROM test.recursive_cte_test_tbl
2421
+ WHERE id = 5 AND name > test.name)
2422
+ FROM test
2423
+ WHERE name IS NOT NULL)
2424
+ SELECT * FROM test;
2425
+ name
2426
+ -------
2427
+ name5
2428
+ name6
2429
+ name7
2430
+
2431
+ (4 rows)
2432
+
2395
2433
DROP SCHEMA test CASCADE;
2396
- NOTICE: drop cascades to 51 other objects
2434
+ NOTICE: drop cascades to 54 other objects
2397
2435
DROP EXTENSION pg_pathman CASCADE;
2398
2436
DROP SCHEMA pathman CASCADE;
0 commit comments