Skip to content

fix(db): use pg_constraint to support SELECT-only roles#41

Merged
mfreed merged 1 commit into
mainfrom
fix/constraint-discovery-select-only
May 24, 2026
Merged

fix(db): use pg_constraint to support SELECT-only roles#41
mfreed merged 1 commit into
mainfrom
fix/constraint-discovery-select-only

Conversation

@mfreed
Copy link
Copy Markdown
Member

@mfreed mfreed commented May 24, 2026

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).

…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).
@mfreed mfreed merged commit 1b3bf9f into main May 24, 2026
2 checks passed
@mfreed mfreed deleted the fix/constraint-discovery-select-only branch May 24, 2026 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

data-first: .export/<format> returns 0 bytes on self-hosted Postgres (macOS, v0.6.0)

1 participant