@@ -31,13 +31,13 @@ CREATE TABLE IF NOT EXISTS @extschema@.pathman_config (
31
31
* partrel - regclass (relation type, stored as Oid)
32
32
* enable_parent - add parent table to plan
33
33
* auto - enable automatic partition creation
34
- * callback -
34
+ * init_callback - cb to be executed on partition creation
35
35
*/
36
36
CREATE TABLE IF NOT EXISTS @extschema@.pathman_config_params (
37
37
partrel REGCLASS NOT NULL PRIMARY KEY ,
38
38
enable_parent BOOLEAN NOT NULL DEFAULT TRUE,
39
39
auto BOOLEAN NOT NULL DEFAULT TRUE,
40
- callback REGPROCEDURE
40
+ init_callback REGPROCEDURE NOT NULL DEFAULT 0
41
41
);
42
42
CREATE UNIQUE INDEX i_pathman_config_params
43
43
ON @extschema@.pathman_config_params(partrel);
87
87
RETURN count (* ) FROM pg_inherits WHERE inhparent = relation;
88
88
END
89
89
$$
90
- LANGUAGE plpgsql;
90
+ LANGUAGE plpgsql STRICT ;
91
91
92
92
/*
93
93
* Add a row describing the optional parameter to pathman_config_params.
108
108
LANGUAGE plpgsql;
109
109
110
110
/*
111
- * Include parent relation into query plan's for specified relation.
112
- */
113
- CREATE OR REPLACE FUNCTION @extschema@.enable_parent(relation REGCLASS)
114
- RETURNS VOID AS
115
- $$
116
- BEGIN
117
- PERFORM @extschema@.pathman_set_param(relation, ' enable_parent' , True);
118
- END
119
- $$
120
- LANGUAGE plpgsql;
121
-
122
- /*
123
- * Do not include parent relation into query plan's for specified relation.
111
+ * Include\exclude parent relation in query plan.
124
112
*/
125
- CREATE OR REPLACE FUNCTION @extschema@.disable_parent(relation REGCLASS)
126
- RETURNS VOID AS
127
- $$
128
- BEGIN
129
- PERFORM @extschema@.pathman_set_param(relation, ' enable_parent' , False);
130
- END
131
- $$
132
- LANGUAGE plpgsql;
133
-
134
- /*
135
- * Enable automatic partition creation.
136
- */
137
- CREATE OR REPLACE FUNCTION @extschema@.enable_auto(relation REGCLASS)
113
+ CREATE OR REPLACE FUNCTION @extschema@.set_enable_parent(
114
+ relation REGCLASS,
115
+ value BOOLEAN )
138
116
RETURNS VOID AS
139
117
$$
140
118
BEGIN
141
- PERFORM @extschema@.pathman_set_param(relation, ' auto ' , True );
119
+ PERFORM @extschema@.pathman_set_param(relation, ' enable_parent ' , value );
142
120
END
143
121
$$
144
- LANGUAGE plpgsql;
122
+ LANGUAGE plpgsql STRICT ;
145
123
146
124
/*
147
- * Disable automatic partition creation.
125
+ * Enable\disable automatic partition creation.
148
126
*/
149
- CREATE OR REPLACE FUNCTION @extschema@.disable_auto(relation REGCLASS)
127
+ CREATE OR REPLACE FUNCTION @extschema@.set_auto_partitioning(
128
+ relation REGCLASS,
129
+ value BOOLEAN )
150
130
RETURNS VOID AS
151
131
$$
152
132
BEGIN
153
- PERFORM @extschema@.pathman_set_param(relation, ' auto' , False );
133
+ PERFORM @extschema@.pathman_set_param(relation, ' auto' , value );
154
134
END
155
135
$$
156
- LANGUAGE plpgsql;
136
+ LANGUAGE plpgsql STRICT ;
157
137
158
138
/*
159
139
* Set partition creation callback
160
140
*/
161
- CREATE OR REPLACE FUNCTION @extschema@.set_callback(relation REGCLASS, callback REGPROC)
141
+ CREATE OR REPLACE FUNCTION @extschema@.set_part_init_callback(
142
+ relation REGCLASS,
143
+ callback REGPROC)
162
144
RETURNS VOID AS
163
145
$$
164
146
BEGIN
165
147
PERFORM @extschema@.validate_on_partition_created_callback(callback);
166
- PERFORM @extschema@.pathman_set_param(relation, ' callback ' , callback);
148
+ PERFORM @extschema@.pathman_set_param(relation, ' init_callback ' , callback);
167
149
END
168
150
$$
169
151
LANGUAGE plpgsql;
@@ -262,7 +244,7 @@ BEGIN
262
244
RETURN;
263
245
END
264
246
$$
265
- LANGUAGE plpgsql
247
+ LANGUAGE plpgsql STRICT
266
248
SET pg_pathman .enable_partitionfilter = on ; /* ensures that PartitionFilter is ON */
267
249
268
250
/*
@@ -291,7 +273,7 @@ BEGIN
291
273
RETURN;
292
274
END
293
275
$$
294
- LANGUAGE plpgsql
276
+ LANGUAGE plpgsql STRICT
295
277
SET pg_pathman .enable_partitionfilter = on ; /* ensures that PartitionFilter is ON */
296
278
297
279
/*
@@ -311,7 +293,7 @@ BEGIN
311
293
PERFORM @extschema@.on_remove_partitions(parent_relid);
312
294
END
313
295
$$
314
- LANGUAGE plpgsql;
296
+ LANGUAGE plpgsql STRICT ;
315
297
316
298
/*
317
299
* Aggregates several common relation checks before partitioning.
@@ -380,7 +362,7 @@ BEGIN
380
362
INTO schema, relname;
381
363
END
382
364
$$
383
- LANGUAGE plpgsql;
365
+ LANGUAGE plpgsql STRICT ;
384
366
385
367
/*
386
368
* Returns schema-qualified name for table
@@ -399,7 +381,7 @@ BEGIN
399
381
WHERE oid = cls::oid );
400
382
END
401
383
$$
402
- LANGUAGE plpgsql;
384
+ LANGUAGE plpgsql STRICT ;
403
385
404
386
/*
405
387
* Validates relation name. It must be schema qualified
@@ -499,7 +481,7 @@ BEGIN
499
481
EXECUTE format(' DROP FUNCTION IF EXISTS %s() CASCADE' ,
500
482
@extschema@.build_update_trigger_func_name(parent_relid));
501
483
END
502
- $$ LANGUAGE plpgsql;
484
+ $$ LANGUAGE plpgsql STRICT ;
503
485
504
486
/*
505
487
* Drop partitions
@@ -584,7 +566,7 @@ BEGIN
584
566
pg_get_constraintdef(rec .conid ));
585
567
END LOOP;
586
568
END
587
- $$ LANGUAGE plpgsql;
569
+ $$ LANGUAGE plpgsql STRICT ;
588
570
589
571
590
572
/*
@@ -712,28 +694,25 @@ RETURNS VOID AS 'pg_pathman', 'debug_capture'
712
694
LANGUAGE C STRICT;
713
695
714
696
/*
715
- * Return tablespace name for specified relation
697
+ * Return tablespace name for specified relation.
716
698
*/
717
699
CREATE OR REPLACE FUNCTION @extschema@.get_rel_tablespace_name(relation REGCLASS)
718
700
RETURNS TEXT AS ' pg_pathman' , ' get_rel_tablespace_name'
719
701
LANGUAGE C STRICT;
720
702
721
703
/*
722
704
* Checks that callback function meets specific requirements. Particularly it
723
- * must have the only JSONB argument and VOID return type
705
+ * must have the only JSONB argument and VOID return type.
724
706
*/
725
707
CREATE OR REPLACE FUNCTION @extschema@.validate_on_partition_created_callback(callback REGPROC)
726
- RETURNS VOID AS ' pg_pathman' , ' validate_on_partition_created_callback '
708
+ RETURNS VOID AS ' pg_pathman' , ' validate_on_part_init_callback_pl '
727
709
LANGUAGE C STRICT;
728
710
729
711
/*
730
- * Builds JSONB object containing new partition parameters and invoke the
731
- * callback
712
+ * Builds JSONB object containing new partition parameters and invoke the callback.
732
713
*/
733
714
CREATE OR REPLACE FUNCTION @extschema@.invoke_on_partition_created_callback(
734
- parent REGCLASS,
735
- partition REGCLASS,
736
- start_value ANYELEMENT,
737
- end_value ANYELEMENT)
738
- RETURNS VOID AS ' pg_pathman' , ' invoke_on_partition_created_callback'
739
- LANGUAGE C STRICT;
715
+ parent_relid REGCLASS,
716
+ partition REGCLASS)
717
+ RETURNS JSONB AS ' pg_pathman' , ' invoke_on_partition_created_callback'
718
+ LANGUAGE C;
0 commit comments