Chat2DB fixes the invisible half of Oracle EXPLAIN PLAN
The 5.3.7 beta now writes a uniquely tagged plan, reads it back through DBMS_XPLAN and restores the client transaction—turning a success message into an inspectable result.
Chat2DB 5.3.7-beta.4 fixes a deceptively important Oracle client failure: EXPLAIN PLAN could succeed while showing the user no plan. The September 21 prerelease now returns the generated execution plan as a result set, alongside two desktop-updater reliability fixes.
Why “success” was not enough
Oracle’s EXPLAIN PLAN does not return the plan as a normal query result. Oracle documents that the statement inserts one row per plan step into an output table—PLAN_TABLE by default—and that a separate query is needed to inspect those rows. That behavior is valid at the database layer, but it meant Chat2DB’s generic execution path could report a successful command with nothing useful in the result grid.
The new Oracle-specific path closes that gap. Chat2DB first checks that PLAN_TABLE is available, generates a unique statement identifier, runs the explanation under that identifier, then reads the formatted plan through DBMS_XPLAN.DISPLAY. If the plan table is missing, the client returns an actionable setup message rather than an empty result.
The transaction boundary matters
The implementation also handles a less visible constraint. Oracle classifies EXPLAIN PLAN as DML and does not implicitly commit its plan-table rows. Chat2DB therefore temporarily disables autocommit when needed, writes and reads the plan in one transaction, rolls back those temporary rows, and restores autocommit afterward. Caller-managed transactions are left alone.
That sequence is more than client polish. A database assistant that proposes or explains SQL needs the same diagnostic evidence a human operator would inspect. Returning only “executed successfully” hides whether Oracle chose an index scan, a full table scan or another expensive path. Returning the actual plan makes the optimization step reviewable before anyone treats an AI-generated query as production-ready.
The merged change also avoids wrapping an existing EXPLAIN PLAN inside a second explain command, which previously could fail with ORA-00905. Custom INTO <table> statements retain Oracle’s default path rather than being intercepted.
What is—and is not—proved
The contributor reports 12 parser tests, 11 command-executor tests and 73 tests across the Oracle module, plus manual checks against Oracle AI Database 26ai Free. Those checks produced different visible plans for indexed and non-indexed predicates. The evidence is maintainer-reported, not an independent benchmark, and the release remains a beta.
Even so, the change defines a useful boundary for AI-assisted SQL tooling: generating a query is only the first half of the workflow. The client must also surface the database’s own execution evidence, preserve transaction semantics and fail clearly when the diagnostic substrate is unavailable.
sources
comments · 0