Skip to content

Align PDO error handling and diagnostics with PDO MySQL #473

Description

@JanJakes

Problem

Error handling and diagnostic state in WP_MySQL_On_SQLite differ from PDO MySQL across public connection and statement operations.

Error-mode handling

Some operations delegate directly to the underlying SQLite connection, which remains in exception mode for internal use. As a result:

  • Raw SQLite PDOExceptions may escape under ERRMODE_SILENT and ERRMODE_WARNING.
  • The configured error mode may be ignored by transaction, attribute, and statement operations.
  • Connection or statement diagnostics may not be populated correctly.

Transaction-state errors such as “There is no active transaction” are separate and should continue to throw regardless of error mode.

Diagnostic lifecycle

Successful operations do not consistently update diagnostics according to PDO MySQL behavior. This is operation-specific:

  • lastInsertId() resets previous diagnostics to 00000.
  • Successful transaction operations preserve existing diagnostics.

Explicit transactions

A failed query() currently rolls back the active user transaction. PDO MySQL keeps the transaction active so the caller can decide whether to commit or roll it back.

Expected behavior

  • Apply the configured error mode to all public connection and statement operations.
  • Keep internal SQLite exception handling separate from caller-visible behavior.
  • Populate connection and statement diagnostics on failure.
  • Reset or preserve diagnostics after success according to PDO MySQL behavior for each operation.
  • Keep transaction-state errors throwing in every error mode.
  • Roll back only the failed statement’s internal transaction or savepoint.
  • Keep explicit user transactions active after statement errors.
  • Add coverage across public operations and all supported error modes.

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