Skip to content

feat(sql): extract dialect interface, then add guarded MySQL engine #52

Description

@jamiesun

Background

internal/sqlsafe currently hardcodes PostgreSQL + SQLite paths (classify.go / classify_sqlite.go / postgres.go). MySQL is the highest-frequency next engine, but adding it naively risks combinatorial explosion across classify → gate → explain → backup → execute.

Plan

  1. Refactor first: extract a Dialect interface (classification quirks, identifier quoting, read-only session mechanism, EXPLAIN/row-estimate strategy, backup strategy, client invocation) with Postgres/SQLite as the two implementations. Zero behavior change, existing tests must stay green.
  2. Then MySQL: implement the dialect via remote mysql client — fail-closed classification (block multi-statement, INTO OUTFILE, LOAD DATA, stored-procedure/DELIMITER forms, writable SET GLOBAL…), read-only via SET TRANSACTION READ ONLY, DML backup via CREATE TABLE … SELECT or CSV snapshot under explicit locking, credential discovery parity with the Docker/env-file flow, run-mode command-position block for mysql/mariadb clients redirecting to sshx sql.

Acceptance

  • Dialect interface refactor lands separately with no behavior change
  • MySQL engine passes the same acceptance matrix rows as Postgres/SQLite (happy path, blocked classes, backup-before-mutate, restore drill)
  • Run-mode guard extended to mysql client binaries

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions