fix(db): use pg_constraint to support SELECT-only roles#41
Merged
Conversation
…ECT-only roles information_schema.table_constraints requires a non-SELECT privilege per the SQL spec, so SELECT-only roles see zero rows and TigerFS silently disables .first/N, .last/N, .by/<pk>, etc., and emits DDL without the PRIMARY KEY clause. Switch the three affected queries (GetPrimaryKey, GetTableDDL, getUniqueConstraints) to pg_constraint, which is publicly readable. Matches the pattern already used by GetForeignKeyDDL, GetCheckConstraintDDL, and the index-PK exclusion in GetIndexDDL. Add TestRoleParity_* covering all 10 information_schema-using functions in the db package with both an owner and a SELECT-only role; includes a negative test confirming the SELECT-only role does not see ungranted tables. Fixes #37 (secondary observation).
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.
information_schema.table_constraints requires a non-SELECT privilege per the SQL spec, so SELECT-only roles see zero rows and TigerFS silently disables .first/N, .last/N, .by/, etc., and emits DDL without the PRIMARY KEY clause.
Switch the three affected queries (GetPrimaryKey, GetTableDDL, getUniqueConstraints) to pg_constraint, which is publicly readable. Matches the pattern already used by GetForeignKeyDDL, GetCheckConstraintDDL, and the index-PK exclusion in GetIndexDDL.
Add TestRoleParity_* covering all 10 information_schema-using functions in the db package with both an owner and a SELECT-only role; includes a negative test confirming the SELECT-only role does not see ungranted tables.
Fixes #37 (secondary observation).