赞
踩
9.29 事件触发器函数
PostgreSQL提供用以从事件触发器中获取信息的函数。
9.29.1. Capturing Changes at Command End
9.29.1 在命令结束时获取变化
pg_event_trigger_ddl_commands () → setof record
pg_event_trigger_ddl_commands返回由用户调用附加了ddl_command_end事件触发器的函数时执行的DDL命令列表。它返回如下列:
9.29.2. Processing Objects Dropped by a DDL Command
9.29.2 处理使用DDL命令删掉的对象
pg_event_trigger_dropped_objects () → setof record
pg_event_trigger_dropped_objects返回调用了sql_drop事件删除的数据库对象列表。其返回如下列:
示例:
- 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 FUNCTION test_event_trigger_for_drops();

9.29.3. Handling a Table Rewrite Event
9.29.3 表重写事件处理
表9.98提供的函数,用以返回调用table_rewrite事件的相关信息。
示例:
- CREATE FUNCTION test_event_trigger_table_rewrite_oid()
- RETURNS event_trigger
- LANGUAGE plpgsql AS
- $$
- BEGIN
- RAISE NOTICE 'rewriting table % for reason %',
- pg_event_trigger_table_rewrite_oid()::regclass,
- pg_event_trigger_table_rewrite_reason();
- END;
- $$;
- CREATE EVENT TRIGGER test_table_rewrite_oid
- ON table_rewrite
- EXECUTE FUNCTION test_event_trigger_table_rewrite_oid();
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。