Skip to content

Commit 010bf7e

Browse files
committed
test inlined SQL functions
1 parent 860c578 commit 010bf7e

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

expected/pathman_basic.out

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,40 @@ WHERE j1.dt < '2015-03-01' AND j2.dt >= '2015-02-01' ORDER BY j2.dt;
10801080
-> Index Scan using range_rel_2_pkey on range_rel_2 j1_1
10811081
(20 rows)
10821082

1083+
/*
1084+
* Test inlined SQL functions
1085+
*/
1086+
CREATE TABLE test.sql_inline (id INT NOT NULL);
1087+
SELECT pathman.create_hash_partitions('test.sql_inline', 'id', 3);
1088+
create_hash_partitions
1089+
------------------------
1090+
3
1091+
(1 row)
1092+
1093+
CREATE OR REPLACE FUNCTION test.sql_inline_func(i_id int) RETURNS SETOF INT AS $$
1094+
select * from test.sql_inline where id = i_id limit 1;
1095+
$$ LANGUAGE sql STABLE;
1096+
EXPLAIN (COSTS OFF) SELECT * FROM test.sql_inline_func(5);
1097+
QUERY PLAN
1098+
--------------------------------------
1099+
Limit
1100+
-> Append
1101+
-> Seq Scan on sql_inline_0
1102+
Filter: (id = 5)
1103+
(4 rows)
1104+
1105+
EXPLAIN (COSTS OFF) SELECT * FROM test.sql_inline_func(1);
1106+
QUERY PLAN
1107+
--------------------------------------
1108+
Limit
1109+
-> Append
1110+
-> Seq Scan on sql_inline_2
1111+
Filter: (id = 1)
1112+
(4 rows)
1113+
1114+
DROP FUNCTION test.sql_inline_func(int);
1115+
DROP TABLE test.sql_inline CASCADE;
1116+
NOTICE: drop cascades to 3 other objects
10831117
/*
10841118
* Test CTE query
10851119
*/

sql/pathman_basic.sql

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,22 @@ JOIN test.range_rel j2 on j2.id = j1.id
264264
JOIN test.num_range_rel j3 on j3.id = j1.id
265265
WHERE j1.dt < '2015-03-01' AND j2.dt >= '2015-02-01' ORDER BY j2.dt;
266266

267+
/*
268+
* Test inlined SQL functions
269+
*/
270+
CREATE TABLE test.sql_inline (id INT NOT NULL);
271+
SELECT pathman.create_hash_partitions('test.sql_inline', 'id', 3);
272+
273+
CREATE OR REPLACE FUNCTION test.sql_inline_func(i_id int) RETURNS SETOF INT AS $$
274+
select * from test.sql_inline where id = i_id limit 1;
275+
$$ LANGUAGE sql STABLE;
276+
277+
EXPLAIN (COSTS OFF) SELECT * FROM test.sql_inline_func(5);
278+
EXPLAIN (COSTS OFF) SELECT * FROM test.sql_inline_func(1);
279+
280+
DROP FUNCTION test.sql_inline_func(int);
281+
DROP TABLE test.sql_inline CASCADE;
282+
267283
/*
268284
* Test CTE query
269285
*/

0 commit comments

Comments
 (0)