tobogganSe connecter

packages

The Louise packages, each released on its own

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

Packages: the postgres driver connects, authenticates and queries (issue #145, part)

`packages/postgres` now talks to a real PostgreSQL:

- **`client`**: one actor per connection (it owns the socket and the read
  buffer, so a connection is never shared mid-query). Connect over TCP,
  upgrade to TLS per `sslmode` (`SslRequest`, then `std/tls`'s
  `tls.connect` — `require` refuses a plain answer), the startup message,
  then authentication: `trust`, cleartext password (over TLS or to
  localhost only), or SCRAM-SHA-256. Queries run on the extended
  protocol, one write for Parse/Bind/Describe/Execute/Sync, rows
  collected until `ReadyForQuery`. Parameters travel as `$1` in text
  format, never inside the SQL text.
- **`config`**: `postgres://user:password@host:port/db?sslmode=...`,
  percent-decoded, the password never in an error or `Debug`.
- **`row`**: typed accessors by column name (`text`, `int`, `bool`,
  `bytea` — NULL is `Option`), errors naming the column.
- **`lib`** (the `postgres` module): `config`, `connect`, `query`,
  `execute` (rows affected from the command tag; DDL counts as 0),
  `close`, `sqlstate`, the `pg.text`/`pg.int`/... value constructors, and
  the row accessors.
- **The `sql` tagged template** (ADR 0048): `` sql`select version from
  streams where id = {stream}` `` numbers its holes into `$1`, `$2`, … —
  parameters, never SQL text — taking each hole's `Show` text as the wire
  encoding (`pg.bool`/`pg.bytea` for the types that need them; SQL `null`
  is written literally).

Tests: the codec against recorded transcripts and SCRAM against RFC
7677's exchange (both backends, no database); `test/live_test.lse` runs
against a real PostgreSQL when `LOUISE_PG_URL` is set (a container in
development: connect, SCRAM, the v0 types, NULL round-trips, a 23505,
the `sql` template; skipped otherwise).

olivier · il y a 1 mois · 405fb02565c164faaae7b77ce25ed5ced79b207d

Parents 2a84a7b

10 fichiers modifiés, 1291 ajouts, 0 suppressions