From: Dimitri Fontaine <dimitri@2ndQuadrant.fr>
To: Robert Haas <robertmhaas@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Subject: Re: Event Triggers: adding information
Date: Sat, 29 Dec 2012 15:02:41 +0100
Message-ID: <m27go1ot1a.fsf@2ndQuadrant.fr> (raw)
In-Reply-To: <CA+TgmoZTxXGAkoyQD0aNOyju1X19SnVfk7KV9fsJCv63bS-C4g@mail.gmail.com>
References: <m2txrsdzxa.fsf@2ndQuadrant.fr>
<m2zk1j9c44.fsf@2ndQuadrant.fr>
<CA+Tgmob6kmAySE5yXvd3uE9LifHunufMg9iU3GmbJ5bpGPiHjQ@mail.gmail.com>
<m2k3sbe51z.fsf@2ndQuadrant.fr>
<CA+TgmoZjOACnHOKrz-eucj3FJXrYJzA-_yjSqajOQR8qkjCi=w@mail.gmail.com>
<m2bodi55yn.fsf@2ndQuadrant.fr>
<CA+TgmoZTxXGAkoyQD0aNOyju1X19SnVfk7KV9fsJCv63bS-C4g@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
Robert Haas <robertmhaas@gmail.com> writes:
> OK, I committed this.
Thanks. Please find attached a rebased patch, v6. I think it's looking
more like what you would expect now:
COLUMNS=70 git diff --stat postgres/master..
doc/src/sgml/event-trigger.sgml | 196 +++-
doc/src/sgml/plpgsql.sgml | 95 +-
doc/src/sgml/ref/create_event_trigger.sgml | 20 +-
src/backend/catalog/objectaddress.c | 22 +-
src/backend/commands/event_trigger.c | 870 ++++++++++++++++-
src/backend/commands/trigger.c | 39 +
src/backend/commands/typecmds.c | 2 +-
src/backend/tcop/utility.c | 385 +++++---
src/backend/utils/cache/evtcache.c | 15 +
src/bin/pg_dump/pg_dump.c | 21 +-
src/bin/pg_dump/pg_dump.h | 1 +
src/bin/psql/describe.c | 9 +-
src/include/catalog/objectaddress.h | 21 +
src/include/catalog/pg_event_trigger.h | 2 +
src/include/commands/event_trigger.h | 47 +-
src/include/commands/trigger.h | 1 +
src/include/utils/evtcache.h | 6 +-
src/pl/plpgsql/src/pl_comp.c | 48 +
src/pl/plpgsql/src/pl_exec.c | 57 +-
src/pl/plpgsql/src/plpgsql.h | 6 +
src/test/regress/expected/event_trigger.out | 53 +-
src/test/regress/sql/event_trigger.sql | 51 +-
22 files changed, 1700 insertions(+), 267 deletions(-)
>> That completes ALTER and CREATE ObjectID support, I did nothing about
>> the DROP case in the attached. The way I intend to solve that problem is
>> using get_object_address() and do an extra lookup from within the Event
>> Trigger code path.
>
> An extra lookup that occurs always, or only when event triggers are in
> use? A re-resolution of the name, or some other kind of lookup?
Only when event triggers are in use, and when the object is known to
exists in the catalogs (ddl_command_start for a DROP operation, or
ddl_command_end for a CREATE or ALTER operation). And it's only a name
resolution using the catcache when it exists, or a catalog index scan
when we have to. The key we have is the OID.
The OID is filled in from utility.c in all CREATE and ALTER operations
that we are interested into, and in the case of a DROP operation we do
either a RangeVarGetRelid for relations or get_object_address() for the
other object kinds.
Given the OID, we use the ObjectProperty[] structure to know which cache
or catalog to scan in order to get the name and namespace of the object.
Regards,
--
Dimitri Fontaine
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackersAttachments:
event_trigger_infos.6.patch.gz (application/octet-stream, 20.0K) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: dimitri@2ndQuadrant.fr, robertmhaas@gmail.com
Subject: Re: Event Triggers: adding information
In-Reply-To: <m27go1ot1a.fsf@2ndQuadrant.fr>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox