File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ DROP FUNCTION @extschema@.on_create_partitions(REGCLASS);
8989DROP FUNCTION @extschema@.on_update_partitions(REGCLASS);
9090DROP FUNCTION @extschema@.on_remove_partitions(REGCLASS);
9191DROP FUNCTION @extschema@.is_attribute_nullable(REGCLASS, TEXT );
92+ DROP FUNCTION @extschema@.build_check_constraint_name(REGCLASS, TEXT );
9293DROP FUNCTION @extschema@.build_check_constraint_name(REGCLASS, INT2);
9394DROP FUNCTION @extschema@.add_to_pathman_config(REGCLASS, TEXT , TEXT );
9495DROP FUNCTION @extschema@.lock_partitioned_relation(REGCLASS);
257258$$ LANGUAGE plpgsql;
258259
259260
261+ CREATE OR REPLACE FUNCTION @extschema@.pathman_ddl_trigger_func()
262+ RETURNS event_trigger AS $$
263+ DECLARE
264+ obj RECORD;
265+ pg_class_oid OID ;
266+ relids REGCLASS[];
267+
268+ BEGIN
269+ pg_class_oid = ' pg_catalog.pg_class' ::regclass;
270+
271+ /* Find relids to remove from config */
272+ SELECT array_agg(cfg .partrel ) INTO relids
273+ FROM pg_event_trigger_dropped_objects() AS events
274+ JOIN @extschema@.pathman_config AS cfg ON cfg .partrel ::oid = events .objid
275+ WHERE events .classid = pg_class_oid AND events .objsubid = 0 ;
276+
277+ /* Cleanup pathman_config */
278+ DELETE FROM @extschema@.pathman_config WHERE partrel = ANY(relids);
279+
280+ /* Cleanup params table too */
281+ DELETE FROM @extschema@.pathman_config_params WHERE partrel = ANY(relids);
282+ END
283+ $$ LANGUAGE plpgsql;
284+
285+
260286CREATE OR REPLACE FUNCTION @extschema@.create_naming_sequence(
261287 parent_relid REGCLASS)
262288RETURNS TEXT AS $$
You can’t perform that action at this time.
0 commit comments