Packages

postgres

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

Upgrading postgres From 3.3.4 to 4.1.1

14 releases in betweenevery note read

Reading releases, release notes and advisories…

Other targets from 3.3.4Newest 3.x3.4.9
  1. 3.3.4yours
  2. 6 releases
  3. 3.4.5breaking
  4. 4 releases
  5. 4.0.0security
  6. 1 release
  7. 4.1.1target

Before you upgrade

Tick each one off as you go
  • Breaking3.4.5

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.1.1

    11 Nov 20268 fixes
    • Fixed

      A statement sql.begin sends after its own COMMIT or ROLLBACK is rejected (#1320). A statement the callback did not await, sent between the transaction's COMMIT or ROLLBACK and the release of its connection, ran outside the transaction, and after a rollback its write was kept. It now rejects with UNSAFE_TRANSACTION, as a statement after the transaction has ended does.

    • Fixed

      A command after a select in a multi-statement simple query has no columns (#1321). In sql.unsafe('select …; rollback') the ROLLBACK result had the columns of the SELECT before it.

    • Fixed

      A query queued behind one with an untyped string or boolean parameter resolves on Cloudflare Hyperdrive (#1319). Such a query is described first, and 4.1.0 sent its Bind, Execute and Sync together with the next query, which never resolved through Hyperdrive. On Cloudflare Workers the next query now waits until the described one is done, as in 3.4.9. Other runtimes still pipeline it.

    • Fixed

      .cursor() yields the rows of SHOW, EXPLAIN and other commands without a row count. Their last batch was only passed on when the command tag had a count, so a cursor over them yielded nothing.

  2. 4.1.0

    5 Nov 202614 new · 15 fixes
    • New

      query_timeout (#1278). Seconds a query may take, waiting for a connection and running together, before it is canceled and rejects with QUERY_TIMEOUT. Off by default. Unlike statement_timeout it also ends a query whose server or network has gone silent, which TCP alone takes many minutes to notice. Transaction control queries and forEach are limited too; cursors, streams and sql.listen are not.

    • New

      cancel_timeout, 5 seconds by default: how long a canceled query may take to end before its connection is closed.

    • New

      sql.batch([queries]) sends queries in one round trip with a single Sync: outside a transaction they commit or roll back together, and the batch rejects with the failing query's position in error.index.

    • New

      json on a transform (#1169). The built-in transforms rename the keys of JSON values in results but send JSON values as they are. json: false leaves JSON values as they are both ways, and json: true renames their keys when sending too, with the transform's column.to. Without it nothing changes.

  3. 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).

  4. 3.4.9

    5 Apr 20261 fix
  5. 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

  6. 3.4.7

    21 May 20251 fix
    • Fixed

      Fix reserved queries failing on connect e34826d

  7. 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

  8. 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

25 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.