All major and minor releases are briefly explained below.
For richer information consult the commit log on github with referenced pull requests.
We do not include break-fix version release in this file.
- Add
queryMode
config option to force use of the extended query protocol on queries without any parameters.
- Emit
release
event when client is returned to the pool.
- Add support for stream factory.
- Better errors for SASL authentication.
- Use native crypto module for SASL authentication.
- Bump minimum required version of native bindings.
- Catch previously uncatchable errors thrown in
pool.query
. - Prevent the pool from blocking the event loop if all clients are idle (and
allowExitOnIdle
is enabled). - Support
lock_timeout
in client config. - Fix errors thrown in callbacks from interfering with cleanup.
- Add connection lifetime limit config option.
- Add optional config to pool to allow process to exit if pool is idle.
- Convert to es6 class
- Add support for promises to cursor methods
- Better SASL error messages & more validation on bad configuration.
- Export DatabaseError.
- Add ParameterDescription support to protocol parsing.
- Fix typescript typedefs with
--isolatedModules
.
- Library has been converted to Typescript. The behavior is identical, but there could be subtle breaking changes due to class names changing or other small inconsistencies introduced by the conversion.
- Fix bug forwarding ssl key.
- Convert pg-query-stream internals to typescript.
- Performance improvements.
- Switch to optional peer dependencies & remove semver package which has been a small thorn in the side of a few users.
- Export
DatabaseError
from pg-protocol. - Add support for
sslmode
in the connection string.
- Support passing a string of command line options flags via the
{ options: string }
field on client/pool config.
- Switch internal protocol parser & serializer to pg-protocol. The change is backwards compatible but results in a significant performance improvement across the board, with some queries as much as 50% faster. This is the first work to land in an on-going performance improvement initiative I'm working on. Stay tuned as things are set to get much faster still! 🚀
- Switch internal protocol parser & serializer to pg-protocol. The change is backwards compatible but results in a significant performance improvement across the board, with some queries as much as 50% faster.
- Switch internal protocol parser & serializer to pg-protocol. The change is backwards compatible but results in a significant performance improvement across the board, with some queries as much as 50% faster.
- Switch to using monorepo version of
pg-connection-string
. This includes better support for SSL argument parsing from connection strings and ensures continuity of support. - Add
&ssl=no-verify
option to connection string andPGSSLMODE=no-verify
environment variable support for the pure JS driver. This is equivalent of passing{ ssl: { rejectUnauthorized: false } }
to the client/pool constructor. The advantage of having support in connection strings and environment variables is it can be "externally" configured via environment variables and CLI arguments much more easily, and should remove the need to directly edit any application code for the SSL default changes in 8.0. This should make using[email protected]
significantly less difficult on environments like Heroku for example.
- Same changes to
pg
impactpg-pool
as they both use the same connection parameter and connection string parsing code for configuring SSL.
- Add maxUses config option.
note: for detailed release notes please check here
- Remove versions of node older than
6 lts
from the test matrix.pg>=8.0
may still work on older versions but it is no longer officially supported. - Change default behavior when not specifying
rejectUnauthorized
with the SSL connection parameters. Previously we defaulted torejectUnauthorized: false
when it was not specifically included. We now default torejectUnauthorized: true.
Manually specify{ ssl: { rejectUnauthorized: false } }
for old behavior. - Change default database when not specified to use the
user
config option if available. Previouslyprocess.env.USER
was used. - Change
pg.Pool
andpg.Query
to be an es6 class. - Make
pg.native
non enumerable. notice
messages are no longer instances ofError
.- Passwords no longer show up when instances of clients or pools are logged.
- This will likely be the last minor release before [email protected].
- This version contains a few bug fixes and adds a deprecation warning for a pending change in 8.0 which will flip the default behavior over SSL from
rejectUnauthorized
fromfalse
totrue
making things more secure in the general use case.
- Rewrote stream internals to better conform to node stream semantics. This should make pg-query-stream much better at respecting highWaterMark and getting rid of some edge case bugs when using pg-query-stream as an async iterator. Due to the size and nature of this change (effectively a full re-write) it's safest to bump the semver major here, though almost all tests remain untouched and still passing, which brings us to a breaking change to the API....
- Changed
stream.close
tostream.destroy
which is the official way to terminate a readable stream. This is a breaking change if you rely on thestream.close
method on pg-query-stream...though should be just a find/replace type operation to upgrade as the semantics remain very similar (not exactly the same, since internals are rewritten, but more in line with how streams are "supposed" to behave). - Unified the
config.batchSize
andconfig.highWaterMark
to both do the same thing: control how many rows are buffered in memory. TheReadableStream
will manage exactly how many rows are requested from the cursor at a time. This should give better out of the box performance and help with efficient async iteration.
- Add support for
idle_in_transaction_session_timeout
option.
- Add optional, opt-in behavior to test new, faster query pipeline. This is experimental, and not documented yet. The pipeline changes will grow significantly after the 8.0 release.
- Change repository structure to support lerna & future monorepo development.
- Warn about deprecation for calling constructors without
new
.
- Reverts 7.13.0 as it contained an accidental breaking change for self-signed SSL cert verification. 7.14.0 is identical to 7.12.1.
- Add support for all tls.connect() options.
- Add support for async password lookup.
- Add support for connection_timeout and keepalives_idle.
- Add support for per-query types.
- Add support for sasl/scram authentication.
- Add support for passing secureOptions SSL config.
- Upgrade pg-types to 2.0.
- Add support for configurable query timeout on a client level.
- Add support for "bring your own promise"
- Better error message when passing
null
orundefined
toclient.query
. - Better error handling on queued queries.
- Add support for Uint8Array values.
- Add support for statement timeout.
- Pinned pg-pool and pg-types to a tighter semver range. This is likely not a noticeable change for you unless you were specifically installing older versions of those libraries for some reason, but making it a minor bump here just in case it could cause any confusion.
- Drop support for node <
4.x
. - Remove
pg.connect
pg.end
andpg.cancel
singleton methods. Client#connect(callback)
now returnsundefined
. It used to return an event emitter.- Upgrade pg-pool to
2.x
. - Upgrade pg-native to
2.x
. - Standardize error message fields between JS and native driver. The only breaking changes were in the native driver as its field names were brought into alignment with the existing JS driver field names.
- Result from multi-statement text queries such as
SELECT 1; SELECT 2;
are now returned as an array of results instead of a single result with 1 array containing rows from both queries.
Please see here for a migration guide
- Overhauled documentation: https://node-postgres.com.
- Add
Client#connect() => Promise<void>
andClient#end() => Promise<void>
calls. Promises are now returned from all async methods on clients if and only if no callback was supplied to the method. - Add
connectionTimeoutMillis
to pg-pool.
- Add support for parsing
replicationStart
messages.
- Add optional callback parameter to the pure JavaScript
client.end
method. The native client already supported this.
- Remove
pg.pools
. There is still a reference kept to the pools created & tracked bypg.connect
but it has been renamed, is considered private, and should not be used. Accessing this API directly was uncommon and was supposed to be private but was incorrectly documented on the wiki. Therefore, it is a breaking change of an (unintentionally) public interface to remove it by renaming it & making it private. Eventuallypg.connect
itself will be deprecated in favor of instantiating pools directly vianew pg.Pool()
so this property should become completely moot at some point. In the mean time...check out the new features...
- Replace internal pooling code with pg-pool. This is the first step in eventually deprecating and removing the singleton
pg.connect
. The pg-pool constructor is exported from node-postgres atrequire('pg').Pool
. It provides a backwards compatible interface withpg.connect
as well as a promise based interface & additional niceties.
You can now create an instance of a pool and don't have to rely on the pg
singleton for anything:
var pg = require('pg')
var pool = new pg.Pool()
// your friendly neighborhood pool interface, without the singleton
pool.connect(function(err, client, done) {
// ...
})
Promise support & other goodness lives now in pg-pool.
Please read the readme at pg-pool for the full api.
- Included support for tcp keep alive. Enable it as follows:
var client = new Client({ keepAlive: true })
This should help with backends incorrectly considering idle clients to be dead and prematurely disconnecting them.
- Make the query object returned from
client.query
implement the promise interface. This is the first step towards promisifying more of the node-postgres api.
Example:
var client = new Client()
client.connect()
client.query('SELECT $1::text as name', ['brianc']).then(function (res) {
console.log('hello from', res.rows[0])
client.end()
})
require('pg').native
now returns null if the native bindings cannot be found; previously, this threw an exception.
- better error message when passing
undefined
as a query parameter - support for
defaults.connectionString
- support for
returnToHead
being passed to generic pool
- Add option to parse JS date objects in query parameters as UTC
- Warn to
stderr
if a named query exceeds 63 characters which is the max length supported by postgres.
- Unpin
pg-types
semver. Allow it to float against[email protected]
.
- Support for additional error fields in postgres >= 9.3 if available.
- Allow type parser overrides on a per-client basis
- Make native bindings an optional install with
npm install pg-native
- No longer surround query result callback with
try/catch
block. - Remove built in COPY IN / COPY OUT support - better implementations provided by pg-copy-streams and pg-native
- Include support for (parsing JSONB)[brianc/node-pg-types#13] (supported in postgres 9.4)
- Include support for parsing boolean arrays
- Include port as connection parameter to unix sockets
- Better support for odd date parsing
- Add support for parsing date arrays
- Expose array parsers on pg.types
- Allow pool to be configured
- Add count of the number of times a client has been checked out from the pool
- Emit
end
frompg
object when a pool is drained
After some discussion it was decided node-postgres was non-compliant in how it was handling DATE results. They were being converted to UTC, but the PostgreSQL documentation specifies they should be returned in the client timezone. This is a breaking change, and if you use the date
type you might want to examine your code and make sure nothing is impacted.
[email protected] included changes to not convert large integers into their JavaScript number representation because of possibility for numeric precision loss. The same types in arrays were not taken into account. This fix applies the same type of type-coercion rules to arrays of those types, so there will be no more possible numeric loss on an array of very large int8s for example. This is a breaking change because now a return type from a query of int8[]
will contain string representations
of the integers. Use your favorite JavaScript bignum module to represent them without precision loss, or punch over the type converter to return the old style arrays again.
Single date
parameters were properly sent to the PostgreSQL server properly in local time, but an input array of dates was being changed into utc dates. This is a violation of what PostgreSQL expects. Small breaking change, but none-the-less something you should check out if you are inserting an array of dates.
This is a small change to bring the semantics of query more in line with other EventEmitters. The tests all passed after this change, but I suppose it could still be a breaking change in certain use cases. If you are doing clever things with the end
and error
events of a query object you might want to check to make sure its still behaving normally, though it is most likely not an issue.
The long & short of it is now any object you supply in the list of query values will be inspected for a .toPostgres
method. If the method is present it will be called and its result used as the raw text value sent to PostgreSQL for that value. This allows the same type of custom type coercion on query parameters as was previously afforded to query result values.
If domains are active node-postgres will honor them and do everything it can to ensure all callbacks are properly fired in the active domain. If you have tried to use domains with node-postgres (or many other modules which pool long lived event emitters) you may have run into an issue where the active domain changes before and after a callback. This has been a longstanding footgun within node-postgres and I am happy to get it fixed.
Avoids a scenario where your pool could fill up with disconnected & unusable clients.
To provide better documentation and a clearer explanation of how to override the query result parsing system we broke the type converters into their own module. There is still work around removing the 'global-ness' of the type converters so each query or connection can return types differently, but this is a good first step and allow a lot more obvious way to return int8 results as JavaScript numbers, for example
- Add support for application_name
- Add support for the password file
- Add better support for unix domain socket connections
- Add support for parsing JSON[] and UUID[] result types
- Use single row mode in native bindings when available [@rpedela]
- reduces memory consumption when handling row values in 'row' event
- Automatically bind buffer type parameters as binary [@eugeneware]
- Respect PGSSLMODE environment variable
- Ability to opt-in to int8 parsing via
pg.defaults.parseInt8 = true
- Use eval in the result set parser to increase performance
- Remove built-in support for binary Int64 parsing. Due to the low usage & required compiled dependency this will be pushed into a 3rd party add-on
- Add support for SSL connections in JavaScript driver
- this means you can connect to heroku postgres from your local machine without the native bindings!
- Add field metadata to result object
- Add ability for rows to be returned as arrays instead of objects
- Properly handle various PostgreSQL to JavaScript type conversions to avoid data loss:
PostgreSQL | [email protected] JavaScript | [email protected] JavaScript
--------------------------------|----------------
float4 | number (float) | string
float8 | number (float) | string
int8 | string | number (int)
numeric | string | number (float)
decimal | string | number (float)
For more information see brianc#353 If you are unhappy with these changes you can always override the built in type parsing fairly easily.
- Make client_encoding configurable and optional
- return field metadata on result object: access via result.fields[i].name/dataTypeID
- built in support for
JSON
data type for PostgreSQL Server @ v9.2.0 or greater
- remove deprecated functionality
- Callback function passed to
pg.connect
now requires 3 arguments - Client#pauseDrain() / Client#resumeDrain removed
- numeric, decimal, and float data types no longer parsed into float before being returned. Will be returned from query results as
String
- Callback function passed to
- client now emits
end
when disconnected from back-end server - if client is disconnected in the middle of a query, query receives an error
- add deprecation warnings in prep for v1.0
- fix read/write failures in native module under node v0.9.x