Skip to content

Fix PostgreSQL key metadata for readonly users - #543

Merged
debba merged 2 commits into
TabularisDB:mainfrom
DhruvShah-Dev:fix/postgres-fk-readonly-catalog
Jul 28, 2026
Merged

Fix PostgreSQL key metadata for readonly users#543
debba merged 2 commits into
TabularisDB:mainfrom
DhruvShah-Dev:fix/postgres-fk-readonly-catalog

Conversation

@DhruvShah-Dev

@DhruvShah-Dev DhruvShah-Dev commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replace PostgreSQL primary-key column detection with a pg_catalog query instead of information_schema.table_constraints.
  • Reuse the catalog expression across single-table, batch-table, and view column loading.
  • Extend coverage so the Postgres FK integration scenario also verifies primary-key detection on the referenced table.

Why

Issue #96 reports that readonly users can have access to pg_constraint while information_schema.table_constraints returns no rows. That caused key metadata to be missed even when the required catalog data was visible.

Validation

  • pnpm.cmd typecheck
  • pnpm.cmd lint
  • pnpm.cmd build
  • git diff --check
  • pnpm.cmd exec gitnexus detect-changes reported low risk

@debba debba left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for this contribution! The fix looks solid: the pg_catalog-based EXISTS expression is correlated on schema, table, and column, handles composite keys via unnest(conkey), and correctly skips dropped columns. I reproduced the original issue locally with a SELECT-only role — information_schema.table_constraints returns no rows for it while the new pg_constraint query correctly reports the primary key — so this genuinely fixes #96. Unit tests (102 passed) and the Postgres integration test both pass on the branch. Merging.

@debba
debba merged commit 58a3ee0 into TabularisDB:main Jul 28, 2026
1 check passed
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.

2 participants