feat: enterprise audit fixes (schema resolution, race conditions, documentation)
This commit is contained in:
@@ -18,7 +18,7 @@ BEGIN
|
||||
SELECT n.nspname INTO v_schema
|
||||
FROM pg_class c
|
||||
JOIN pg_namespace n ON n.oid = c.relnamespace
|
||||
WHERE c.relname = v_table AND c.relkind = 'p';
|
||||
WHERE c.relname = v_table AND c.relkind = 'p' AND pg_table_is_visible(c.oid);
|
||||
|
||||
IF v_schema IS NOT NULL THEN
|
||||
RAISE NOTICE 'Reverting partitioned table %...', v_table;
|
||||
@@ -47,15 +47,25 @@ BEGIN
|
||||
|
||||
RAISE NOTICE 'SUCCESS: % reverted to default. Partitioned data stored in % (You can DROP TABLE % CASCADE; later).', v_table, v_part_table, v_part_table;
|
||||
|
||||
ELSIF EXISTS (SELECT 1 FROM pg_class WHERE relname = v_table AND relkind = 'r') THEN
|
||||
ELSIF EXISTS (SELECT 1 FROM pg_class WHERE relname = v_table AND relkind = 'r' AND pg_table_is_visible(oid)) THEN
|
||||
RAISE NOTICE 'Table % is already a regular table. Skipping.', v_table;
|
||||
ELSE
|
||||
RAISE WARNING 'Partitioned table % not found!', v_table;
|
||||
END IF;
|
||||
END LOOP;
|
||||
|
||||
-- Drop the housekeeper intercept trigger
|
||||
DROP TRIGGER IF EXISTS housekeeper_filter ON housekeeper;
|
||||
-- Drop the housekeeper intercept trigger (dynamically determine schema for custom schema support)
|
||||
SELECT n.nspname INTO v_schema
|
||||
FROM pg_class c
|
||||
JOIN pg_namespace n ON n.oid = c.relnamespace
|
||||
WHERE c.relname = 'housekeeper' AND pg_table_is_visible(c.oid);
|
||||
|
||||
IF v_schema IS NOT NULL THEN
|
||||
EXECUTE format('DROP TRIGGER IF EXISTS housekeeper_filter ON %I.housekeeper', v_schema);
|
||||
RAISE NOTICE 'Housekeeper intercept trigger removed from %.housekeeper', v_schema;
|
||||
ELSE
|
||||
RAISE WARNING 'housekeeper table not found — trigger removal skipped.';
|
||||
END IF;
|
||||
|
||||
RAISE NOTICE '================================================================================';
|
||||
RAISE NOTICE 'Undo complete. Partitioned tables have been renamed to *_part.';
|
||||
|
||||
Reference in New Issue
Block a user