157 Commits

Author SHA1 Message Date
Brian Carlson
ee302cbcf1 Publish
- pg-cursor@2.9.0
 - pg-pool@3.6.0
 - pg-query-stream@4.4.0
 - pg@8.10.0
2023-03-06 14:18:02 -06:00
Cody Greene
5703791640
fix: double client.end() hang (#2717)
* fix: double client.end() hang

fixes https://github.com/brianc/node-postgres/issues/2716

`client.end()` will resolve early if the connection is already dead,
rather than waiting for an "end" event that will never arrive.

* fix: client.end() resolves when socket is fully closed
2023-03-06 12:10:07 -06:00
Brian Carlson
20a243e8b3 Publish
- pg-cursor@2.8.0
 - pg-protocol@1.6.0
 - pg-query-stream@4.3.0
 - pg@8.9.0
2023-01-27 09:12:49 -06:00
Brian Carlson
5bdc61a33d Remove expired sponsors 2023-01-27 09:11:05 -06:00
Sehrope Sarkuni
bb8745b215
Fix SASL to bubble up errors, enable SASL tests in CI, and add informative empty SASL password message (#2901)
* Enable SASL tests in GitHub actions CI

* Add SASL test to ensure that client password is a string

* Fix SASL error handling to emit and bubble up errors

* Add informative error when SASL password is empty string
2023-01-23 10:03:51 -08:00
Ruy Adorno
f82f39c20c
Add support to stream factory (#2898)
This changeset enables declaring the `stream` config value as a factory
method. Providing a much more flexible control of the socket connection.

Defining a custom `stream` config value allows the postgres driver to
support a larger variety of environments/setups such as proxy servers
and secure socket connections that are used by cloud providers such as
GCP.

Currently, usage of the `stream` config value is only viable for single
connections given that it's only possible to define a single socket
stream instance per new Client/Pool instance. By adding support to a
factory function, it becomes possible to enable usage of custom socket
streams for connection pools.

For reference, see the `mysql2` driver for MySQL (linked below) for
prior art example of this pattern.

Refs: ba15fe2570/lib/connection.js (L63-L65)
Refs: https://cloud.google.com/sql/docs/postgres/connect-overview
Signed-off-by: Ruy Adorno <ruyadorno@google.com>

Signed-off-by: Ruy Adorno <ruyadorno@google.com>
2023-01-23 10:02:39 -08:00
Frazer Smith
15b502d4c1
refactor(pg): remove unused imports (#2854) 2022-11-05 18:26:42 -07:00
Knut Olav Løite
406f141a1a
perf: remove superfluous flush message (#2842) 2022-10-15 12:57:16 -05:00
David Matějka
9dfb3dccbf
perf(pg): use native crypto.pbkdf2Sync in sasl auth (#2815) 2022-09-27 05:38:28 -05:00
Brian Carlson
c99fb2c127 Publish
- pg-cursor@2.7.4
 - pg-pool@3.5.2
 - pg-query-stream@4.2.4
 - pg@8.8.0
2022-08-23 11:36:18 -05:00
Brian C
747485d342
Bump min version of pg-native (#2787)
Fixes 2786
2022-08-22 15:34:07 -05:00
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
28ac2a17bc
Add test for how to set search path (#2700)
Also refactor a few tests a bit to slowly clean up some of the old style.
2022-05-12 22:00:00 -05:00
dependabot[bot]
b812ec1e65
Bump async from 0.9.0 to 2.6.4 (#2736)
Bumps [async](https://github.com/caolan/async) from 0.9.0 to 2.6.4.
- [Release notes](https://github.com/caolan/async/releases)
- [Changelog](https://github.com/caolan/async/blob/v2.6.4/CHANGELOG.md)
- [Commits](https://github.com/caolan/async/compare/0.9.0...v2.6.4)

---
updated-dependencies:
- dependency-name: async
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-11 23:41:05 -05:00
Brian C
4b4d97b8f3
Remove stream-tester (#2743)
* Remove stream-tester

* Use random port for network-partition tests

* Use random port for connection timeout test

* Bump CI version
2022-05-10 14:49:22 -05:00
Lars Hvam
f5e87ac0b1
pg: update README, remove dead badge (#2719) 2022-04-01 11:31:45 -05:00
Brian Carlson
4fa7ee891a Publish
- pg-cursor@2.7.3
 - pg-pool@3.5.1
 - pg-query-stream@4.2.3
 - pg@8.7.3
2022-02-04 10:28:01 -06:00
Brian Carlson
6849cc6868 Publish
- pg-cursor@2.7.2
 - pg-pool@3.5.0
 - pg-query-stream@4.2.2
 - pg@8.7.2
2022-02-04 10:21:57 -06:00
Brian C
3aba3794cf
Use github actions for CI (#2654)
This is the initial port to github actions.  Still pending are the SSL and client SSL cert tests which are currently being skipped. But perfect is the enemy of the good here, and having no CI because travis-ci keeps not working is unacceptable.
2021-11-17 10:02:22 -06:00
Brian M. Carlson
92b4d37926 Publish
- pg-cursor@2.7.1
 - pg-pool@3.4.1
 - pg-query-stream@4.2.1
 - pg@8.7.1
2021-07-27 17:33:19 -05:00
Brian C
86d31a6fad
Only call client.ref if it exists
* Only call client.ref if it exists. Fixes #2582

* Make test requiring port less flakey

* Bump port range

Fixes #2582
Fixes #2584
2021-07-27 17:27:05 -05:00
Brian M. Carlson
f3b0ee4c09 Publish
- pg-cursor@2.7.0
 - pg-pool@3.4.0
 - pg-query-stream@4.2.0
 - pg@8.7.0
2021-07-27 12:41:17 -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
Brian M. Carlson
d459479382 Publish
- pg-connection-string@2.5.0
 - pg-cursor@2.6.0
 - pg-pool@3.3.0
 - pg-protocol@1.5.0
 - pg-query-stream@4.1.0
 - pg@8.6.0
2021-04-13 11:02:40 -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
Emily Marigold Klassen
5a41a56862
Add missing metadata to package.jsons (#2487)
Co-authored-by: Emily Marigold Klassen <forivall@users.noreply.github.com>
2021-03-12 08:23:13 -06:00
Brian C
daeafe82b4
Make tests pass in github codespaces (#2437)
* Make tests pass in github codespaces

There were a few tests which didn't specify a host or port which wasn't working well inside the codespaces docker environment.  Added host & port where required.  Also noticed one test wasn't actually _testing_, it was just `console.log`-ing its output, so I added proper assertions there.  Finally set `PGTESTNOSSL: true` in the codespaces environment until I can get the postgres docker container configured w/ SSL...which I will do l8r.

* lint
2020-12-30 04:20:20 -06: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 M. Carlson
5de36c7f7f Update sponsors & readme 2020-11-30 10:57:40 -06:00
Brian M. Carlson
0b9bb349dc Publish
- pg-cursor@2.5.1
 - pg-query-stream@3.4.2
 - pg@8.5.1
2020-11-13 08:59:48 -06:00
Brian C
ebe412cf24
Support "true" as string for ssl (#2407)
Fixes 2406
2020-11-11 10:41:20 -06:00
Brian M. Carlson
ec1dcab966 Publish
- pg-cursor@2.5.0
 - pg-protocol@1.4.0
 - pg-query-stream@3.4.0
 - pg@8.5.0
2020-11-10 11:01:03 -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
Charmander
8bed670aee Add more error handling to error handling tests 2020-11-05 23:19:59 -08: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
Brian M. Carlson
b6d69d5bc2 Publish
- pg-cursor@2.4.2
 - pg-pool@3.2.2
 - pg-query-stream@3.3.2
 - pg@8.4.2
2020-10-26 12:19:03 -05:00
Lewis Cowles
e82137e6d3 Tests 2020-10-20 12:53:25 -05: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
36342c9a84 Publish
- pg-cursor@2.4.1
 - pg-query-stream@3.3.1
 - pg@8.4.1
2020-10-08 15:53:16 -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