diff --git a/expected/pgaudit.out b/expected/pgaudit.out index eea0a58..db55b89 100644 --- a/expected/pgaudit.out +++ b/expected/pgaudit.out @@ -1168,6 +1168,36 @@ DROP TABLE public.t; NOTICE: AUDIT: SESSION,86,1,DDL,DROP TABLE,,,DROP TABLE public.t;, DROP ROLE alice; NOTICE: AUDIT: SESSION,87,1,ROLE,DROP ROLE,,,DROP ROLE alice;, +-- +-- Test PARTITIONED table +CREATE TABLE h(x int ,y int) PARTITION BY HASH(x); +NOTICE: AUDIT: SESSION,88,1,DDL,CREATE TABLE,,,"CREATE TABLE h(x int ,y int) PARTITION BY HASH(x);", +CREATE TABLE h_0 partition OF h FOR VALUES WITH ( MODULUS 2, REMAINDER 0); +NOTICE: AUDIT: SESSION,89,1,DDL,CREATE TABLE,,,"CREATE TABLE h_0 partition OF h FOR VALUES WITH ( MODULUS 2, REMAINDER 0);", +CREATE TABLE h_1 partition OF h FOR VALUES WITH ( MODULUS 2, REMAINDER 1); +NOTICE: AUDIT: SESSION,90,1,DDL,CREATE TABLE,,,"CREATE TABLE h_1 partition OF h FOR VALUES WITH ( MODULUS 2, REMAINDER 1);", +INSERT INTO h VALUES(1,1); +NOTICE: AUDIT: SESSION,91,1,WRITE,INSERT,TABLE,public.h,"INSERT INTO h VALUES(1,1);", +SELECT * FROM h; +NOTICE: AUDIT: SESSION,92,1,READ,SELECT,TABLE,public.h,SELECT * FROM h;, + x | y +---+--- + 1 | 1 +(1 row) + +SELECT * FROM h_0; +NOTICE: AUDIT: SESSION,93,1,READ,SELECT,TABLE,public.h_0,SELECT * FROM h_0;, + x | y +---+--- + 1 | 1 +(1 row) + +CREATE INDEX h_idx ON h (x); +NOTICE: AUDIT: SESSION,94,1,DDL,CREATE INDEX,,,CREATE INDEX h_idx ON h (x);, +DROP INDEX h_idx; +NOTICE: AUDIT: SESSION,95,1,DDL,DROP INDEX,,,DROP INDEX h_idx;, +DROP TABLE h; +NOTICE: AUDIT: SESSION,96,1,DDL,DROP TABLE,,,DROP TABLE h;, -- Cleanup -- Set client_min_messages up to warning to avoid noise SET client_min_messages = 'warning'; diff --git a/pgaudit.c b/pgaudit.c index c1dc653..ebb9185 100644 --- a/pgaudit.c +++ b/pgaudit.c @@ -1038,10 +1038,12 @@ log_select_dml(Oid auditOid, List *rangeTabls) switch (rte->relkind) { case RELKIND_RELATION: + case RELKIND_PARTITIONED_TABLE: auditEventStack->auditEvent.objectType = OBJECT_TYPE_TABLE; break; case RELKIND_INDEX: + case RELKIND_PARTITIONED_INDEX: auditEventStack->auditEvent.objectType = OBJECT_TYPE_INDEX; break; diff --git a/sql/pgaudit.sql b/sql/pgaudit.sql index 43b0ad1..a11f4d9 100644 --- a/sql/pgaudit.sql +++ b/sql/pgaudit.sql @@ -818,6 +818,18 @@ RESET ROLE; DROP TABLE public.t; DROP ROLE alice; +-- +-- Test PARTITIONED table +CREATE TABLE h(x int ,y int) PARTITION BY HASH(x); +CREATE TABLE h_0 partition OF h FOR VALUES WITH ( MODULUS 2, REMAINDER 0); +CREATE TABLE h_1 partition OF h FOR VALUES WITH ( MODULUS 2, REMAINDER 1); +INSERT INTO h VALUES(1,1); +SELECT * FROM h; +SELECT * FROM h_0; +CREATE INDEX h_idx ON h (x); +DROP INDEX h_idx; +DROP TABLE h; + -- Cleanup -- Set client_min_messages up to warning to avoid noise SET client_min_messages = 'warning';