Skip to content

Commit a4e190a

Browse files
committed
Merge branch 'rel_future_beta' of github.com:postgrespro/pg_pathman into rel_future_beta
2 parents 1cbe237 + 7d39ce5 commit a4e190a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

pg_pathman--1.3--1.4.sql

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ DROP FUNCTION @extschema@.on_create_partitions(REGCLASS);
8989
DROP FUNCTION @extschema@.on_update_partitions(REGCLASS);
9090
DROP FUNCTION @extschema@.on_remove_partitions(REGCLASS);
9191
DROP FUNCTION @extschema@.is_attribute_nullable(REGCLASS, TEXT);
92+
DROP FUNCTION @extschema@.build_check_constraint_name(REGCLASS, TEXT);
9293
DROP FUNCTION @extschema@.build_check_constraint_name(REGCLASS, INT2);
9394
DROP FUNCTION @extschema@.add_to_pathman_config(REGCLASS, TEXT, TEXT);
9495
DROP FUNCTION @extschema@.lock_partitioned_relation(REGCLASS);
@@ -257,6 +258,31 @@ END
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+
260286
CREATE OR REPLACE FUNCTION @extschema@.create_naming_sequence(
261287
parent_relid REGCLASS)
262288
RETURNS TEXT AS $$

0 commit comments

Comments
 (0)