Packages

postgres

4.1.1 · 11 Nov 2026Unlicense38.9M / weekRepositoryHomepagenpmAtom feed

Upgrading postgres From 1.0.2 to 4.0.0

30 releases in betweenevery note read

Reading releases, release notes and advisories…

Other targets from 1.0.2Latest4.1.1
  1. 1.0.2yours
  2. 3.0.0major
  3. 23 releases
  4. 3.4.5breaking
  5. 4 releases
  6. 4.0.0target

Before you upgrade

Tick each one off as you go
  • Breaking3.4.5
  • Breaking3.0.0
  • Breaking3.0.0
  • Breaking3.0.0
  • Breaking3.0.0
  • Breaking3.0.0
  • Breaking3.0.0
  • Breaking3.0.0
  • Breaking3.0.0
  • Breaking3.0.0

Security

  • A NUL character in a connection parameter can no longer add parameters (also in v3). A database, user or connection value such as 'db\0user\0postgres' was sent as further startup parameters, so an app that put untrusted input there, as with a database per tenant, could be made to log in as another user where that user needs no password, or with replication or options set. A NUL in any protocol string, also in query text and identifiers, now rejects with NUL_CHARACTER.

    4.0.0
  • A column named __proto__ is an own property (also in v3). It became the prototype of the row, so a JSON value in it, for instance from a column alias built from user input, made the row inherit its properties (row.isAdmin), in query results and in sql.subscribe rows alike.

    4.0.0

