Skip to content

refactor(postgresql): eliminate duplicate _splitPostgresStatements in favor of SqlStatementSplitter #1517

Open

Description

@ZhuchkaTriplesix

Summary

In lib/features/postgresql/postgres_table_utils.dart (lines 66–109):

isAllowedPostgresSelectQuery relies on _splitPostgresStatements(sql), which creates multiple full-text masked copies of the SQL string:

List<String> _splitPostgresStatements(String sql) {
  final masked = _maskPostgresComments(maskSqlLiteralsForLimitScan(sql));
  final statements = <String>[];
  var start = 0;
  for (var i = 0; i < masked.length; i++) {
    if (masked[i] == ';') {
      statements.add(sql.substring(start, i));
      start = i + 1;
    }
  }
...

This duplicates the functionality already provided by the core SqlStatementSplitter (lib/core/database/sql_statement_splitter.dart), while generating 2 full-text string buffers and multiple unnecessary substring slices.

Proposed Solution

  1. Replace _splitPostgresStatements(sql) with SqlStatementSplitter.spans(sql).
  2. Remove private helper functions _splitPostgresStatements and _maskPostgresComments in postgres_table_utils.dart.

Acceptance Criteria

  • isAllowedPostgresSelectQuery uses SqlStatementSplitter.spans for statement boundary detection.
  • Over 40 lines of duplicate masking code are deleted.
  • All table browse SQL validation tests pass.

Activity

  1. added
    performanceTheme parser epic label: performance
    coreCore library logic and services
    backendBackend database driver execution and queries
    P3Low priority / Polish & Enhancements
    on Oct 12, 2026
  2. added this to the 0.5.0 milestone on Oct 12, 2026
  3. added a commit that references this issue on Oct 15, 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

    P3Low priority / Polish & EnhancementsbackendBackend database driver execution and queriescoreCore library logic and servicesperformanceTheme parser epic label: performance

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions