Re: Event Triggers: adding information

From: Dimitri Fontaine <dimitri(at)2ndQuadrant(dot)fr>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Event Triggers: adding information
Date: 2012-12-12 21:47:23
Message-ID: m2zk1j9c44.fsf@2ndQuadrant.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi again,

The previously attached patch already needs a rebase since Tom fixed the
single user mode where you're not supposed to access potentially
corrupted system indexes. Please find attached a new version of the
patch that should applies cleanly to master (I came to trust git).

Dimitri Fontaine <dimitri(at)2ndQuadrant(dot)fr> writes:
> The current patch provides the following features:
>
> - New events: ddl_command_end and ddl_command_trace
>
> - New information in the TG_VARIABLE:
> object name, schema name, object id, object kind,
> operation (CREATE|ALTER|DROP), context (GENERATED|TOPLEVEL|…)
> normalized command string
>
> - New event filtering on CONTEXT (see after sig for an example)
>
> + create event trigger regress_event_trigger_end on ddl_command_end
> + when context in ('toplevel', 'generated', 'query', 'subcommand')
> + execute procedure test_event_trigger();
>
> - Documentation of listed features
>
> - pg_dump support of the new features (context support)

Still the same, plus some more command rewriting support so that I have
some more data points to offer about the code maintainance burden we all
want to limit on that feature.

> For example, I added CREATE SCHEMA objectid and command normalisation
> and here's the footprint:
> 4 files changed, 38 insertions(+), 5 deletions(-)
>
> For the whole DefineStmt command set (CREATE AGGREGATE, OPERATOR, TYPE,
> TEXT SEARCH *, COLLATION), we're talking about:
> 11 files changed, 186 insertions(+), 70 deletions(-)
> 95 lines of those in ddl_rewrite.c
>
> For the normalisation of CREATE CONVERSATION command string, this time
> 4 files changed, 40 insertions(+), 5 deletions(-)
>
> And CREATE DOMAIN, which is more involved as you need to take care of
> rewriting DEFAULT and CHECK constraints, we have
> 4 files changed, 163 insertions(+), 3 deletions(-)

The whole set of RenameStmt commands:
32 files changed, 382 insertions(+), 119 deletions(-)

Then after that, sharing a lot of the previous code, support for both
AlterOwnerStmt and AlterObjectSchemaStmt rewriting:
1 file changed, 102 insertions(+), 17 deletions(-)

As you can guess I separated away the EventTriggerTargetOid tracking:
20 files changed, 96 insertions(+), 57 deletions(-)

Again, those data point are not commented here, it's only to get some
better idea of what we are talking about as the cost of maintaining the
new command normalisation feature that's brewing in this patch.

I would like that we commit to that idea and the current implementation
of it, and include the set of commands I already had time to prepare in
the current submission, knowing that I will continue adding commands
support up to the next commitfest with the goal to have a full coverage.

I also will be working on more features (complete PL support, some kind
of command diverting, a "table_rewrite" event, some ready to use event
triggers functions).

Regards,
--
Dimitri Fontaine
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support

Attachment Content-Type Size
event_trigger_infos.4.patch.gz application/octet-stream 48.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mikko Tiihonen 2012-12-12 22:11:09 Use gcc built-in atomic inc/dec in lock.c
Previous Message Tom Lane 2012-12-12 21:32:33 Re: encouraging index-only scans