Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion object_reference.control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
comment = 'Provides reference IDs for database objects'
default_version = '0.1.0'
default_version = 'stable'
relocatable = false
schema = 'object_reference'
requires = 'cat_tools, count_nulls'
63 changes: 8 additions & 55 deletions sql/object_reference--0.1.0.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* DO NOT EDIT - AUTO-GENERATED FILE */
SET LOCAL client_min_messages = WARNING;
\echo This extension must be loaded via 'CREATE EXTENSION object_reference;'
\echo You really, REALLY do NOT want to try and load this via psql!!!
\echo It will FAIL during pg_dump! \quit
Expand Down Expand Up @@ -187,7 +188,6 @@ CREATE TABLE _object_reference.object(
*/
);
SELECT __object_reference.safe_dump('_object_reference.object');
SELECT __object_reference.safe_dump('_object_reference.object_object_id_seq');
GRANT REFERENCES ON _object_reference.object TO object_reference__dependency;

CREATE TABLE _object_reference._object_oid(
Expand Down Expand Up @@ -357,7 +357,7 @@ BEGIN
IF object_type IS NULL THEN
-- Should definitely exist
SELECT INTO STRICT object_type, classid, objid, objsubid
o.object_type, a.classid, a.objid, a.objsubid
o.object_type, a.classid, a.objid, a.subobjid
FROM _object_reference.object o
, pg_catalog.pg_get_object_address(o.object_type::text, o.object_names, o.object_args) a
WHERE o.object_id = _object_oid__add.object_id
Expand Down Expand Up @@ -1366,8 +1366,6 @@ BEGIN
USING HINT = 'Did you not start a transaction? Did you forget to call object_reference.capture__stop()?'
;
END IF;

RETURN NULL;
END
$body$
, 'Trigger function to ensure capture__stop() is called an appropriate number of times.'
Expand Down Expand Up @@ -1511,59 +1509,14 @@ $body$
, 'Event trigger function to drop object records when objects are removed.'
);

SELECT __object_reference.create_function(
'_object_reference.etg_raise__start'
, ''
, 'event_trigger LANGUAGE plpgsql'
, $body$
BEGIN
RAISE WARNING 'etg_raise__start: % %', tg_event, tg_tag;
END;
$body$
, $$Event trigger function to report on DDL activity. Example trigger:
CREATE EVENT TRIGGER start
ON ddl_command_start
--WHEN tag IN ( 'ALTER TABLE', 'DROP TABLE' )
EXECUTE PROCEDURE _object_reference.etg_raise__start()
;
$$);
SELECT __object_reference.create_function(
'_object_reference.etg_raise__drop'
, ''
, 'event_trigger LANGUAGE plpgsql'
, $body$
DECLARE
r record;
/*
CREATE OR REPLACE FUNCTION snitch() RETURNS event_trigger AS $$
BEGIN
FOR r IN SELECT classid, objid, objsubid, object_type, schema_name, object_name, object_identity FROM pg_catalog.pg_event_trigger_dropped_objects() LOOP
RAISE WARNING 'dropped_objects:
classid: %
objid: %
objsubid: %
object_type: %
schema_name: %
object_name: %
object_identity: %
'
-- :^r" s/\([^ ]\+\):.*/, r.\1/
, r.classid
, r.objid
, r.objsubid
, r.object_type
, r.schema_name
, r.object_name
, r.object_identity
;
END LOOP;
RAISE WARNING 'snitch: % %', tg_event, tg_tag;
END;
$body$
, $$Event trigger function to report on DDL activity. Example trigger:
CREATE EVENT TRIGGER drop
ON sql_drop
--WHEN tag IN ( 'ALTER TABLE', 'DROP TABLE' )
EXECUTE PROCEDURE _object_reference.etg_raise__drop()
;
$$);
$$ LANGUAGE plpgsql;
CREATE EVENT TRIGGER snitch ON ddl_command_start EXECUTE PROCEDURE snitch();
*/

CREATE EVENT TRIGGER zzz__object_reference_drop
ON sql_drop
Expand Down
Loading
Loading