Best way to monitor, control, or rewrite data definition commands? - Mailing list pgsql-general

From Turner, Ian
Subject Best way to monitor, control, or rewrite data definition commands?
Date
Msg-id 8744EE476651744882371AB948473F0B159E7E@mailnyc2.nyc.deshaw.com
Whole thread Raw
Responses Re: Best way to monitor, control, or rewrite data definition commands?
Re: Best way to monitor, control, or rewrite data definition commands?
List pgsql-general
Hello list,

I am trying to implement automatic audit log tracking for newly created
tables. When a user creates a table, I would like to create a second
table for the audit log, along with the relevant rules. So for example,
if a user does

CREATE TABLE foo (fooid integer);

Then I would also like to do

CREATE TABLE foo_audit (fooid integer, <other columns>);

along with the creation of some other triggers, rules, etc.

Is there any way to be notified when a user executes data definition
commands such as CREATE TABLE? It doesn't appear possible to apply
triggers or rules to the system tables, and the query rewrite engine
only seems to apply to SELECT, INSERT, and UPDATE. Thoughts?

Cheers,

--Ian Turner

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: pg_dump/pg_restore schema and data separately and foreign key constraints
Next
From: Greg Smith
Date:
Subject: Re: Best way to monitor, control, or rewrite data definition commands?