Movatterモバイル変換


[0]ホーム

URL:



Facebook
Postgres Pro
Facebook
Downloads
PostgreSQL 9.4.1 Documentation
PrevUpChapter 9. Functions and OperatorsNext

9.28. Event Trigger Functions

CurrentlyPostgreSQL provides one built-in event trigger helper function,pg_event_trigger_dropped_objects.

pg_event_trigger_dropped_objects returns a list of all objects dropped by the command in whosesql_drop event it is called. If called in any other context,pg_event_trigger_dropped_objects raises an error.pg_event_trigger_dropped_objects returns the following columns:

NameTypeDescription
classidOidOID of catalog the object belonged in
objidOidOID the object had within the catalog
objsubidint32Object sub-id (e.g. attribute number for columns)
object_typetextType of the object
schema_nametext Name of the schema the object belonged in, if any; otherwiseNULL. No quoting is applied.
object_nametext Name of the object, if the combination of schema and name can be used as a unique identifier for the object; otherwiseNULL. No quoting is applied, and name is never schema-qualified.
object_identitytext Text rendering of the object identity, schema-qualified. Each and every identifier present in the identity is quoted if necessary.

Thepg_event_trigger_dropped_objects function can be used in an event trigger like this:

CREATE FUNCTION test_event_trigger_for_drops()        RETURNS event_trigger LANGUAGE plpgsql AS $$DECLARE    obj record;BEGIN    FOR obj IN SELECT * FROM pg_event_trigger_dropped_objects()    LOOP        RAISE NOTICE '% dropped object: % %.% %',                     tg_tag,                     obj.object_type,                     obj.schema_name,                     obj.object_name,                     obj.object_identity;    END LOOP;END$$;CREATE EVENT TRIGGER test_event_trigger_for_drops   ON sql_drop   EXECUTE PROCEDURE test_event_trigger_for_drops();

For more information about event triggers, seeChapter 37.


PrevHomeNext
Trigger FunctionsUpType Conversion
Go to PostgreSQL 9.4
By continuing to browse this website, you agree to the use of cookies. Go toPrivacy Policy.

[8]ページ先頭

©2009-2025 Movatter.jp