pg-dispatch-is-function-level-early-return

IN premise

PostgreSQL routing uses a function-level early-return pattern — each API function checks `pg_conninfo` and short-circuits to `_pg_dispatch`, which instantiates PgApi and calls the matching method via `getattr` — rather than using abstract base classes, subclassing, or factory patterns.

Summary

The PostgreSQL backend switching works through a simple pattern where each API function checks for a connection string and, if found, immediately hands off to a PostgreSQL-specific implementation by looking up the equivalent method by name. This means there is no formal class hierarchy or plugin system involved — just a straightforward "if Postgres is configured, call the Postgres version instead" check at the top of each function.

Details

Sourceentries/2026/05/10/postgresql-backend-support.md