diff --git a/doc/src/sgml/event-trigger.sgml b/doc/src/sgml/event-trigger.sgml index d0306390346..cfa7b3d1b2d 100644 --- a/doc/src/sgml/event-trigger.sgml +++ b/doc/src/sgml/event-trigger.sgml @@ -104,6 +104,11 @@ control statements are available to rewrite a table, like CLUSTER and VACUUM, the table_rewrite event is not triggered by them. + To find the OID of the table that was rewritten, use the function + pg_event_trigger_table_rewrite_oid() (see + ). To discover the reason(s) + for the rewrite, use the function + pg_event_trigger_table_rewrite_reason(). diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 7be0324ac87..05f630c6a6c 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -31687,8 +31687,12 @@ CREATE EVENT TRIGGER test_event_trigger_for_drops integer - Returns a code explaining the reason(s) for rewriting. The exact - meaning of the codes is release dependent. + Returns a code explaining the reason(s) for rewriting. The value is + a bitmap built from the following values: 1 + (the table has changed its persistence), 2 + (default value of a column has changed), 4 + (a column has a new data type) and 8 + (the table access method has changed). diff --git a/src/include/commands/event_trigger.h b/src/include/commands/event_trigger.h index 90fc1af5f69..00cfb397584 100644 --- a/src/include/commands/event_trigger.h +++ b/src/include/commands/event_trigger.h @@ -31,6 +31,12 @@ typedef struct EventTriggerData extern PGDLLIMPORT bool event_triggers; +/* + * Reasons for relation rewrites. + * + * pg_event_trigger_table_rewrite_reason() uses these values, so make sure to + * update the documentation when changing this list. + */ #define AT_REWRITE_ALTER_PERSISTENCE 0x01 #define AT_REWRITE_DEFAULT_VAL 0x02 #define AT_REWRITE_COLUMN_REWRITE 0x04