Repository navigation
fix(erd): the Diagram tab reads the catalog through the SQL editor session (implicit BEGIN, aborted transactions, LIMIT 5000) #1218
Copy link
Copy link
Closed
Labels
P1High priority / Core capabilityHigh priority / Core capabilitybugSomething isn't workingSomething isn't workingconnectionsDatabase connections, URI parsing, poolsDatabase connections, URI parsing, poolseditorCode/SQL editorCode/SQL editor
Description
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'sSqlExecutionDelegate, i.e. the editor'sreadWritesession (orreadOnlyfor read-only connections).ErdCatalog.load/loadNeighbourhoodcalldelegate.executeQuery(...)without a limit (lib/features/erd/erd_catalog.dart:108-109,:121).
Consequences:
- PostgreSQL, manual commit:
PostgresSqlExecutionDelegate.executeQuerysendsBEGINwhen 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. - 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".
- 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).
- Silent truncation: without a limit,
executeQueryinjectsLIMIT 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'sreadOnlyslot, or a dedicated catalog slot), not the editor's delegate. - Catalog queries never go through the editor's implicit
BEGINor 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
BEGINon 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P1High priority / Core capabilityHigh priority / Core capabilitybugSomething isn't workingSomething isn't workingconnectionsDatabase connections, URI parsing, poolsDatabase connections, URI parsing, poolseditorCode/SQL editorCode/SQL editor
Activity
Merge pull request #1224 from QueryaHub/fix/1218-diagram-catalog-session
ZhuchkaTriplesix commentedon Oct 9, 2026
Closed by #1224.