Skip to content

Decouple driver internals from PDO::ATTR_STRINGIFY_FETCHES #451

Description

@JanJakes

Problem

The MySQL-on-SQLite driver currently relies on PDO::ATTR_STRINGIFY_FETCHES being enabled for some of its internal metadata queries.

When stringification is disabled (the default for PDO SQLite), SQLite metadata values are returned as integers on current PHP versions. Several driver paths compare those values strictly against strings, so changing a public PDO fetch attribute can alter internal DDL and emulation behavior.

Known examples include:

  • detecting temporary information-schema tables with fetchColumn() === '1'
  • restoring PRAGMA foreign_keys only when its value is strictly '1'
  • interpreting NON_UNIQUE only when its value is strictly '0'
  • reconstructing columns and indexes by comparing notnull, pk, and unique metadata to string values

This was observed while simplifying the driver API in #449. With PDO::ATTR_STRINGIFY_FETCHES disabled, translation tests failed because unique indexes were recreated as non-unique and foreign-key state handling was skipped.

WordPress and the MySQL binary protocol adapter may still choose to enable stringified fetches for their outward compatibility. The driver's internal correctness should not depend on that caller-facing setting.

Expected behavior

  • Normalize or cast internal SQLite metadata independently of PDO::ATTR_STRINGIFY_FETCHES.
  • Produce identical DDL, index, foreign-key, and information-schema behavior whether stringified fetches are enabled or disabled.
  • Continue honoring PDO::ATTR_STRINGIFY_FETCHES for result values returned through the public PDO-compatible API.
  • Add coverage for both attribute states, including unique index reconstruction and foreign-key handling.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions