Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ members = [
"crates/perry-ext-nodemailer",
"crates/perry-ext-cron",
"crates/perry-ext-ioredis",
"crates/perry-ext-pg",
"crates/perry-ext-mysql2",
"crates/perry-ext-fetch",
"crates/perry-ext-undici",
Expand Down Expand Up @@ -504,7 +503,6 @@ perry-ext-ethers = { path = "crates/perry-ext-ethers" }
perry-ext-nodemailer = { path = "crates/perry-ext-nodemailer" }
perry-ext-cron = { path = "crates/perry-ext-cron" }
perry-ext-ioredis = { path = "crates/perry-ext-ioredis" }
perry-ext-pg = { path = "crates/perry-ext-pg" }
perry-ext-mysql2 = { path = "crates/perry-ext-mysql2" }
perry-ext-fetch = { path = "crates/perry-ext-fetch" }
perry-ext-undici = { path = "crates/perry-ext-undici" }
Expand Down
31 changes: 31 additions & 0 deletions changelog.d/10677-remove-pg-native-binding.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Removed the native `pg` binding: `crates/perry-ext-pg` (sqlx::postgres +
tokio bridge over `perry-ffi`) and the duplicate pre-#466 in-tree
implementation in `crates/perry-stdlib/src/pg/` (the `bundled-pg` feature),
kept alive since before the migration to a separate ext crate. Both defined
the same `extern "C"` symbols (`js_pg_client_new`, `js_pg_client_query`, …);
whichever won the link order silently shadowed the other. `import ... from
"pg"` no longer resolves as a native module at all — it compiles the real
npm `pg` package from source, same as any other TypeScript/JavaScript
dependency, with `pg` and its 13 transitive deps (`pg-connection-string`,
`pg-pool`, `pg-protocol`, `pg-types`, `pgpass`, `pg-int8`,
`postgres-{array,date,interval,bytea}`, `pg-cloudflare`, `split2`, `xtend`)
picked up automatically by Perry's compile-package wildcard when a project
has no `perry.compilePackages` entry, or explicit listing otherwise.

Removed the `[bindings.pg]` entry (`well_known_bindings.toml`), the `"pg"`
`NATIVE_MODULES` entry and manifest rows (`perry-api-manifest`), the pg
`NativeModSig` dispatch-table rows (`perry-codegen`'s
`lower_call/native_table/databases.rs`), the `stdlib_features.rs` /
`optimized_libs` feature-gate arms, the `bundled-pg`/`database-postgres`
Cargo features and the now-unreachable `sqlx` `"postgres"` feature on
`perry-stdlib`'s dependency (verified nothing else in the workspace
requests it), and the `perry-ext-pg` entry in `workspace-architecture.json`.
Regenerated `docs/api/perry.d.ts`, `docs/src/api/reference.md`, and
`docs/src/native-libraries/governance.md`'s generated table; updated
`docs/src/native-libraries/overview.md`'s well-known-binding description.

