pgaudit.git / summary / log / commit / refs
commit 84ebffcdde355eb98a360fbfa08933affd43f826
Author: David Steele <david@pgmasters.net>
Commit: GitHub <noreply@github.com>
Date: Wed Jul 23 14:03:17 2025 +0000
PostgreSQL 18 support.
Update the ExecutorRun hook signature and add the PG_MODULE_MAGIC_EXT() to set the extension name and version.
Reviewed by David Christensen (@pgguru).
Makefile | 2 +-
README.md | 16 +++++++++-------
expected/pgaudit.out | 8 +++++---
pgaudit--18.0.sql | 0
pgaudit.c | 8 ++++----
pgaudit.control | 2 +-
sql/pgaudit.sql | 2 +-
test/Dockerfile.debian | 4 ++--
test/Dockerfile.rhel | 5 ++++-
9 files changed, 27 insertions(+), 20 deletions(-)
diff --git a/Makefile b/Makefile
index da64ada..c0e162f 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@ MODULE_big = pgaudit
OBJS = pgaudit.o $(WIN32RES)
EXTENSION = pgaudit
-DATA = pgaudit--17.0.sql
+DATA = pgaudit--18.0.sql
PGFILEDESC = "pgAudit - An audit logging extension for PostgreSQL"
REGRESS = pgaudit
diff --git a/README.md b/README.md
index 75582a9..b315217 100644
--- a/README.md
+++ b/README.md
@@ -50,12 +50,14 @@ To limit the number of relations audit logged for `SELECT` and `DML` statements,
pgAudit supports PostgreSQL 13 or greater.
-In order to support new functionality introduced in each PostgreSQL release, pgAudit maintains a separate branch for each PostgreSQL major version (currently PostgreSQL 13 - 17) which will be maintained in a manner similar to the PostgreSQL project.
+In order to support new functionality introduced in each PostgreSQL release, pgAudit maintains a separate branch for each PostgreSQL major version (currently PostgreSQL 13 - 18) which will be maintained in a manner similar to the PostgreSQL project.
Aside from bug fixes, no further development is allowed for stable branches. New development, if any, will be strictly for the next unreleased major version of PostgreSQL.
pgAudit versions relate to PostgreSQL major versions as follows:
+- **pgAudit v18.X** is intended to support PostgreSQL 18.
+
- **pgAudit v17.X** is intended to support PostgreSQL 17.
- **pgAudit v16.X** is intended to support PostgreSQL 16.
@@ -78,13 +80,13 @@ Change to pgAudit directory:
```
cd pgaudit
```
-Checkout `REL_17_STABLE` branch (note that the stable branch may not exist for unreleased versions of PostgreSQL):
+Checkout `REL_18_STABLE` branch (note that the stable branch may not exist for unreleased versions of PostgreSQL):
```
-git checkout REL_17_STABLE
+git checkout REL_18_STABLE
```
Build and install pgAudit:
```
-make install USE_PGXS=1 PG_CONFIG=/usr/pgsql-17/bin/pg_config
+make install USE_PGXS=1 PG_CONFIG=/usr/pgsql-18/bin/pg_config
```
Instructions for testing and development may be found in `test`.
@@ -94,7 +96,7 @@ Settings may be modified only by a superuser. Allowing normal users to change th
Settings can be specified globally (in `postgresql.conf` or using `ALTER SYSTEM ... SET`), at the database level (using `ALTER DATABASE ... SET`), or at the role level (using `ALTER ROLE ... SET`). Note that settings are not inherited through normal role inheritance and `SET ROLE` will not alter a user's pgAudit settings. This is a limitation of the roles system and not inherent to pgAudit.
-The pgAudit extension must be loaded in [shared_preload_libraries](http://www.postgresql.org/docs/17/runtime-config-client.html#GUC-SHARED-PRELOAD-LIBRARIES). Otherwise, an error will be raised at load time and no audit logging will occur.
+The pgAudit extension must be loaded in [shared_preload_libraries](http://www.postgresql.org/docs/18/runtime-config-client.html#GUC-SHARED-PRELOAD-LIBRARIES). Otherwise, an error will be raised at load time and no audit logging will occur.
In addition, `CREATE EXTENSION pgaudit` must be called before `pgaudit.log` is set to ensure proper pgaudit functionality. The extension installs event triggers which add additional auditing for DDL. pgAudit will work without the extension installed but DDL statements will not have information about the object type and name.
@@ -140,7 +142,7 @@ The default is `off`.
### pgaudit.log_level
-Specifies the log level that will be used for log entries (see [Message Severity Levels](http://www.postgresql.org/docs/17/runtime-config-logging.html#RUNTIME-CONFIG-SEVERITY-LEVELS) for valid levels) but note that `ERROR`, `FATAL`, and `PANIC` are not allowed). This setting is used for regression testing and may also be useful to end users for testing or other purposes.
+Specifies the log level that will be used for log entries (see [Message Severity Levels](http://www.postgresql.org/docs/18/runtime-config-logging.html#RUNTIME-CONFIG-SEVERITY-LEVELS) for valid levels) but note that `ERROR`, `FATAL`, and `PANIC` are not allowed). This setting is used for regression testing and may also be useful to end users for testing or other purposes.
Note that `pgaudit.log_level` is only enabled when `pgaudit.log_client` is `on`; otherwise the default will be used.
@@ -353,7 +355,7 @@ Audit entries are written to the standard logging facility and contain the follo
- **PARAMETER** - If `pgaudit.log_parameter` is set then this field will contain the statement parameters as quoted CSV or `<none>` if there are no parameters. Otherwise, the field is `<not logged>`.
-Use [log_line_prefix](http://www.postgresql.org/docs/17/runtime-config-logging.html#GUC-LOG-LINE-PREFIX) to add any other fields that are needed to satisfy your audit log requirements. A typical log line prefix might be `'%m %u %d [%p]: '` which would provide the date/time, user name, database name, and process id for each audit log.
+Use [log_line_prefix](http://www.postgresql.org/docs/18/runtime-config-logging.html#GUC-LOG-LINE-PREFIX) to add any other fields that are needed to satisfy your audit log requirements. A typical log line prefix might be `'%m %u %d [%p]: '` which would provide the date/time, user name, database name, and process id for each audit log.
## Caveats
diff --git a/expected/pgaudit.out b/expected/pgaudit.out
index a14b1ad..be6f652 100644
--- a/expected/pgaudit.out
+++ b/expected/pgaudit.out
@@ -56,6 +56,7 @@ NOTICE: AUDIT: SESSION,5,1,ROLE,ALTER ROLE,,,ALTER ROLE regress_user1 PassWord
ALTER USER regress_user1 encrypted /* random comment */PASSWORD
/* random comment */
'md565cb1da342495ea6bb0418a6e5718c38' LOGIN;
+WARNING: setting an MD5-encrypted password
NOTICE: AUDIT: SESSION,6,1,ROLE,ALTER ROLE,,,ALTER USER regress_user1 encrypted /* random comment */PASSWORD <REDACTED>,<not logged>
ALTER ROLE regress_user1 SET pgaudit.log_client = ON;
NOTICE: AUDIT: SESSION,7,1,ROLE,ALTER ROLE,,,ALTER ROLE regress_user1 SET pgaudit.log_client = ON,<not logged>
@@ -991,6 +992,7 @@ NOTICE: AUDIT: SESSION,41,1,DDL,ALTER TABLE,TABLE,test.test2,"ALTER TABLE test.
DROP COLUMN description",<none>
DROP TABLE test.test2;
NOTICE: AUDIT: SESSION,42,1,DDL,DROP TABLE,TABLE,test.test2,DROP TABLE test.test2,<none>
+NOTICE: AUDIT: SESSION,42,1,DDL,DROP TABLE,TABLE CONSTRAINT,test_id_not_null on test.test2,DROP TABLE test.test2,<none>
NOTICE: AUDIT: SESSION,42,1,DDL,DROP TABLE,TABLE CONSTRAINT,test_pkey on test.test2,DROP TABLE test.test2,<none>
NOTICE: AUDIT: SESSION,42,1,DDL,DROP TABLE,INDEX,test.test_pkey,DROP TABLE test.test2,<none>
--
@@ -2547,9 +2549,9 @@ SET pgaudit.log = 'all,-misc_set';
SET pgaudit.log_level = 'warning';
CREATE EXTENSION pg_stat_statements;
WARNING: AUDIT: SESSION,3,1,DDL,CREATE EXTENSION,,,CREATE EXTENSION pg_stat_statements,<not logged>
-ALTER EXTENSION pg_stat_statements UPDATE TO '1.11';
-WARNING: AUDIT: SESSION,4,1,DDL,ALTER EXTENSION,,,ALTER EXTENSION pg_stat_statements UPDATE TO '1.11',<not logged>
-NOTICE: version "1.11" of extension "pg_stat_statements" is already installed
+ALTER EXTENSION pg_stat_statements UPDATE TO '1.12';
+WARNING: AUDIT: SESSION,4,1,DDL,ALTER EXTENSION,,,ALTER EXTENSION pg_stat_statements UPDATE TO '1.12',<not logged>
+NOTICE: version "1.12" of extension "pg_stat_statements" is already installed
DROP EXTENSION pg_stat_statements;
WARNING: AUDIT: SESSION,5,1,DDL,DROP EXTENSION,,,DROP EXTENSION pg_stat_statements,<not logged>
SET pgaudit.log_level = 'notice';
diff --git a/pgaudit--17.0.sql b/pgaudit--18.0.sql
similarity index 100%
rename from pgaudit--17.0.sql
rename to pgaudit--18.0.sql
diff --git a/pgaudit.c b/pgaudit.c
index 87cd761..a6ee0aa 100644
--- a/pgaudit.c
+++ b/pgaudit.c
@@ -42,7 +42,7 @@
#include "utils/timestamp.h"
#include "utils/varlena.h"
-PG_MODULE_MAGIC;
+PG_MODULE_MAGIC_EXT(.name = "pgaudit", .version = "18.0");
void _PG_init(void);
@@ -1553,15 +1553,15 @@ pgaudit_ExecutorCheckPerms_hook(List *rangeTabls,
* Hook ExecutorRun to get rows processed by the current statement.
*/
static void
-pgaudit_ExecutorRun_hook(QueryDesc *queryDesc, ScanDirection direction, uint64 count, bool execute_once)
+pgaudit_ExecutorRun_hook(QueryDesc *queryDesc, ScanDirection direction, uint64 count)
{
AuditEventStackItem *stackItem = NULL;
/* Call the previous hook or standard function */
if (next_ExecutorRun_hook)
- next_ExecutorRun_hook(queryDesc, direction, count, execute_once);
+ next_ExecutorRun_hook(queryDesc, direction, count);
else
- standard_ExecutorRun(queryDesc, direction, count, execute_once);
+ standard_ExecutorRun(queryDesc, direction, count);
if (auditLogRows && !internalStatement && !IsParallelWorker())
{
diff --git a/pgaudit.control b/pgaudit.control
index 97623c8..f5aa011 100644
--- a/pgaudit.control
+++ b/pgaudit.control
@@ -1,5 +1,5 @@
# pgaudit extension
comment = 'provides auditing functionality'
-default_version = '17.0'
+default_version = '18.0'
module_pathname = '$libdir/pgaudit'
relocatable = true
diff --git a/sql/pgaudit.sql b/sql/pgaudit.sql
index 0b8943e..b741170 100644
--- a/sql/pgaudit.sql
+++ b/sql/pgaudit.sql
@@ -1621,7 +1621,7 @@ SET pgaudit.log = 'all,-misc_set';
SET pgaudit.log_level = 'warning';
CREATE EXTENSION pg_stat_statements;
-ALTER EXTENSION pg_stat_statements UPDATE TO '1.11';
+ALTER EXTENSION pg_stat_statements UPDATE TO '1.12';
DROP EXTENSION pg_stat_statements;
SET pgaudit.log_level = 'notice';
diff --git a/test/Dockerfile.debian b/test/Dockerfile.debian
index 46e37af..aaa8bb4 100644
--- a/test/Dockerfile.debian
+++ b/test/Dockerfile.debian
@@ -17,14 +17,14 @@ RUN useradd -m -u $UID -g $GID -o -s /bin/bash postgres
# Add PostgreSQL repository
RUN RELEASE_CODENAME=`lsb_release -c | awk '{print $2}'` && \
- echo 'deb http://apt.postgresql.org/pub/repos/apt/ '${RELEASE_CODENAME?}'-pgdg main' | \
+ echo 'deb http://apt.postgresql.org/pub/repos/apt/ '${RELEASE_CODENAME?}'-pgdg main 18' | \
tee -a /etc/apt/sources.list.d/pgdg.list
RUN APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 && \
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
RUN apt-get update
# Install PostgreSQL
-ENV PGVERSION=17
+ENV PGVERSION=18
RUN apt-get install -y postgresql-${PGVERSION?} postgresql-server-dev-${PGVERSION?}
diff --git a/test/Dockerfile.rhel b/test/Dockerfile.rhel
index 9540579..5dfc494 100644
--- a/test/Dockerfile.rhel
+++ b/test/Dockerfile.rhel
@@ -20,8 +20,11 @@ RUN dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-`
# Disable PostgreSQL in default repository
RUN dnf -qy module disable postgresql
+# Enable PG18 repo (can be removed after the official release)
+RUN dnf config-manager --set-enabled pgdg18-updates-testing
+
# Install PostgreSQL
-ENV PGVERSION=17
+ENV PGVERSION=18
RUN dnf install -y postgresql${PGVERSION?}-server postgresql${PGVERSION?}-devel postgresql${PGVERSION?}-contrib
[parent: 135b63528dec]