按 PostgreSQL 版本定义
pg_event_trigger (PostgreSQL 17)
Table "pg_catalog.pg_event_trigger" Column | Type | Collation | Nullable | Default ------------+--------+-----------+----------+--------- oid | oid | | not null | evtname | name | | not null | evtevent | name | | not null | evtowner | oid | | not null | evtfoid | oid | | not null | evtenabled | "char" | | not null | evttags | text[] | C | | Indexes: "pg_event_trigger_oid_index" PRIMARY KEY, btree (oid) "pg_event_trigger_evtname_index" UNIQUE CONSTRAINT, btree (evtname)
文档: pg_event_trigger
pg_event_trigger (PostgreSQL 16)
Table "pg_catalog.pg_event_trigger" Column | Type | Collation | Nullable | Default ------------+--------+-----------+----------+--------- oid | oid | | not null | evtname | name | | not null | evtevent | name | | not null | evtowner | oid | | not null | evtfoid | oid | | not null | evtenabled | "char" | | not null | evttags | text[] | C | | Indexes: "pg_event_trigger_oid_index" PRIMARY KEY, btree (oid) "pg_event_trigger_evtname_index" UNIQUE CONSTRAINT, btree (evtname)
文档: pg_event_trigger
pg_event_trigger (PostgreSQL 15)
Table "pg_catalog.pg_event_trigger" Column | Type | Collation | Nullable | Default ------------+--------+-----------+----------+--------- oid | oid | | not null | evtname | name | | not null | evtevent | name | | not null | evtowner | oid | | not null | evtfoid | oid | | not null | evtenabled | "char" | | not null | evttags | text[] | C | | Indexes: "pg_event_trigger_oid_index" PRIMARY KEY, btree (oid) "pg_event_trigger_evtname_index" UNIQUE CONSTRAINT, btree (evtname)
文档: pg_event_trigger
pg_event_trigger (PostgreSQL 14)
Table "pg_catalog.pg_event_trigger" Column | Type | Collation | Nullable | Default ------------+--------+-----------+----------+--------- oid | oid | | not null | evtname | name | | not null | evtevent | name | | not null | evtowner | oid | | not null | evtfoid | oid | | not null | evtenabled | "char" | | not null | evttags | text[] | C | | Indexes: "pg_event_trigger_oid_index" PRIMARY KEY, btree (oid) "pg_event_trigger_evtname_index" UNIQUE CONSTRAINT, btree (evtname)
文档: pg_event_trigger
pg_event_trigger (PostgreSQL 13)
Table "pg_catalog.pg_event_trigger" Column | Type | Collation | Nullable | Default ------------+--------+-----------+----------+--------- oid | oid | | not null | evtname | name | | not null | evtevent | name | | not null | evtowner | oid | | not null | evtfoid | oid | | not null | evtenabled | "char" | | not null | evttags | text[] | C | | Indexes: "pg_event_trigger_evtname_index" UNIQUE, btree (evtname) "pg_event_trigger_oid_index" UNIQUE, btree (oid)
文档: pg_event_trigger
pg_event_trigger (PostgreSQL 12)
Table "pg_catalog.pg_event_trigger" Column | Type | Collation | Nullable | Default ------------+--------+-----------+----------+--------- oid | oid | | not null | evtname | name | | not null | evtevent | name | | not null | evtowner | oid | | not null | evtfoid | oid | | not null | evtenabled | "char" | | not null | evttags | text[] | C | | Indexes: "pg_event_trigger_evtname_index" UNIQUE, btree (evtname) "pg_event_trigger_oid_index" UNIQUE, btree (oid)
文档: pg_event_trigger
pg_event_trigger (PostgreSQL 11)
Table "pg_catalog.pg_event_trigger" Column | Type | Collation | Nullable | Default ------------+--------+-----------+----------+--------- evtname | name | | not null | evtevent | name | | not null | evtowner | oid | | not null | evtfoid | oid | | not null | evtenabled | "char" | | not null | evttags | text[] | | | Indexes: "pg_event_trigger_evtname_index" UNIQUE, btree (evtname) "pg_event_trigger_oid_index" UNIQUE, btree (oid)
文档: pg_event_trigger
pg_event_trigger (PostgreSQL 10)
Table "pg_catalog.pg_event_trigger" Column | Type | Collation | Nullable | Default ------------+--------+-----------+----------+--------- evtname | name | | not null | evtevent | name | | not null | evtowner | oid | | not null | evtfoid | oid | | not null | evtenabled | "char" | | not null | evttags | text[] | | | Indexes: "pg_event_trigger_evtname_index" UNIQUE, btree (evtname) "pg_event_trigger_oid_index" UNIQUE, btree (oid)
文档: pg_event_trigger
pg_event_trigger (PostgreSQL 9.6)
Table "pg_catalog.pg_event_trigger" Column | Type | Modifiers ------------+--------+----------- evtname | name | not null evtevent | name | not null evtowner | oid | not null evtfoid | oid | not null evtenabled | "char" | not null evttags | text[] | Indexes: "pg_event_trigger_evtname_index" UNIQUE, btree (evtname) "pg_event_trigger_oid_index" UNIQUE, btree (oid)
文档: pg_event_trigger
pg_event_trigger (PostgreSQL 9.5)
Table "pg_catalog.pg_event_trigger" Column | Type | Modifiers ------------+--------+----------- evtname | name | not null evtevent | name | not null evtowner | oid | not null evtfoid | oid | not null evtenabled | "char" | not null evttags | text[] | Indexes: "pg_event_trigger_evtname_index" UNIQUE, btree (evtname) "pg_event_trigger_oid_index" UNIQUE, btree (oid)
文档: pg_event_trigger
pg_event_trigger (PostgreSQL 9.4)
Table "pg_catalog.pg_event_trigger" Column | Type | Modifiers ------------+--------+----------- evtname | name | not null evtevent | name | not null evtowner | oid | not null evtfoid | oid | not null evtenabled | "char" | not null evttags | text[] | Indexes: "pg_event_trigger_evtname_index" UNIQUE, btree (evtname) "pg_event_trigger_oid_index" UNIQUE, btree (oid)
文档: pg_event_trigger
pg_event_trigger (PostgreSQL 9.3)
Table "pg_catalog.pg_event_trigger" Column | Type | Modifiers ------------+--------+----------- evtname | name | not null evtevent | name | not null evtowner | oid | not null evtfoid | oid | not null evtenabled | "char" | not null evttags | text[] | Indexes: "pg_event_trigger_evtname_index" UNIQUE, btree (evtname) "pg_event_trigger_oid_index" UNIQUE, btree (oid)
文档: pg_event_trigger
更改历史记录
自PostgreSQL 9.3中添加以来,此表没有被修改过。
- PostgreSQL 9.3
- 添加 (提交 3855968f)
示例
使用以下(人为设计的)示例,它创建了一个事件触发器,以防止任何名为foo
的对象被删除
CREATE OR REPLACE FUNCTION do_not_drop_foo() RETURNS event_trigger LANGUAGE plpgsql AS $$ BEGIN PERFORM * FROM pg_catalog.pg_event_trigger_dropped_objects() WHERE object_name = 'foo'; IF FOUND THEN RAISE EXCEPTION 'objects named ''foo'' may not be dropped'; END IF; END; $$; CREATE EVENT TRIGGER prevent_foo_drop ON sql_drop EXECUTE FUNCTION do_not_drop_foo();
pg_event_trigger
填充如下
postgres=# SELECT * FROM pg_event_trigger ; oid | evtname | evtevent | evtowner | evtfoid | evtenabled | evttags -------+------------------+----------+----------+---------+------------+--------- 16463 | prevent_foo_drop | sql_drop | 10 | 16455 | O | (1 row) postgres=# \dy List of event triggers Name | Event | Owner | Enabled | Function | Tags ------------------+----------+----------+---------+-----------------+------ prevent_foo_drop | sql_drop | postgres | enabled | do_not_drop_foo | (1 row)
参考文献
- PostgreSQL 文档: pg_event_trigger