Skip to content

fix(postgres): discover ordinary and materialized views - #769

Open
2160039878-cyber wants to merge 1 commit into
libredb:mainfrom
2160039878-cyber:fix/postgres-view-discovery-710
Open

fix(postgres): discover ordinary and materialized views#769
2160039878-cyber wants to merge 1 commit into
libredb:mainfrom
2160039878-cyber:fix/postgres-view-discovery-710

Conversation

@2160039878-cyber

@2160039878-cyber 2160039878-cyber commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Description

PostgreSQL ordinary and materialized views now appear with their columns in the existing schema explorer. Ordinary views use information_schema; materialized views supplement it from pg_class/pg_attribute because PostgreSQL excludes them from information_schema. Both fast and full schema reads remain single queries.

Closes #710.

Changes Made

  • Include ordinary views and supplement materialized relations/columns without duplicating engines that already publish them through information_schema.
  • Preserve system/extension-schema exclusion and role visibility, including column-only grants. Use format_type for materialized-view type modifiers; keep their existing index discovery and avoid inventing primary keys.
  • Keep the overview's relation count consistent with the explorer. Ordinary views and unpopulated materialized views have no estimated row-count badge.
  • If a wire-compatible engine reports a missing PostgreSQL catalog column or privilege/type function, remove the marked catalog supplement and retry its information-schema path. Permission errors remain errors.
  • Update the matching provider documentation and integration tests in the same PR.

Testing

  • TDD: three new discovery regressions failed before implementation.
  • bun run test:integration --isolate --pass-with-no-tests -t 'PostgresProvider': 195 passed, including existing compatibility fallbacks and new view discovery/error cases.
  • Ran the actual production schema and overview SQL against an isolated in-memory PostgreSQL 18.3 engine (PGlite 0.5.8), not mocked query rows. Verified both schema paths, ordinary and materialized columns, numeric(12,2), materialized indexes, no invented PK, unpopulated metadata, and consistent overview counts. An owner saw all five fixture relations; a restricted role saw only three granted views and only its two granted materialized-view columns. Selecting the unpopulated view correctly returned PostgreSQL error 55000. The temporary database was closed afterward.
  • PGlite was installed in a separate local verification directory; no project dependency was added. This does not validate a TCP connection or live PostgreSQL-compatible products.
  • Passed locally: format, lint, typecheck, knip, readme:check, chart:check, channels:showcase:check, security:check, build, build:lib, attw.
  • Builds used clean commit c1a214fe0bb9e20620dddc6f6664a43bb2576a92.
  • Full local bun run test, coverage and app E2E were not run: this Windows host lacks Helm/chart dependencies and working Docker; existing SQLite cleanup also encounters Windows file locks. CI must verify the full suite and 100% line coverage.

Environment: Windows, Node.js 24.18.1, Bun 1.4.2.

Checklist

  • Claimed and linked the issue, reviewed the diff and kept the provider code/docs/tests triad together.
  • Added regression coverage and validated production SQL against a real PostgreSQL engine.
  • Required CI test job passes the 100% line-coverage gate.

Additional Notes

AI-assisted implementation and validation using Codex. Schema discovery performs catalog reads only. An unpopulated materialized view can be explored through its columns, but a data preview still requires a user-initiated REFRESH MATERIALIZED VIEW; the explorer never refreshes it automatically.

@cevheri cevheri added the loop:needs-moderator-action Flagged by the maintainer loop: suspicious content or a decision only a human can make label Sep 9, 2026
@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

loop:needs-moderator-action Flagged by the maintainer loop: suspicious content or a decision only a human can make

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] support views and materialised views for Postgres

2 participants