I\'m trying to work with current_setting()
.
I came up with this:
CREATE OR REPLACE FUNCTION process_audit() RETURNS TRIGGER AS $audit$
D
PostgreSQL (9.6+) supports current_setting('setting_name', 't')
to fetch a setting and return NULL
if it's unset. you can combine this with coalesce
to supply a default.
Per the question, you can do it with a plpgsql
function that uses a BEGIN ... EXCEPTION
handler, if you don't mind the performance hit and clumsiness. But there's no built-in support.