9.28. 事件觸發函式
PostgreSQLprovides these helper functions to retrieve information from event triggers.
For more information about event triggers, seeChapter 39.
9.28.1. Capturing Changes at Command End
pg_event_trigger_ddl_commands
returns a list ofDDLcommands executed by each user action, when invoked in a function attached to addl_command_end
event trigger. If called in any other context, an error is raised.pg_event_trigger_ddl_commands
returns one row for each base command executed; some commands that are a single SQL sentence may return more than one row. This function returns the following columns:
Name | Type | Description |
|
| OID of catalog the object belongs in |
|
| OID of the object in the catalog |
|
| Object sub-id (e.g. attribute number for columns) |
|
| command tag |
|
| Type of the object |
|
| Name of the schema the object belongs in, if any; otherwise |
|
| Text rendering of the object identity, schema-qualified. Each and every identifier present in the identity is quoted if necessary. |
|
| whether the command is part of an extension script |
|
| A complete representation of the command, in internal format. This cannot be output directly, but it can be passed to other functions to obtain different pieces of information about the command. |
9.28.2. Processing Objects Dropped by a DDL Command
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:
Name | Type | Description |
|
| OID of catalog the object belonged in |
|
| OID the object had within the catalog |
|
| Object sub-id (e.g. attribute number for columns) |
|
| Flag used to identify the root object(s) of the deletion |
|
| Flag indicating that there's a normal dependency relationship in the dependency graph leading to this object |
|
| Flag indicating that the object was a temporary object. |
|
| Type of the object |
|
| Name of the schema the object belonged in, if any; otherwise |
|
| Name of the object, if the combination of schema and name can be used as a unique identifier for the object; otherwise |
|
| Text rendering of the object identity, schema-qualified. Each and every identifier present in the identity is quoted if necessary. |
|
| An array that, together with |
|
| Complement for |
Thepg_event_trigger_dropped_objects
function can be used in an event trigger like this:
9.28.3. Handling a Table Rewrite Event
The functions shown inTable 9.90provide information about a table for which atable_rewrite
event has just been called. If called in any other context, an error is raised.
Table 9.90. Table Rewrite information
Name | Return Type | Description |
|
| The OID of the table about to be rewritten. |
|
| The reason code(s) explaining the reason for rewriting. The exact meaning of the codes is release dependent. |
Thepg_event_trigger_table_rewrite_oid
function can be used in an event trigger like this:
Last updated