From 0739decfa935a67e2b2ca7394ef03fc940bbf676 Mon Sep 17 00:00:00 2001 From: archaeogeek Date: Fri, 15 Jun 2018 11:49:46 +0100 Subject: [PATCH 1/2] Added a statement to create a view showing all tables (and schemas) for which auditing has been set up --- audit.sql | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/audit.sql b/audit.sql index 6c19498..c0db93c 100644 --- a/audit.sql +++ b/audit.sql @@ -239,3 +239,14 @@ $body$ LANGUAGE 'sql'; COMMENT ON FUNCTION audit.audit_table(regclass) IS $body$ Add auditing support to the given table. Row-level changes will be logged with full client query text. No cols are ignored. $body$; + +CREATE OR REPLACE VIEW audit.tableslist AS + SELECT DISTINCT triggers.trigger_schema AS schema, + triggers.event_object_table AS auditedtable + FROM information_schema.triggers + WHERE triggers.trigger_name::text = 'audit_trigger_row'::text + ORDER BY schema, auditedtable; + +COMMENT ON VIEW audit.tableslist IS $body$ +View showing all tables with auditing set up. Ordered by schema, then table. +$body$; From a79d1b214dd30394e839639044c8d74dcecf5ad6 Mon Sep 17 00:00:00 2001 From: archaeogeek Date: Thu, 6 Sep 2018 17:06:31 +0100 Subject: [PATCH 2/2] Added option for showing tables with statement-level triggers --- audit.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/audit.sql b/audit.sql index c0db93c..d4b122c 100644 --- a/audit.sql +++ b/audit.sql @@ -244,8 +244,8 @@ CREATE OR REPLACE VIEW audit.tableslist AS SELECT DISTINCT triggers.trigger_schema AS schema, triggers.event_object_table AS auditedtable FROM information_schema.triggers - WHERE triggers.trigger_name::text = 'audit_trigger_row'::text - ORDER BY schema, auditedtable; + WHERE triggers.trigger_name::text IN ('audit_trigger_row'::text, 'audit_trigger_stm'::text) +ORDER BY schema, auditedtable; COMMENT ON VIEW audit.tableslist IS $body$ View showing all tables with auditing set up. Ordered by schema, then table.