Skip to content

fix(erd): the Diagram tab reads the catalog through the SQL editor session (implicit BEGIN, aborted transactions, LIMIT 5000) #1218

Description

@ZhuchkaTriplesix

Part of #1212.

Problem

The SQL workspace's Diagram tab reads the catalog through the SQL editor's own session and its result-grid rules.

  • ErdView(source: SqlErdSource(delegate: widget.delegate, ...)) (lib/features/workspace/generic_sql_workspace.dart:1212): the catalog goes through the editor's SqlExecutionDelegate, i.e. the editor's readWrite session (or readOnly for read-only connections).
  • ErdCatalog.load / loadNeighbourhood call delegate.executeQuery(...) without a limit (lib/features/erd/erd_catalog.dart:108-109, :121).

Consequences:

  1. PostgreSQL, manual commit: PostgresSqlExecutionDelegate.executeQuery sends BEGIN when no transaction is open (lib/features/postgresql/postgres_sql_workspace.dart:97-102). Opening or refreshing the diagram therefore opens a transaction in the editor. The toolbar shows "Transaction open", and closing the workspace or connection warns about an open transaction the user never started.
  2. Aborted editor transaction: if the editor's transaction failed, every catalog query fails with "current transaction is aborted, commands ignored until end of transaction block", and the diagram shows "Could not load the schema".
  3. Editor query running: the catalog waits behind it; with the driver's 30 s timer counting the wait, the catalog statement can cancel the editor's query, and the wrapper then force-closes the editor session, losing its transaction (fix(db): a timeout or a server-side cancel force-closes a shared session, and a queued statement can cancel another caller's #1216).
  4. Silent truncation: without a limit, executeQuery injects LIMIT kDefaultSqlResultMaxRows = 5000 (lib/core/storage/app_settings.dart:11, postgres_sql_workspace.dart:94; MySQL and SQLite delegates do the same). The columns query returns one row per column, ordered by table name, so a schema with more than 5000 columns loses the tables at the end of the alphabet, or shows them with missing columns, without any notice. MCP reads the same catalog with a limit of 200 000.

The Relations view in the table browser is not affected by 1, 2 and 4: it uses TableDataSqlAdapter → loadCustomSql (no limit, no BEGIN) on the read-only session.

Scope

  • The Diagram tab gets its own read-only ErdSource: a catalog delegate on a read-only session (the pool's readOnly slot, or a dedicated catalog slot), not the editor's delegate.
  • Catalog queries never go through the editor's implicit BEGIN or the result-grid limit. Use an explicit catalog limit (like MCP's 200 000) and show a notice in the diagram when the catalog hits it.
  • The editor's transaction state, running query and badge stay untouched by the diagram.

Acceptance

  • PostgreSQL, manual commit: opening and refreshing the Diagram sends no BEGIN on the editor session, and the transaction badge does not change (fake delegate test).
  • With the editor's transaction aborted, the diagram still loads.
  • A fake catalog of 6 000 column rows renders every table; a catalog over the explicit limit shows a truncation notice.

Activity

  1. added
    bugSomething isn't working
    editorCode/SQL editor
    connectionsDatabase connections, URI parsing, pools
    P1High priority / Core capability
    on Oct 9, 2026
  2. added a commit that references this issue on Oct 9, 2026
  3. ZhuchkaTriplesix commented on Oct 9, 2026

    @ZhuchkaTriplesix
    MemberAuthor

    Closed by #1224.

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 workingconnectionsDatabase connections, URI parsing, poolseditorCode/SQL editor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions