From: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: Add sql_drop event for event triggers |
Date: | 2013-03-28 16:08:30 |
Message-ID: | E1ULFNO-0004x6-VI@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers pgsql-hackers |
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(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2013-03-28 17:19:56 | pgsql: Avoid "variable might be clobbered by longjmp" warning. |
Previous Message | Simon Riggs | 2013-03-28 15:07:08 | Re: [COMMITTERS] pgsql: Allow external recovery_config_directory |
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2013-03-28 16:13:40 | Re: sql_drop Event Triggerg |
Previous Message | Tom Lane | 2013-03-28 15:54:59 | Re: FDW for PostgreSQL |