Files
synapse/tests
Erik JohnstonandClaude Opus 4.8 d26d1f5757 Make PostgresEngine a driver-agnostic base for psycopg2 and Rust
Previously RustPostgresEngine subclassed the psycopg2 PostgresEngine, which
dragged psycopg2 into the Rust path and conflated "is Postgres" with "is
psycopg2". Split the hierarchy so both drivers are siblings:

  - `PostgresEngine` (new `postgres_base` module) is now the driver-agnostic
    base holding the shared SQL-dialect and config logic (single_threaded,
    supports_using_any_list, row_id_name, get_db_locale, check_new_database,
    lock_table, synchronous_commit / statement_timeout). It has no driver
    dependency, so it always imports. Everything touching a live connection,
    the DBAPI2 exception module, or the placeholder style is left abstract.
  - `Psycopg2Engine(PostgresEngine)` holds the psycopg2 specifics (register_type
    / register_adapter, isolation-level map, conn.status/closed/server_version,
    `%s` placeholders, psycopg2 execute path, `uses_psycopg2_extras = True`).
  - `RustPostgresEngine(PostgresEngine)` is re-parented onto the base (no longer
    inherits psycopg2). It passes the Rust DBAPI2 module to the base and gets
    NotImplementedError stubs for the still-psycopg2-shaped check_database /
    server_version (part of the deferred startup wiring).

The base keeps the name `PostgresEngine`, so all ~91
`isinstance(engine, PostgresEngine)` checks across the storage layer (which mean
"emit Postgres SQL") hold for both drivers unchanged. `create_engine` now
returns `Psycopg2Engine` for `name == "psycopg2"`.

Verified: full lint clean; Rust engine/adapter tests pass; a psycopg2 homeserver
boots and runs (test_room_search under Postgres) and the sqlite path is
unaffected (test_room_search / test_event_federation under sqlite).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W3G4M92AmwSSZCbmtMJU3d
2026-07-11 09:04:57 +00:00
..
2026-06-02 11:05:38 +01:00