Module: Pg
- Defined in:
- lib/fresco/runtime/db_postgres.rb
Overview
Fresco Postgres adapter. Copied verbatim to generated/db_adapter.rb by ‘fresco build` when config/database.rb declares `Fresco.database :postgres`. Always loaded between runtime.rb and config/app.rb —boot order in lib/fresco/runtime/boot.rb.
Same Ruby surface as db_sqlite.rb — ‘Fresco::Db::Postgres` exposes open/close/exec/prepare/bind_str/bind_int/step/col_str/col_int/ col_count/finalize/reset/last_rowid + the first_str/first_int helpers. Generated code (M3+) writes against `Fresco::Db::Active` so swapping adapters is a config edit, not an action edit.
Placeholder syntax differs from SQLite: libpq uses ‘$1, $2, …` not `?`. User-written SQL has to use the adapter’s native syntax; M3+ codegen will paper over this when emitting prepared statements.
Build dependency: generated/runtime/postgres.c (copied from the fresco gem at build time) needs libpq’s headers (‘libpq-fe.h`) and library (`-lpq`). `fresco release` auto-detects Homebrew/Postgres.app layouts and exports CPATH/LIBRARY_PATH accordingly. On Linux: `apt-get install libpq-dev`. `Pg` (not `Postgres`) so the FFI module name doesn’t collide with ‘Fresco::Db::Postgres`. Matches the `fresco_pg_*` C-side prefix and mirrors the `Sqlite` (FFI) vs `SQLite` (wrapper) split.