D.36 RDB$TRIGGERS

RDB$TRIGGERS stores the trigger definitions for all tables and views.

Column NameData TypeDescription

RDB$TRIGGER_NAME

CHAR(63)

Trigger name

RDB$RELATION_NAME

CHAR(63)

The name of the table or view the trigger applies to. NULL if the trigger is applicable to a database event (database trigger)

RDB$TRIGGER_SEQUENCE

SMALLINT

Position of this trigger in the sequence. Zero usually means that no sequence position is specified

RDB$TRIGGER_TYPE

BIGINT

The event the trigger fires on:

1 - before insert 2 - after insert 3 - before update 4 - after update 5 - before delete 6 - after delete 17 - before insert or update 18 - after insert or update 25 - before insert or delete 26 - after insert or delete 27 - before update or delete 28 - after update or delete 113 - before insert or update or delete 114 - after insert or update or delete 8192 - on connect 8193 - on disconnect 8194 - on transaction start 8195 - on transaction commit 8196 - on transaction rollback

For DDL triggers, the trigger type is obtained by bitwise OR above the event phase (0 - BEFORE, 1 AFTER) and all listed types events:

0x0000000000004002 - CREATE TABLE 0x0000000000004004 - ALTER TABLE 0x0000000000004008 - DROP TABLE 0x0000000000004010 - CREATE PROCEDURE 0x0000000000004020 - ALTER PROCEDURE 0x0000000000004040 - DROP PROCEDURE 0x0000000000004080 - CREATE FUNCTION 0x0000000000004100 - ALTER FUNCTION 0x0000000000004200 - DROP FUNCTION 0x0000000000004400 - CREATE TRIGGER 0x0000000000004800 - ALTER TRIGGER 0x0000000000005000 - DROP TRIGGER 0x0000000000014000 - CREATE EXCEPTION 0x0000000000024000 - ALTER EXCEPTION 0x0000000000044000 - DROP EXCEPTION 0x0000000000084000 - CREATE VIEW 0x0000000000104000 - ALTER VIEW 0x0000000000204000 - DROP VIEW 0x0000000000404000 - CREATE DOMAIN 0x0000000000804000 - ALTER DOMAIN 0x0000000001004000 - DROP DOMAIN 0x0000000002004000 - CREATE ROLE 0x0000000004004000 - ALTER ROLE 0x0000000008004000 - DROP ROLE 0x0000000010004000 - CREATE INDEX 0x0000000020004000 - ALTER INDEX 0x0000000040004000 - DROP INDEX 0x0000000080004000 - CREATE SEQUENCE 0x0000000100004000 - ALTER SEQUENCE 0x0000000200004000 - DROP SEQUENCE 0x0000000400004000 - CREATE USER 0x0000000800004000 - ALTER USER 0x0000001000004000 - DROP USER 0x0000002000004000 - CREATE COLLATION 0x0000004000004000 - DROP COLLATION 0x0000008000004000 - ALTER CHARACTER SET 0x0000010000004000 - CREATE PACKAGE 0x0000020000004000 - ALTER PACKAGE 0x0000040000004000 - DROP PACKAGE 0x0000080000004000 - CREATE PACKAGE BODY 0x0000100000004000 - DROP PACKAGE BODY 0x0000200000004000 - CREATE MAPPING 0x0000400000004000 - ALTER MAPPING 0x0000800000004000 - DROP MAPPING 0x7FFFFFFFFFFFDFFE - ANY DDL STATEMENT

For example trigger BEFORE CREATE PROCEDURE OR CREATE FUNCTION will be of type 0x0000000000004090, AFTER CREATE PROCEDURE OR CREATE FUNCTION - 0x0000000000004091, BEFORE DROP FUNCTION OR DROP EXCEPTION - 0x00000000000044200, AFTER DROP FUNCTION OR DROP EXCEPTION - 0x00000000000044201, BEFORE DROP TRIGGER OR DROP DOMAIN - 0x00000000001005000, AFTER DROP TRIGGER OR DROP DOMAIN - 0x00000000001005001.

Identification of the exact RDB$TRIGGER_TYPE code is a little more complicated, since it is a bitmap, calculated according to which phase and events are covered and the order in which they are defined. For the curious, the calculation is explained in this code comment by Mark Rotteveel.

RDB$TRIGGER_SOURCE

BLOB TEXT

Stores the source code of the trigger in PSQL

RDB$TRIGGER_BLR

BLOB BLR

Stores the trigger in the binary language representation (BLR)

RDB$DESCRIPTION

BLOB TEXT

Trigger comment text

RDB$TRIGGER_INACTIVE

SMALLINT

Indicates whether the trigger is currently inactive (1) or active (0)

RDB$SYSTEM_FLAG

SMALLINT

Flag: indicates whether the trigger is user-defined (value 0) or system-defined (value 1 or greater)

RDB$FLAGS

SMALLINT

Internal use

RDB$VALID_BLR

SMALLINT

Indicates whether the text of the trigger remains valid after the latest modification by the the ALTER TRIGGER statement

RDB$DEBUG_INFO

BLOB

Contains debugging information about variables used in the trigger

RDB$ENGINE_NAME

CHAR(63)

Engine for external triggers. ‘UDR’ for UDR triggers. NULL for PSQL triggers

RDB$ENTRYPOINT

CHAR(255)

The exported name of the external trigger in the trigger library. Note, this is often not the same as RDB$TRIGGER_NAME, which is the identifier with which the trigger is declared to the database

RDB$SQL_SECURITY

BOOLEAN

The SQL SECURITY mode (DEFINER or INVOKER):

NULL - initial default (INVOKER) FALSE - INVOKER TRUE - DEFINER