Catalogs and logs
Overview
Catalogs describe database objects; activity views expose runtime state and statistics; logs record selected events. PostgreSQL information_schema provides standardized metadata views while pg_catalog exposes engine-specific details. Access depends on privileges. Logs should minimize sensitive values and have controlled retention.
First example
SELECT name,type FROM pragma_table_info('ad_account') ORDER BY cid;Observed SQLite result (rows in JSON):
[ [ "id", "INTEGER" ], [ "balance", "INTEGER" ]]How it works
SQLite sqlite_schema contains object definitions; pragma_table_info exposes columns. ad_log is synthetic application data, not a server log. Correlate errors with timestamps, request IDs and workload context in real systems; absence of a logged error does not prove success.
Practical example
SELECT id,level FROM ad_log WHERE level<>'INFO' ORDER BY id;Observed SQLite result (rows in JSON):
[ [ 2, "WARN" ], [ 3, "ERROR" ]]Practice and mistakes
Practice: list account columns and non-INFO events. Hint: inspect pragma_table_info and filter level. Check: id, balance; WARN and ERROR. Mistake: treating catalog data as a historical audit trail.
PostgreSQL 17 example — NOT RUN
SELECT table_schema,table_name FROM information_schema.tables WHERE table_schema NOT IN ('pg_catalog','information_schema') ORDER BY 1,2;Expected result, not executed: "Visible objects depend on privileges."