Skip to content

perf(mysql): avoid full parse for ordinary completion scripts - #2865

Merged
openai0229 merged 1 commit into
mainfrom
fix/sql-completion-performance
Sep 2, 2026
Merged

openai0229 merged 1 commit into
mainfrom
fix/sql-completion-performance

Conversation

@openai0229

Copy link
Copy Markdown
Contributor

Related issue

N/A - no issue number was provided.

Summary

Avoids parsing the entire MySQL editor script with the ANTLR root parser when lexer boundaries prove that the input is a balanced ordinary SQL script. Complex routines, DELIMITER scripts, malformed input, and ambiguous no-semicolon statements keep the existing parser/probe path. Adds boundary coverage and a large-SQL performance test for 200-line scripts and 166/500/1000-value IN lists.

Affected surfaces

  • Frontend / Web
  • Backend / API / Storage
  • Database plugin / Driver
  • JCEF / Desktop packaging
  • CI / Build / Release
  • Documentation only

Verification

  • Commands and results:
    • mvn -B -f chat2db-community-server/pom.xml -pl :chat2db-community-mysql -am -Dmaven.test.skip=false -DskipTests=false -Dtest='MysqlSqlCompletionProviderTest,MysqlSqlCompletionScenarioCoverageTest,MysqlSqlCompletionStatementProgressionTest,MysqlSqlCompletionDdlScenarioCoverageTest,MysqlSqlCompletionRuleRangeTest,MysqlSqlCompletionStatementLocatorTest,MysqlSqlCompletionPerformanceTest' -Dsurefire.failIfNoSpecifiedTests=false -Dmaven.test.failure.ignore=false test - 521 tests passed, 0 failures, 0 errors.
    • git diff --check - passed.
  • Manual verification: N/A; this is a backend parser/completion change covered by focused tests.
  • UI evidence: N/A

Risk and compatibility

  • Public API or stored data: N/A; no public request or persistence contract changed.
  • Database or driver compatibility: MySQL completion only. Stored procedures, triggers, functions, DELIMITER input, malformed input, and ambiguous statements retain the existing parser path.
  • Network, privacy, or security: N/A; no SQL text is logged or sent to a new endpoint.
  • Community / Local / Pro boundary: Community MySQL plugin only; no Studio or Enterprise code is changed.
  • Backward compatibility: Existing completion scenarios remain covered; all 521 focused tests pass.

Reviewer map

  • Start here: chat2db-community-server/chat2db-community-plugins/chat2db-community-mysql/src/main/java/ai/chat2db/plugin/mysql/completion/locate/MysqlSqlCompletionStatementLocator.java
  • Failure condition: canUseTokenWindow requires balanced parentheses, no CREATE/DELIMITER tokens, no unsafe lexer errors, and a proven separator or single top-level statement; otherwise the existing parser/probe path runs.
  • Rollback or disable path: Revert this PR; no runtime flag or migration is required.

Contributor declaration

  • I linked the Issue that defines this change.
  • I tested the affected behavior and reported the actual results above.
  • I did not include credentials, private data, or generated build output.
  • I disclosed substantial AI assistance below, or this PR contains no substantial AI-generated code.

AI assistance: Substantial AI assistance was used for code navigation, implementation, test design, performance measurement, and verification.

@openai0229
openai0229 requested a review from Aias00 as a code owner September 2, 2026 04:46
@openai0229 openai0229 moved this to In Review in Chat2DB Community Sep 2, 2026
@openai0229
openai0229 force-pushed the fix/sql-completion-performance branch from 9ac654e to acda89b Compare September 2, 2026 05:47
@openai0229
openai0229 force-pushed the fix/sql-completion-performance branch from acda89b to 4e894c0 Compare September 2, 2026 05:50
@openai0229
openai0229 merged commit 3bcd316 into main Sep 2, 2026
16 checks passed
@openai0229
openai0229 deleted the fix/sql-completion-performance branch September 2, 2026 06:44
@openai0229 openai0229 moved this from In Review to Done in Chat2DB Community Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant