Column privileges of several types render as GRANT INSERT, UPDATE (cols), which grants INSERT on the whole table
Version: v1.13.1 (darwin/arm64), PostgreSQL 18.6 (postgres:18), default embedded plan database
Summary
When a role holds column privileges of more than one type on the same columns, dump and plan write them as one
statement, GRANT INSERT, UPDATE (a, b) ON TABLE t TO app;. PostgreSQL attaches a column list only to the privilege
right before it, so that statement grants INSERT on the whole table and UPDATE on a, b.
The effect is a privilege widening: applying a plan that narrows column grants leaves the role able to insert into
every column. The comparison itself seems right (a desired state that matches the database plans empty); the SQL
that dump and plan render is what is wrong.
Reproduction
-- target database
CREATE ROLE app;
CREATE TABLE t (id int PRIMARY KEY, a int, b int);
GRANT INSERT (a, b), UPDATE (a, b) ON t TO app;
-- desired.sql: narrow both grants to column a
CREATE TABLE t (id int PRIMARY KEY, a int, b int);
GRANT INSERT (a), UPDATE (a) ON t TO app;
-
pgschema dump --db r1 --schema publicwrites:GRANT INSERT, UPDATE (a, b) ON TABLE t TO app; -
planfrom that dump against the same, unchanged database is not empty:REVOKE INSERT (a, b) ON TABLE t FROM app; GRANT INSERT ON TABLE t TO app; -
pgschema plan --db r1 --file desired.sql --output-sql stdout:REVOKE INSERT, UPDATE (a, b) ON TABLE t FROM app; GRANT INSERT, UPDATE (a) ON TABLE t TO app; -
After
pgschema apply --db r1 --file desired.sql --auto-approve(exit 0):SELECT has_table_privilege('app', 't', 'INSERT') AS table_insert, has_column_privilege('app', 't', 'id', 'INSERT') AS id_insert, has_column_privilege('app', 't', 'b', 'INSERT') AS b_insert, relacl FROM pg_class WHERE relname = 't';table_insert | id_insert | b_insert | relacl --------------+-----------+----------+--------------------------------------------- t | t | t | {postgres=arwdDxtm/postgres,app=a/postgres}Column
ahas{app=w/postgres};idandbhave no column ACL. Soappcan now insert into every column, which neither the old nor the new desired state allows.
Expected
One column list per privilege, e.g. GRANT INSERT (a), UPDATE (a) ON TABLE t TO app; (and the same for REVOKE).
After the apply, app should have INSERT and UPDATE on column a only, and dump → plan of an unchanged
database should be empty.