@@ -31,13 +31,13 @@ CREATE TABLE IF NOT EXISTS @extschema@.pathman_config (
3131 * partrel - regclass (relation type, stored as Oid)
3232 * enable_parent - add parent table to plan
3333 * auto - enable automatic partition creation
34- * callback -
34+ * init_callback - cb to be executed on partition creation
3535 */
3636CREATE TABLE IF NOT EXISTS @extschema@.pathman_config_params (
3737 partrel REGCLASS NOT NULL PRIMARY KEY ,
3838 enable_parent BOOLEAN NOT NULL DEFAULT TRUE,
3939 auto BOOLEAN NOT NULL DEFAULT TRUE,
40- callback REGPROCEDURE
40+ init_callback REGPROCEDURE NOT NULL DEFAULT 0
4141);
4242CREATE UNIQUE INDEX i_pathman_config_params
4343ON @extschema@.pathman_config_params(partrel);
8787 RETURN count (* ) FROM pg_inherits WHERE inhparent = relation;
8888END
8989$$
90- LANGUAGE plpgsql;
90+ LANGUAGE plpgsql STRICT ;
9191
9292/*
9393 * Add a row describing the optional parameter to pathman_config_params.
108108LANGUAGE plpgsql;
109109
110110/*
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.
124112 */
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 )
138116RETURNS VOID AS
139117$$
140118BEGIN
141- PERFORM @extschema@.pathman_set_param(relation, ' auto ' , True );
119+ PERFORM @extschema@.pathman_set_param(relation, ' enable_parent ' , value );
142120END
143121$$
144- LANGUAGE plpgsql;
122+ LANGUAGE plpgsql STRICT ;
145123
146124/*
147- * Disable automatic partition creation.
125+ * Enable\disable automatic partition creation.
148126 */
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 )
150130RETURNS VOID AS
151131$$
152132BEGIN
153- PERFORM @extschema@.pathman_set_param(relation, ' auto' , False );
133+ PERFORM @extschema@.pathman_set_param(relation, ' auto' , value );
154134END
155135$$
156- LANGUAGE plpgsql;
136+ LANGUAGE plpgsql STRICT ;
157137
158138/*
159139 * Set partition creation callback
160140 */
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)
162144RETURNS VOID AS
163145$$
164146BEGIN
165147 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);
167149END
168150$$
169151LANGUAGE plpgsql;
@@ -262,7 +244,7 @@ BEGIN
262244 RETURN;
263245END
264246$$
265- LANGUAGE plpgsql
247+ LANGUAGE plpgsql STRICT
266248SET pg_pathman .enable_partitionfilter = on ; /* ensures that PartitionFilter is ON */
267249
268250/*
@@ -291,7 +273,7 @@ BEGIN
291273 RETURN;
292274END
293275$$
294- LANGUAGE plpgsql
276+ LANGUAGE plpgsql STRICT
295277SET pg_pathman .enable_partitionfilter = on ; /* ensures that PartitionFilter is ON */
296278
297279/*
@@ -311,7 +293,7 @@ BEGIN
311293 PERFORM @extschema@.on_remove_partitions(parent_relid);
312294END
313295$$
314- LANGUAGE plpgsql;
296+ LANGUAGE plpgsql STRICT ;
315297
316298/*
317299 * Aggregates several common relation checks before partitioning.
@@ -380,7 +362,7 @@ BEGIN
380362 INTO schema, relname;
381363END
382364$$
383- LANGUAGE plpgsql;
365+ LANGUAGE plpgsql STRICT ;
384366
385367/*
386368 * Returns schema-qualified name for table
@@ -399,7 +381,7 @@ BEGIN
399381 WHERE oid = cls::oid );
400382END
401383$$
402- LANGUAGE plpgsql;
384+ LANGUAGE plpgsql STRICT ;
403385
404386/*
405387 * Validates relation name. It must be schema qualified
@@ -499,7 +481,7 @@ BEGIN
499481 EXECUTE format(' DROP FUNCTION IF EXISTS %s() CASCADE' ,
500482 @extschema@.build_update_trigger_func_name(parent_relid));
501483END
502- $$ LANGUAGE plpgsql;
484+ $$ LANGUAGE plpgsql STRICT ;
503485
504486/*
505487 * Drop partitions
@@ -584,7 +566,7 @@ BEGIN
584566 pg_get_constraintdef(rec .conid ));
585567 END LOOP;
586568END
587- $$ LANGUAGE plpgsql;
569+ $$ LANGUAGE plpgsql STRICT ;
588570
589571
590572/*
@@ -712,28 +694,25 @@ RETURNS VOID AS 'pg_pathman', 'debug_capture'
712694LANGUAGE C STRICT;
713695
714696/*
715- * Return tablespace name for specified relation
697+ * Return tablespace name for specified relation.
716698 */
717699CREATE OR REPLACE FUNCTION @extschema@.get_rel_tablespace_name(relation REGCLASS)
718700RETURNS TEXT AS ' pg_pathman' , ' get_rel_tablespace_name'
719701LANGUAGE C STRICT;
720702
721703/*
722704 * 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.
724706 */
725707CREATE 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 '
727709LANGUAGE C STRICT;
728710
729711/*
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.
732713 */
733714CREATE 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