File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -1080,6 +1080,40 @@ WHERE j1.dt < '2015-03-01' AND j2.dt >= '2015-02-01' ORDER BY j2.dt;
1080
1080
-> Index Scan using range_rel_2_pkey on range_rel_2 j1_1
1081
1081
(20 rows)
1082
1082
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
1083
1117
/*
1084
1118
* Test CTE query
1085
1119
*/
Original file line number Diff line number Diff line change @@ -264,6 +264,22 @@ JOIN test.range_rel j2 on j2.id = j1.id
264
264
JOIN test .num_range_rel j3 on j3 .id = j1 .id
265
265
WHERE j1 .dt < ' 2015-03-01' AND j2 .dt >= ' 2015-02-01' ORDER BY j2 .dt ;
266
266
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
+
267
283
/*
268
284
* Test CTE query
269
285
*/
You can’t perform that action at this time.
0 commit comments