Skip to content

fix(erd): PostgreSQL catalog misses keys for non-owner roles, composite FKs give wrong edges; read pg_catalog #1167

Description

@ZhuchkaTriplesix

Problem

ErdCatalog reads PostgreSQL through information_schema (erd_catalog.dart). Three problems:

  • Read-only roles see no keys. Per the PostgreSQL docs, information_schema.table_constraints lists only constraints of tables the current user owns or has some privilege other than SELECT on, and constraint_column_usage only columns of tables owned by a currently enabled role. Connected as an application or read-only user (not the schema owner), the diagram shows tables without PK markers and without relations.
  • Composite foreign keys produce wrong edges. The FK query joins key_column_usage and constraint_column_usage on the constraint name only; for a 2-column FK (a, b) → (x, y) this yields 4 pairs (a→x, a→y, b→x, b→y) instead of 2.
  • Slow on large catalogs. information_schema views are much slower than pg_catalog on databases with thousands of tables.

Scope

Acceptance

  • A role with only SELECT on the tables sees PKs and FKs.
  • A composite FK draws 2 edges between the right columns.
  • Catalog tests: composite FK, cross-schema FK, non-owner role (SQL-level test with recorded rows).

Activity

  1. added
    bugSomething isn't working
    performanceTheme parser epic label: performance
    coreCore library logic and services
    P1High priority / Core capability
    on Oct 8, 2026
  2. added 2 commits that reference this issue on Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High priority / Core capabilitybugSomething isn't workingcoreCore library logic and servicesperformanceTheme parser epic label: performance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions