Conversation
Track per-column ACLs from pg_attribute.attacl so plans emit GRANT/REVOKE SELECT/INSERT/UPDATE/REFERENCES (column) statements. Column grants are emitted after CREATE TABLE for new tables and after ADD COLUMN for new columns. A column that is dropped takes its privileges with it, so no REVOKE is emitted for it. Constraint: Column privileges are stored in pg_attribute.attacl, separate from the table ACL in pg_class.relacl, so they need their own introspection query and schema field. Rejected: Folding column ACLs into the table privilege list | table and column privileges live in different catalogs and their SQL statements carry different column lists. Directive: Keep column privilege validation aligned with table privilege validation because privilege statements are skipped when roles are absent in the temp DB. Tested: go test ./... with PostgreSQL 17 server utilities and PostgreSQL 18 pg_dump for --restrict-key support
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Adds schema tracking and migration generation for column-level privileges.
pg_attribute.attaclthrough a newGetColumnPrivilegesquery.ColumnPrivilegeandTable.ColumnPrivilegesto the schema model.GRANT/REVOKE SELECT|INSERT|UPDATE|REFERENCES (column) ON tablestatements for column ACL drift.CREATE TABLEfor new tables and afterADD COLUMNfor new columns, ordered through SQL graph dependencies.REVOKE.Why
PostgreSQL stores column grants in
pg_attribute.attacl, separate from the table ACL inpg_class.relacl. Before this change, pg-schema-diff did not model column ACLs, so a plan could omitGRANT ... (column)statements for new tables and new columns, and it could miss drift when a column grant was revoked. Both cases had to be patched by hand.Validation
Ran the full test suite with PostgreSQL 17 server utilities and PostgreSQL 18
pg_dumpfor--restrict-keysupport:go test ./...New acceptance cases cover a new table with column grants, granting and revoking a column privilege, granting on a new column (asserting
ADD COLUMNis ordered beforeGRANT), a grant on multiple columns,GRANT OPTIONrecreation, a non-public schema, and the partition not-implemented paths.