2ndQuadrant / audit-trigger

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

Cannot add tables with CamelCase #28

Open brentrjones opened 7 years ago

brentrjones commented 7 years ago

Have some tables named with mixed-case (was there before I inherited). I saw the other ticket about tables in all uppercase, but looks like mixed case may mix it up also

$ SELECT audit.audit_table('Account'); ERROR: 42P01: relation "account" does not exist LINE 1: SELECT audit.audit_table('Account'); ^ LOCATION: RangeVarGetRelidExtended, namespace.c:420

dadambickford commented 7 years ago

+1

michaelfiber commented 6 years ago

I was testing this script earlier with a table that has foldable characters and it looks like the use of quote_ident on a regclass parameter might be the issue. If all the quote_ident(table_name::TEXT) in the function are turned into simply table_name it works.

The documentation says that regclass will "do the right thing" with what it is given and it will give you a correct table name or throw an error if what it's given can't be found as a table.

I didn't do a pull request for it though because this is new to me and I don't know if there are any risks in accepting the value of a regclass. It looks like just using regclass is the right thing to do accordingg to documentation, but it's something I've never used in a project before so I'm not certain.