audit-trigger icon indicating copy to clipboard operation
audit-trigger copied to clipboard

Adding trigger to user table

Open joelbarnard opened this issue 9 years ago • 1 comments

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

joelbarnard avatar Oct 06 '15 18:10 joelbarnard

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

mikijov avatar Feb 20 '16 02:02 mikijov