Verified end to end without forcing `compilePackages`: a from-scratch
`node_modules` with a plain `"pg": "^8"` dependency and no
`perry.compilePackages` key compiles, links (24.7 MB binary), and reaches a
genuine `net.connect()` — `Connection refused` against a port with nothing
listening. No live Postgres was available to test a real query round-trip.
1 change: 0 additions & 1 deletion crates/perry-api-manifest/src/entries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ pub const NATIVE_MODULES: &[&str] = &[
// ── Third-party npm packages (native wrappers; see well_known_bindings.toml) ──
"mysql2", // MySQL/MariaDB client
"mysql2/promise", // mysql2's promise-API subpath
"pg", // PostgreSQL client
"uuid", // RFC-4122 UUID generation
"qs", // nested query-string parser/stringifier (Stripe dependency)
"bcrypt", // bcrypt password hashing (replaces the N-API addon)
Expand Down
7 changes: 0 additions & 7 deletions crates/perry-api-manifest/src/entries/part_1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,6 @@ pub(crate) const API_MANIFEST_PART_1: &[ApiEntry] = &[
method("mysql2/promise", "beginTransaction", true, None),
method("mysql2/promise", "commit", true, None),
method("mysql2/promise", "rollback", true, None),
method_sig("pg", "connect", false, None, &[p_any("p0")], TypeSpec::Any),
method_sig("pg", "Pool", false, None, &[p_any("p0")], TypeSpec::Any),
method("pg", "connect", true, Some("Client")),
method("pg", "query", true, Some("Pool")),
method("pg", "end", true, Some("Pool")),
method("pg", "query", true, None),
method("pg", "end", true, None),
method_sig(
"ioredis",
"createClient",
Expand Down
2 changes: 0 additions & 2 deletions crates/perry-api-manifest/src/entries/part_3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,6 @@ pub(crate) const API_MANIFEST_PART_3: &[ApiEntry] = &[
class("ioredis", "Redis"),
class("mysql2/promise", "Pool"),
class("mysql2", "Pool"),
class("pg", "Pool"),
class("pg", "Client"),
class("url", "URL"),
class("url", "URLSearchParams"),
class("url", "URLPattern"),
Expand Down
81 changes: 0 additions & 81 deletions crates/perry-codegen/src/lower_call/native_table/databases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,87 +275,6 @@ pub(super) const DATABASES_ROWS: &[NativeModSig] = &[
args: &[],
ret: NR_GCPTR,
},
// ========== PostgreSQL (pg) ==========
// `new Client(config)` and `new Pool(config)` are dispatched by
// `lower_builtin_new` (sync constructors that produce real handles).
// The factory-style entries below stay wired for `pg.connect(config)` /
// `pg.Pool(config)` patterns that some npm code uses.
NativeModSig {
module: "pg",
has_receiver: false,
method: "connect",
class_filter: None,
runtime: "js_pg_connect",
args: &[NA_F64],
ret: NR_GCPTR,
},
NativeModSig {
module: "pg",
has_receiver: false,
method: "Pool",
class_filter: None,
runtime: "js_pg_create_pool",
args: &[NA_F64],
ret: NR_GCPTR,
},
// `client.connect()` — async, opens the TCP connection on a handle that
// `new Client(config)` previously created in the pre-connect state.
// No-op if the handle was already connected (e.g. came from the
// older `pg.connect(config)` factory). Class-filtered to Client so
// `pool.connect()` (which has different semantics — checkout a pooled
// connection — not yet implemented) doesn't accidentally land here.
NativeModSig {
module: "pg",
has_receiver: true,
method: "connect",
class_filter: Some("Client"),
runtime: "js_pg_client_connect",
args: &[],
ret: NR_GCPTR,
},
// Pool-specific query/end — different runtime fns from the Client paths.
// Pre-existing dispatch was unfiltered and routed both Pool and Client
// through the Client query/end fns (latent bug: pool.query() against a
// Pool handle would fail because js_pg_client_query expects a Connection
// handle). Class-filtered Pool rows take precedence over the unfiltered
// Client/default rows below thanks to native_module_lookup's two-pass
// search (exact class_filter match first, then None fallback).
NativeModSig {
module: "pg",
has_receiver: true,
method: "query",
class_filter: Some("Pool"),
runtime: "js_pg_pool_query",
args: &[NA_STR, NA_PTR],
ret: NR_GCPTR,
},
NativeModSig {
module: "pg",
has_receiver: true,
method: "end",
class_filter: Some("Pool"),
runtime: "js_pg_pool_end",
args: &[],
ret: NR_GCPTR,
},
NativeModSig {
module: "pg",
has_receiver: true,
method: "query",
class_filter: None,
runtime: "js_pg_client_query",
args: &[NA_STR, NA_PTR],
ret: NR_GCPTR,
},
NativeModSig {
module: "pg",
has_receiver: true,
method: "end",
class_filter: None,
runtime: "js_pg_client_end",
args: &[],
ret: NR_GCPTR,
},
// ========== ioredis ==========
// NB: every row was previously emitting `js_redis_*` symbols which don't
// exist in perry-stdlib (the actual fns are `js_ioredis_*`). The bug was
Expand Down
20 changes: 0 additions & 20 deletions crates/perry-ext-pg/Cargo.toml

This file was deleted.

Loading
Loading