Goal: compare built-in DDL logging with a real pgAudit read record.
Think of DDL logging as recording cabinet installation/removal, while READ auditing records opening it. Connect as postgres to database postgres (-U role, -d database); expect postgres=#. The fixture uses only the invented text DEMO-SSN. This experiment tests statement evidence, not production compliance retention or pgAudit object auditing.
Goal: inspect extensions installed in this database.
pg_extension lists database extension objects; expect plpgsql 1.0 initially. That does not imply only one library is loaded in the server: startup preloading and CREATE EXTENSION are different layers. Ordering by name makes the inventory stable.
Goal: separate available installation files from database installation.
First count the server’s 46 available extension definitions, then inspect pgaudit’s default_version and installed_version. Expect pgaudit version 19.0 with a blank installed_version before installation. The count is one summary value, not the number of displayed rows. A blank here means the extension is not installed in this database.
Goal: install the supplied extension objects.
CREATE EXTENSION pgaudit should succeed because both its files and startup preloading are already supplied. Expect CREATE EXTENSION. It installs objects in this database, not all four datasets at once. Missing files or missing preloading are reference failure cases, not expected failures on this image.
Goal: confirm the startup prerequisites without changing them.
Read shared_preload_libraries and context: expect pg_stat_statements,pgaudit and postmaster. That context means list changes require restart; we do not replace the list or restart here. A reload acknowledgement alone cannot prove a new startup library was loaded.
Goal: apply DDL-only built-in logging and verify the active value.
ALTER SYSTEM writes log_statement = ddl; reload and the short sleep allow it to apply. Expect SHOW to return ddl. DDL means structural commands such as CREATE and DROP; our SELECT will not receive a built-in statement entry under this setting. Other independently configured logging could still capture reads.
Goal: run one controlled create/write/read/drop sequence.
Create sensitive_table, insert the fictitious marker, read it in ID order, then drop it. Expect CREATE TABLE, INSERT 0 1, the row 1 | DEMO-SSN, and DROP TABLE. The INSERT supplies data so a successful read is concrete. serial generates its ID. No real personal data is used.
Goal: prove which statements were and were not recorded by built-in DDL logging.
pg_current_logfile() must name log/postgresql.log; the path is relative to the data directory. After a short wait, \! as-postgres grep reads that collector file. Expect CREATE and DROP statement entries for sensitive_table. grep -q checks silently; the shell if/else prints NO_BUILTIN_READ only when the exact SELECT statement entry is absent. A different marker means the negative test failed.
Goal: capture the same read with pgAudit session READ logging.
SET pgaudit.log = read affects this SQL client. Recreate the table and marker, read it, wait for the collector, and search for AUDIT plus READ/SELECT and sensitive_table. Expect the returned demo row and an AUDIT record for its SELECT, then DROP TABLE. A log statement is not a copy of the returned SSN values. This is session auditing; object audit roles are reference-only.
Goal: finish with the original logging thresholds and no demo table.
RESET pgaudit.log removes this session’s override; ALTER SYSTEM RESET log_statement removes the persistent file entry. Reload and wait, then expect statement_logging = none and audit_classes = none. The extension remains installed, but this session’s READ auditing is off. The fixture table must already be gone.