Release by release

  1. 4.0.0

    Security fix29 Oct 202639 new · 34 fixes
    • Security

      A NUL character in a connection parameter can no longer add parameters (also in v3). A database, user or connection value such as 'db\0user\0postgres' was sent as further startup parameters, so an app that put untrusted input there, as with a database per tenant, could be made to log in as another user where that user needs no password, or with replication or options set. A NUL in any protocol string, also in query text and identifiers, now rejects with NUL_CHARACTER.

    • Security

      A column named __proto__ is an own property (also in v3). It became the prototype of the row, so a JSON value in it, for instance from a column alias built from user input, made the row inherit its properties (row.isAdmin), in query results and in sql.subscribe rows alike.

    • New

      Scheduling across connections: when every connection is busy, a query is pipelined on the connection where it should be done soonest, from how long each statement took before and how long what is in flight has run, and slow queries are kept together once the rest of the pool is needed for quick ones. In simulations of mixed workloads, the p99 of quick queries fell 2 to 100 times; on PostgreSQL, a 1 ms lookup no longer waits behind a report on a busy pool (p99.9 from 792 ms to 5 ms). scheduler: false pipelines on the busy connection with the fewest queries in flight instead; v3 went round-robin over the busy connections. With max: 1 it is off, as there is only one connection.

    • New

      queue_timeout: seconds a query, transaction or reserve may wait for a connection before it rejects with QUEUE_TIMEOUT, unsent (#1036, #824).

  2. 3.4.9

    5 Apr 20261 fix
  3. 3.4.8

    6 Jan 20261 new · 3 fixes
    • New

      Add support for sslnegotiation=direct - fixes #1104 7f80980

    • Fixed

      Prevent out of bound errors from commit-time failures de64f7a

    • Fixed

      Use lower max connections in Cloudflare Workers environment 94b7170

    • Fixed

      Fix PGAPPNAME env access by prioritizing connection.application_name 32feb25

  4. 3.4.7

    21 May 20251 fix
    • Fixed

      Fix reserved queries failing on connect e34826d

  5. 3.4.6

    20 May 20251 new · 4 fixes
    • New

      Support env.PGAPPNAME and env.PGUSERNAME ef7afdb 9f38ea1

    • Fixed

      Fix failures in sql.reserve() connect shadowing real errors e8bb3b8

    • Fixed

      Fix stuck queries on non busy connections 76c13f2

    • Fixed

      Ensure non object errors thrown are handled properly a39dfef

    • Fixed

      Fixed typings for generic error code variants ad0ed44

  6. 3.4.5

    Migration needed25 Oct 20242 fixes
    • Breaking

      Remove "worker" export as we now have "workerd" for cloudflare cc688c6

    • Fixed

      Fix for deno 2 5fb70c1

    • Fixed

      Don't reassign to errors 4baef5e, f58cd4f

  7. 3.4.4

    21 Mar 20241 new · 1 fix
    • New

      Add subscribe onerror handler 3e3d5e8

    • Fixed

      Ensure retryRoutines are only used for prepared statements - fixes #830 3e28f3a

  8. 3.4.3

    2 Nov 20231 fix
    • Fixed

      Ensure reserved connections are initialized properly - fixes #718 c084a1c

62 other lines we could not sort, mostly version bumps
  • The server decides the type of every parameter (infer: false by default) (#392). v3 typed a Date as timestamptz, a boolean, a Buffer, a bigint and arrays of these from JavaScript; v4 sends them without a type and writes each value for the type the server asks for, as libpq does. timestamptz columns, values written to a column of their own type, strings, numbers and anything cast work as before. Outside UTC, a Date written to or compared with a timestamp or date column is taken as UTC instead of the session's local time, and a timestamp is read as UTC, so it comes back as the instant that was written whatever the time zone. A Date where the query doesn't decide its type, such as in date_trunc('day', ${ date }), needs a cast (${ date }::timestamptz). infer: true keeps v3's behaviour.

    4.0.0
  • Runtimes. Node.js 20 or later, Bun, and Cloudflare Workers; Deno through its Node.js compatibility. The CommonJS and Deno builds are gone: Postgres.js is an ES module, which require can load on Node.js 20.19 and 22.12 and later (require('postgres').default).

    4.0.0
  • sql.array() is removed. Pass the array as it is, with a cast where the query doesn't decide its type: ${ ids }::int. Calling sql.array() throws ARRAY_REMOVED.

    4.0.0
  • A transaction the server rolled back rejects. When the server answers COMMIT with ROLLBACK, sql.begin rejects with TRANSACTION_ROLLED_BACK; v3 took it as a commit.

    4.0.0
  • A released connection stays released. A query on a reserved sql after release(), or on a transaction's sql after it has committed or rolled back, rejects; v3 ran it on whatever connection it then had. Releasing a reserved connection while its own BEGIN is still open closes it instead of returning an open transaction to the pool.

    4.0.0
  • An unsafe begin outside sql.begin, a reserved connection or max: 1 rejects with UNSAFE_TRANSACTION and is rolled back. A query that looks like it may open a transaction runs alone on its connection, so nothing else lands in it, and any query that leaves its connection in a transaction is rolled back and rejected. v3 rejected BEGIN but left the transaction open. A script that opens and closes its own transaction in one query, such as a migration file with BEGIN and COMMIT, runs; v3 ran it and still rejected it.

    4.0.0
  • A query that cannot be built or serialized inside a transaction aborts the transaction, in sql.begin (#1236, #1238) or one opened by hand on a reserved connection, just as a server error would: the queries after it fail with 25P02 and a later COMMIT answers ROLLBACK. v3 skipped the query and let the rest commit.

    4.0.0
  • Domains that exist when the pool starts are read and written as their base type, so a domain over int comes back as an array of numbers; v3 returned the text.

    4.0.0
  • A connection refused for too many connections (53300) is retried with backoff until connect_timeout has passed, and the waiting queries reject with that error only then. Such a refusal is often momentary: connections opened at the same time against a connection limit can all be refused while the server counts them. v3 rejected the queries of the refused connection at once.

    4.0.0
  • No host matching target_session_attrs rejects with CONNECTION_DESTROYED instead of retrying forever.

    4.0.0

6 internal lines (docs, tests, tooling) left out.

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.