pgsql: Add sql_drop event for event triggers

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема pgsql: Add sql_drop event for event triggers
Дата
Msg-id E1ULFNO-0004x6-VI@gemulon.postgresql.org
обсуждение исходный текст
Ответы Re: pgsql: Add sql_drop event for event triggers  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-committers
Add sql_drop event for event triggers

This event takes place just before ddl_command_end, and is fired if and
only if at least one object has been dropped by the command.  (For
instance, DROP TABLE IF EXISTS of a table that does not in fact exist
will not lead to such a trigger firing).  Commands that drop multiple
objects (such as DROP SCHEMA or DROP OWNED BY) will cause a single event
to fire.  Some firings might be surprising, such as
ALTER TABLE DROP COLUMN.

The trigger is fired after the drop has taken place, because that has
been deemed the safest design, to avoid exposing possibly-inconsistent
internal state (system catalogs as well as current transaction) to the
user function code.  This means that careful tracking of object
identification is required during the object removal phase.

Like other currently existing events, there is support for tag
filtering.

To support the new event, add a new pg_event_trigger_dropped_objects()
set-returning function, which returns a set of rows comprising the
objects affected by the command.  This is to be used within the user
function code, and is mostly modelled after the recently introduced
pg_identify_object() function.

Catalog version bumped due to the new function.

Dimitri Fontaine and Álvaro Herrera
Review by Robert Haas, Tom Lane

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/473ab40c8bb3fcb1a7645f6a7443a0424d70fbaf

Modified Files
--------------
doc/src/sgml/event-trigger.sgml             |  110 ++++++-
doc/src/sgml/func.sgml                      |  113 ++++++
src/backend/catalog/dependency.c            |   65 +++-
src/backend/commands/event_trigger.c        |  518 +++++++++++++++++++++++----
src/backend/parser/gram.y                   |    1 -
src/backend/tcop/utility.c                  |   64 +++-
src/backend/utils/adt/regproc.c             |    2 +-
src/backend/utils/cache/evtcache.c          |    2 +
src/include/catalog/catversion.h            |    2 +-
src/include/catalog/pg_proc.h               |    3 +
src/include/commands/event_trigger.h        |    9 +-
src/include/utils/builtins.h                |    3 +
src/include/utils/evtcache.h                |    3 +-
src/test/regress/expected/event_trigger.out |  197 ++++++++++-
src/test/regress/sql/event_trigger.sql      |  106 ++++++-
15 files changed, 1083 insertions(+), 115 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Simon Riggs
Дата:
Сообщение: pgsql: Revoke 7a5a59d378e052618d6feae64d1d2b4f2ad6f9bc
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Avoid "variable might be clobbered by longjmp" warning.