2ndQuadrant / audit-trigger

Simple, easily customised trigger-based auditing for PostgreSQL (Postgres). See also pgaudit.
Other
659 stars 241 forks source link

Adding trigger to user table #18

Open joelbarnard opened 9 years ago

joelbarnard commented 9 years ago

Our schema has a "user" table, user is also a reserved word in Postgres. When trying to enable auditing on this table, it throws an error.

I've tried every vairation of ', and " I can think of, including prefixing the schema.

Any ideas?

SELECT audit.audit_table('user');

NOTICE:  relation ""user"" does not exist, skipping
CONTEXT:  SQL statement "DROP TRIGGER IF EXISTS audit_trigger_row ON """user""""
PL/pgSQL function audit.audit_table(regclass,boolean,boolean,text[]) line 7 at EXECUTE statement
NOTICE:  relation ""user"" does not exist, skipping
CONTEXT:  SQL statement "DROP TRIGGER IF EXISTS audit_trigger_stm ON """user""""
PL/pgSQL function audit.audit_table(regclass,boolean,boolean,text[]) line 8 at EXECUTE statement
NOTICE:  CREATE TRIGGER audit_trigger_row AFTER INSERT OR UPDATE OR DELETE ON """user""" FOR EACH ROW EXECUTE PROCEDURE audit.if_modified_func('true');
ERROR:  relation ""user"" does not exist
CONTEXT:  SQL statement "CREATE TRIGGER audit_trigger_row AFTER INSERT OR UPDATE    OR DELETE ON """user""" FOR EACH ROW EXECUTE PROCEDURE audit.if_modified_func('true');"
PL/pgSQL function audit.audit_table(regclass,boolean,boolean,text[]) line 19 at EXECUTE statement
********** Error **********

ERROR: relation ""user"" does not exist
SQL state: 42P01
Context: SQL statement "CREATE TRIGGER audit_trigger_row AFTER INSERT OR UPDATE OR DELETE ON """user""" FOR EACH ROW EXECUTE PROCEDURE audit.if_modified_func('true');"
PL/pgSQL function audit.audit_table(regclass,boolean,boolean,text[]) line 19 at EXECUTE statement
mikijov commented 8 years ago

I believe that my change in this pull request solves this problem. Pull request: https://github.com/2ndQuadrant/audit-trigger/pull/20