Skip to content

Commit fd2bde6

Browse files
Restore true 0.1.0 content; move default_version to 'stable' (#12)
1 parent bb68c82 commit fd2bde6

3 files changed

Lines changed: 1616 additions & 56 deletions

File tree

object_reference.control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
comment = 'Provides reference IDs for database objects'
2-
default_version = '0.1.0'
2+
default_version = 'stable'
33
relocatable = false
44
schema = 'object_reference'
55
requires = 'cat_tools, count_nulls'

sql/object_reference--0.1.0.sql

Lines changed: 8 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* DO NOT EDIT - AUTO-GENERATED FILE */
2+
SET LOCAL client_min_messages = WARNING;
23
\echo This extension must be loaded via 'CREATE EXTENSION object_reference;'
34
\echo You really, REALLY do NOT want to try and load this via psql!!!
45
\echo It will FAIL during pg_dump! \quit
@@ -187,7 +188,6 @@ CREATE TABLE _object_reference.object(
187188
*/
188189
);
189190
SELECT __object_reference.safe_dump('_object_reference.object');
190-
SELECT __object_reference.safe_dump('_object_reference.object_object_id_seq');
191191
GRANT REFERENCES ON _object_reference.object TO object_reference__dependency;
192192

193193
CREATE TABLE _object_reference._object_oid(
@@ -357,7 +357,7 @@ BEGIN
357357
IF object_type IS NULL THEN
358358
-- Should definitely exist
359359
SELECT INTO STRICT object_type, classid, objid, objsubid
360-
o.object_type, a.classid, a.objid, a.objsubid
360+
o.object_type, a.classid, a.objid, a.subobjid
361361
FROM _object_reference.object o
362362
, pg_catalog.pg_get_object_address(o.object_type::text, o.object_names, o.object_args) a
363363
WHERE o.object_id = _object_oid__add.object_id
@@ -1366,8 +1366,6 @@ BEGIN
13661366
USING HINT = 'Did you not start a transaction? Did you forget to call object_reference.capture__stop()?'
13671367
;
13681368
END IF;
1369-
1370-
RETURN NULL;
13711369
END
13721370
$body$
13731371
, 'Trigger function to ensure capture__stop() is called an appropriate number of times.'
@@ -1511,59 +1509,14 @@ $body$
15111509
, 'Event trigger function to drop object records when objects are removed.'
15121510
);
15131511

1514-
SELECT __object_reference.create_function(
1515-
'_object_reference.etg_raise__start'
1516-
, ''
1517-
, 'event_trigger LANGUAGE plpgsql'
1518-
, $body$
1519-
BEGIN
1520-
RAISE WARNING 'etg_raise__start: % %', tg_event, tg_tag;
1521-
END;
1522-
$body$
1523-
, $$Event trigger function to report on DDL activity. Example trigger:
1524-
CREATE EVENT TRIGGER start
1525-
ON ddl_command_start
1526-
--WHEN tag IN ( 'ALTER TABLE', 'DROP TABLE' )
1527-
EXECUTE PROCEDURE _object_reference.etg_raise__start()
1528-
;
1529-
$$);
1530-
SELECT __object_reference.create_function(
1531-
'_object_reference.etg_raise__drop'
1532-
, ''
1533-
, 'event_trigger LANGUAGE plpgsql'
1534-
, $body$
1535-
DECLARE
1536-
r record;
1512+
/*
1513+
CREATE OR REPLACE FUNCTION snitch() RETURNS event_trigger AS $$
15371514
BEGIN
1538-
FOR r IN SELECT classid, objid, objsubid, object_type, schema_name, object_name, object_identity FROM pg_catalog.pg_event_trigger_dropped_objects() LOOP
1539-
RAISE WARNING 'dropped_objects:
1540-
classid: %
1541-
objid: %
1542-
objsubid: %
1543-
object_type: %
1544-
schema_name: %
1545-
object_name: %
1546-
object_identity: %
1547-
'
1548-
-- :^r" s/\([^ ]\+\):.*/, r.\1/
1549-
, r.classid
1550-
, r.objid
1551-
, r.objsubid
1552-
, r.object_type
1553-
, r.schema_name
1554-
, r.object_name
1555-
, r.object_identity
1556-
;
1557-
END LOOP;
1515+
RAISE WARNING 'snitch: % %', tg_event, tg_tag;
15581516
END;
1559-
$body$
1560-
, $$Event trigger function to report on DDL activity. Example trigger:
1561-
CREATE EVENT TRIGGER drop
1562-
ON sql_drop
1563-
--WHEN tag IN ( 'ALTER TABLE', 'DROP TABLE' )
1564-
EXECUTE PROCEDURE _object_reference.etg_raise__drop()
1565-
;
1566-
$$);
1517+
$$ LANGUAGE plpgsql;
1518+
CREATE EVENT TRIGGER snitch ON ddl_command_start EXECUTE PROCEDURE snitch();
1519+
*/
15671520

15681521
CREATE EVENT TRIGGER zzz__object_reference_drop
15691522
ON sql_drop

0 commit comments

Comments
 (0)