69 Commits

Author SHA1 Message Date
Martin Kubliniak
3e53d06cd8
Support lock_timeout (#2779) 2022-08-10 16:15:06 -05:00
Peter Rust
68160a29bd
Fix #2556 by keeping callback errors from interfering with cleanup (#2753)
* Fix #2556 (handleRowDescription of null) by keeping callback errors from interfering with cleanup

* Added regression test for #2556
2022-06-20 08:25:12 -05:00
Brian C
779803fbce
Add ref/unref noop to native client (#2581)
* Add ref/unref noop to native client

* Use promise.catch in test

* Make partition test not flake on old node

* Fix test flake on old node
2021-07-27 12:23:30 -05:00
Brian Crowell
684cd09bce
Allow Node to exit if the pool is idle (#2568)
Based on the suggestion from #2078. This adds ref/unref methods to the
Connection and Client classes and then uses them to allow the process to
exit if all of the connections in the pool are idle. This behavior is
controlled by the allowExitOnIdle flag to the Pool constructor; it defaults
to the old behavior.
2021-07-27 11:29:07 -05:00
Juan M Martínez
3dc79b605c
util in connection not used (#2507) 2021-04-02 22:37:39 +00:00
Kannan Goundan
4b229275cf
pg: Re-export DatabaseError from 'pg-protocol' (#2445)
* pg: Re-export DatabaseError from 'pg-protocol'

Before, users would have to import DatabaseError from 'pg-protocol'.  If
there are multiple versions of 'pg-protocol', you might end up using the
wrong one.

Closes #2378

* Update error-handling-tests.js

* Update query-error-handling-tests.js

Co-authored-by: Brian C <brian.m.carlson@gmail.com>
2021-03-22 13:07:05 -05:00
Sehrope Sarkuni
a109e8c6d2
Add more SASL validation and fix tests (#2436)
* Add sha256 SASL helper

* Rename internal createHMAC(...) to hmacSha256(...)

* Add parseAttributePairs(...) helper for SASL

* Tighten arg checks in SASL xorBuffers(...)

* Add SASL nonce check for printable chars

* Add SASL server salt and server signature base64 validation

* Add check for non-empty SASL server nonce

* Rename SASL helper to parseServerFirstMessage(...)

* Add parameter validation to SASL continueSession(...)

* Split out SASL final message parsing into parseServerFinalMessage(...)

* Fix SCRAM tests

Removes custom assert.throws(...) so that the real one from the assert package is used and
fixes the SCRAM tests to reflect the updated error messages and actual checking of errors.

Previously the custom assert.throws(...) was ignoring the error signature validation.
2020-12-30 04:19:27 -06:00
Brian C
ebe412cf24
Support "true" as string for ssl (#2407)
Fixes 2406
2020-11-11 10:41:20 -06:00
Charmander
0012a43d95
Forward options’ ssl.key even when non-enumerable (#2394)
* Test client certificate authentication

* Forward options’ ssl.key even when non-enumerable
2020-11-09 11:30:40 -06:00
Brian C
07988f985a
Speed up bind functionality (#2286)
Move from 3 loops (prepareValue, check for buffers, write param types, write param values) to a single loop. This speeds up the insert benchmark by around 100 queries per second. Performance improvement depends on number of parameters being bound.
2020-11-04 08:27:40 -06:00
Casey Foster
415bf09041 Remove console.error on pg-native module not found 2020-11-02 10:33:55 -06:00
Lewis Cowles
fd2c3563a5 Security: simplify defineProperty non-enumerables
* `password` already has this set, but was a little long considering we only want to override default of one property
* `ssl.key` was showing up in tracebacks
2020-10-20 12:53:25 -05:00
Brian M. Carlson
d8681fc2cd Comments & cleanup 2020-10-08 15:17:34 -05:00
Brian M. Carlson
dd3ce616d0 Fixes based on postgres maintainer advice 2020-10-08 15:17:34 -05:00
Brian M. Carlson
d31486fb7c Change when sync is sent during pipelining 2020-10-08 15:17:34 -05:00
Brian M. Carlson
b45051d72a Update comments 2020-10-08 15:17:34 -05:00
Brian M. Carlson
f55d879c52 Apply fix 2020-10-08 15:17:34 -05:00
Brian M. Carlson
17e7e9ed3d Remove fix to fail tests 2020-10-08 15:17:34 -05:00
Brian M. Carlson
9c678e108c Fix double-sync crash on postgres 9.x 2020-10-08 15:17:34 -05:00
Bogdan Chadkin
a02dfac5ad Replace semver with optional peer dependencies
See example bb74168c95/package.json (L42-L49)

This feature is supported by both npm and yarn.
2020-10-04 13:35:16 -05:00
Pimm "de Chinchilla" Hogeling
0758b766aa Fix context (this) in _checkPgPass. 2020-08-26 15:58:37 -05:00
Christopher Young
f4d123b09e Prevents bad ssl credentials from causing a crash
Fixes: https://github.com/brianc/node-postgres/issues/2307
Fixes: https://github.com/brianc/node-postgres/issues/2004
2020-08-12 07:22:34 -07:00
Charmander
1b022f8c5f Remove accidentally duplicated methods
Fixes #2293.
2020-07-26 10:30:01 -07:00
Brian C
8291b233b8
Merge pull request #2277 from brianc/bmc/remove-comments
Remove out of date unneeded copyright / license comments
2020-07-16 09:58:20 -05:00
Brian M. Carlson
9ba4ebb803 Fix SASL again 2020-07-15 13:53:12 -05:00
Brian M. Carlson
66d32c6f3f Fix more SASL. Thank God for tests. 2020-07-15 13:38:34 -05:00
Brian M. Carlson
fdf13bac34 Fix msg not being passed for SASL 2020-07-15 13:30:25 -05:00
Brian M. Carlson
5425bc15d2 Fix untested pgpass code 2020-07-15 13:19:45 -05:00
Brian M. Carlson
966278a5cc Instance bound methods are not supported in node 8 2020-07-15 12:59:10 -05:00
Brian M. Carlson
9bf31060e1 Cleanup some dead code 2020-07-15 12:22:13 -05:00
Brian M. Carlson
5ba7e3fb48 Refactor connection to class 2020-07-15 11:49:54 -05:00
Brian M. Carlson
9d1dce9c5d Mark handler methods as 'private' 2020-07-15 11:42:33 -05:00
Brian M. Carlson
63e15d15fa Refactor 2020-07-15 11:31:16 -05:00
Brian M. Carlson
0b424cfff1 Move more functionality to methods 2020-07-15 11:16:46 -05:00
Brian M. Carlson
66e1e76c9b More refactoring 2020-07-15 11:05:31 -05:00
Brian M. Carlson
04e5297d2e Convert more things to ES6 classes 2020-07-15 10:33:33 -05:00
Brian M. Carlson
80d07c489f Remove out of date unneeded copyright / license comments 2020-07-15 10:01:26 -05:00
Brian C
da5d4efef4
Merge pull request #2216 from rafiss/pgoptions
Support options connection parameter
2020-07-08 12:16:03 -05:00
Brian M. Carlson
a79c8e7992 Send sync after flush 2020-05-15 17:51:09 -05:00
Rafi Shamim
06cdf3e9f0 Support options connection parameter
This supports the connection parameter documented here:
https://www.postgresql.org/docs/9.1/libpq-connect.html#LIBPQ-CONNECT-OPTIONS
2020-05-14 10:07:35 -04:00
Brian M. Carlson
08afb12dcc Set noDelay to true 2020-05-12 16:32:40 -05:00
Brian M. Carlson
520bd35319 Switch internals to use faster connection
This switches the internals to use faster protocol parsing & serializing.  This results in a significant (30% - 50%) speed up in some common query patterns.  There is quite a bit more performance work I need to do, but this takes care of some initial stuff & removes a big fork in the code.
2020-05-12 10:56:14 -05:00
Brian M. Carlson
7929f6ae44 Make change less invasive and fully backwards compatible for native binding config 2020-05-07 11:36:39 -05:00
Brian M. Carlson
e9073f5a00 Cleanup & comments 2020-05-05 11:03:29 -05:00
Brian M. Carlson
b89eb0f81d Write tests & unify treatment of no-verify 2020-05-05 10:58:34 -05:00
Brian M. Carlson
d8c7005115 Merge branch 'bhsj/noverify' of https://github.com/benhjames/node-postgres into benhjames-bhsj/noverify 2020-05-05 10:35:46 -05:00
Brian M. Carlson
9e11004e8a No need to import from dist 2020-05-05 09:53:56 -05:00
Brian M. Carlson
3a2af0f52c Fix relative path import
Closes #2188
2020-05-05 09:50:53 -05:00
Ben Salili-James
6937a2428b Add PGSSLMODE=noverify support to opt-out of rejecting self-signed certs 2020-05-05 13:24:11 +01:00
Charmander
149f482324 Replace uses of private/undocumented readyState API
The `readyState` of a newly-created `net.Socket` changed from `'closed'` to `'open'` in Node 14.0.0, so this makes the JS driver work on Node 14.

`Connection` now always calls `connect` on its `stream` when `connect` is called on it.
2020-04-21 23:20:48 -07:00