Skip to content

Instantly share code, notes, and snippets.

@pramsey
Created January 31, 2022 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pramsey/4c65bc65b753efed52955be6bd60e507 to your computer and use it in GitHub Desktop.
Save pramsey/4c65bc65b753efed52955be6bd60e507 to your computer and use it in GitHub Desktop.
PostGIS + PgAudit?
DO $$
DECLARE
pgalog text;
BEGIN
SHOW pgaudit.log INTO pgalog;
IF lower(pgalog) != 'none'
THEN
RAISE DEBUG 'pgaudit.log is currently ''%''', pgalog;
EXECUTE Format('SET pgaudit.log_save TO %s', pgalog);
SET pgaudit.log = 'none';
RAISE DEBUG 'pgaudit.log set to ''none'' during postgis extension install';
END IF;
EXCEPTION WHEN OTHERS THEN
RAISE NOTICE 'pgaudit is not installed, skipping disable step';
END;
$$;
--
-- Do all the extension stuff
--
DO $$
DECLARE
pgalog text;
BEGIN
SHOW pgaudit.log_save INTO pgalog;
IF lower(pgalog) != 'none'
THEN
EXECUTE Format('SET pgaudit.log TO %s', pgalog);
RAISE DEBUG 'pgaudit.log set back to ''%'' after postgis extension install', pgalog;
END IF;
EXCEPTION WHEN OTHERS THEN
RAISE NOTICE 'pgaudit is not installed, skipping enable step';
END;
$$;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment