I'm implementing a database with a few triggers that registers changes to specific tables into a couterpart tables in a named "audit" schema.
This is, as it sounds, to be able to audit changes made to the data.
It works pretty well. But, of course, I need to grant insert privileges to the user used to connect to the database from the application because, otherwise, that triggers will fail on inserting rows in the audit schema.
I think the answer is "no", but anyway I would ask for if I'm wrong: Is there any way to permit a PostgreSQL trigger function to be executed as distinct user (for example function's owner) making it able to perform operations (such as that inserts) that are not permitted to users who performed the operation that triggered them?
Thanks.