Faithful port of the C++ fivenode topology — node hosts the existing N-API
addon, which now links a libfivenode implemented in Go (CGO c-shared)
instead of the Harbour-C core. cmd/libfivenode exports the C ABI the addon
expects (hb_bridge_init/shutdown/handle_request/last_error/set_auth/
clear_auth/free, tfn_register_callbacks). Build:
go build -buildmode=c-shared \
-ldflags="-extldflags=-Wl,-install_name,@rpath/libfivenode.dylib" \
-o native/output/darwin/libfivenode.dylib ./cmd/libfivenode
P1 proven: node → addon → Go hb_bridge_handle_request round-trips a
response in-process (no Harbour-C, no subprocess). P2 wires the real PRG
dispatcher; P3 the npm callbacks (tfn_register_callbacks → Require); P4
the node main-thread marshaling. (goja probe removed — pure-JS only,
insufficient for full npm.)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
PG_OPEN(cDsn) -> integer handle, -1 on failure
PG_CLOSE(nH) -> NIL
PG_QUERY(nH, cSQL [, aArgs]) -> array of { col => val } hashes
PG_EXEC (nH, cSQL [, aArgs]) -> rows affected, -1 on error
PG_LAST_ERROR(nH) -> last error string
Backed by github.com/jackc/pgx/v5/pgxpool, which is already in Five's
indirect dep tree (pgserver uses pgproto3 from the same repo). Pool
limits: MaxConns 8, MinConns 1, 5-min idle. Query timeout is capped at
30s so a runaway query can't pin a goroutine forever.
aArgs uses standard Postgres $1/$2/... placeholders — pgx parameter
binding prevents SQL injection. Never concatenate user input into cSQL.
Smoke-tested with app/pg_test.prg: bad DSN returns -1 cleanly (no
panic), the error path prints the expected fallback message, and the
real round-trip path is wired so setting LABDB_DSN to a live database
exercises SELECT + parameter binding + multi-row return without any
further code change.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>