Commit Graph

648 Commits

Author SHA1 Message Date
Raul Marin
b5be2ee38c Remove deprecation warnings 2018-05-23 18:04:20 +02:00
Raul Marin
389c25f44d Merge tag 'v6.4.2' into cdb-6.1
Bump version
2018-05-23 17:54:17 +02:00
Raul Ochoa
3eef52dd1e Merge tag 'v6.1.6' into cdb-6.1
Bump version
2017-08-13 12:01:19 +02:00
Brian M. Carlson
9bcf55dda9 Fix vulnerability 2017-08-12 16:31:32 -05:00
Brian M. Carlson
c0a381eab2 Fix vulnerability 2017-08-12 16:25:09 -05:00
2Pacalypse-
c2af53a24e Properly insert buffers in arrays.
Before this commit, when someone tried to insert a Buffer into an array,
the library would try to escape it (by calling the `escapeElement` on
it), which would fail because buffers don't have a `replace` method.
2017-07-13 22:24:52 -05:00
Eder Ávila Prado
860cccd531 fix for server enconding when using SQL_ASCII and latin1 enconding 2017-06-21 12:23:06 -05:00
Brian Carlson
e4469340ae Fix deprecation warnings in native driver 2017-06-20 09:28:44 -05:00
Brian C
842803c7ef Fix over-eager deprecation warnings (#1333)
* WIP

* Remove console.log messages
2017-06-20 08:59:07 -05:00
Brian M. Carlson
b5b49eb895 Add deprecations
This adds deprecations in preparation for `pg@7.0`

- deprecate using event emitters on automatically created results from client.query.
- deprecate query.promise() - it should never have been a public method and it's not documented. I need to do better about using _ prefix on private methods in the future.
- deprecate singleton pool on the `pg` object. `pg.connect`, `pg.end`, and `pg.cancel`.
2017-06-19 16:00:37 -05:00
Brian Carlson
76c59a01f2 Emit error when backend unexpectedly disconnects 2017-06-09 12:27:47 -05:00
Brian C
f2b87e02f1 Add client connectionString tests (#1310)
* Remove redundant tests

* Add client connectionString test

Add test to ensure { connectionString } is respected as an argument to the client constructor

* Add test for connection string property

Also fixed some legacy require statements.
2017-06-07 22:58:03 -05:00
Raul Ochoa
4cd56cc4f8 Make pool name consistent on missing config params (#1279)
* Going red: using a config object creates two pools when missing some params

It should only create a pool in a consistent way, even if some params
are not provided in the first place.

* Delay the pool name generation to make it consistent between calls

* Don't fallback to empty object as config is already defined
2017-05-24 09:04:50 -05:00
T.J. Schuck
e5f0e5d36a s/2016/2017/ (#1291) 2017-05-17 16:47:07 -05:00
Sehrope Sarkuni
ee8193673c Libpq connection string escaping (#1285)
* Fix escaping of libpq connection string properties

Fix handlings of libpq connection properties to properly escape single
quotes and backslashes. Previously the values were surrounded in single
quotes which handled whitespace within the property value, but internal
single quotes and backslashes would cause invalid connection strings to
be generated.

* Update expected output in test to be quoted

Update the expect host output in the connection parameter test
to expect it to be surrounded by single quotes.

* Add test for configs with quotes and backslashes
2017-05-15 12:19:13 -05:00
Kibae Shin
4f790deb73 Support for logical streaming replication (#1271)
* Support for logical streaming replication

* Wrong compare expr in getLibpqConnectionString

* Simplify codes for replication parameter
2017-04-24 13:24:30 -05:00
Ary Purnomoz
4505ae98d9 support ssl params for pg-native (#1169)
Make pg-native able to pass sslmode, sslca, sslkey and sslcert params to libpq
2017-04-19 09:55:56 -05:00
Magnus Hiie
197f86f90d Fix ECONNRESET error emitted after failed connect (#1230)
On Windows, after a connect attempt has failed, an error event with
ECONNRESET is emitted after the real connect error is propagated to the
connect callback, because the connection is not in ending state
(connection._ending) where ECONNRESET is ignored. This change ends the
connection when connect has failed.

This fixes #746.
2017-03-20 12:01:41 -05:00
Linus Unnebäck
ce8f215c88 Fix throw in type parsers when in prepared statement (#1242) 2017-03-09 15:05:26 -06:00
Linus Unnebäck
5cb38f5892 Handle throws in type parsers (#1218)
* Handle throws in type parsers

* Fix throw in type parsers test for Node 0.x
2017-03-06 11:04:16 -06:00
Charmander
41017814d3 Avoid infinite loop on malformed message (#1208)
* Avoid infinite loop on malformed message

If handling of such messages is deemed unimportant, `indexOf` is still faster (~40%) and cleaner than a manual loop.

Addresses #1048 to an extent.

* Use indexOf fallback for Node ≤0.12
2017-02-21 11:19:03 -06:00
Raul Ochoa
3c81aea432 Clean line end 2016-12-16 17:35:47 +00:00
Raul Ochoa
c0ce6bf019 Don't use __dirname 2016-12-16 17:35:38 +00:00
Raul Ochoa
8e7c659f33 Merge remote-tracking branch 'brianc/master' into cdb-6.1 2016-12-16 16:55:33 +00:00
Alexander Mochalin
f6c40b9331 parse int8[] (#1152)
* parse int8[]

* missing semicolon

* test

* test fixed

* test fixed

* test fixed. again.
2016-12-16 09:44:19 -06:00
Brian C
7f35240a5c Fix for utf-8 characters in md5 passwords (#1183)
This is the same fix as supplied in 1178 but includes a test.

Closes #1178
2016-12-13 11:51:36 -06:00
Charmander
981960b445 Remove confusing conditions (#1159)
* Remove unreachable code

* Remove redundant condition

Every path with `!this.values` results in `false` regardless of `this.binary`.
2016-12-13 07:50:07 -06:00
Charmander
5d821c3acb Use more correct escaping for array elements (#1177)
It’s not JSON.
2016-12-10 17:28:48 -06:00
Daniel García Aubert
27d9813114 Expose keep-alive connection param 2016-12-07 15:46:26 +01:00
Daniel García Aubert
fa8cfcaebf Emit message if the returned row is bigger than limit 2016-12-07 15:12:43 +01:00
Brian C
a536afb1a8 Add callback to client#end (#1106)
A long standing bug was the pure JS client didn't accept or call a callback on `client.end`.  This is inconsistent with both the documentation & general node patterns.

This fixes the issue & adds a test.  The issue did not exist in the native version of the client.
2016-08-11 10:17:03 -05:00
Brian C
b1b2801c71 Add onFailure to query#then (#1082)
The promise adapter I had implemented wasn't spec compliant: it didn't accept both `onSuccess` and `onFailure` in the call to `query#then`.  This subtly broke yield & async/await because they both rely on `onError` being passed into `Promise#then`.  The pool was also not returning the promise after a client was acquired, which broke awaiting on `pool.connect` - this is also fixed now.
2016-07-19 10:16:48 -05:00
guoxiangyang
33a1c35ad2 changed for self signed ssl support (#1072) 2016-07-10 16:26:36 -05:00
Illirik Smirnov
522d62229b Resolve merge conflict in PR #1041 (#1065)
* Add license comment

* Delete pool.js
2016-06-24 10:56:43 -05:00
Brian C
812277f99f Fix native constructor and pool exports (#1061) 2016-06-24 00:52:28 -05:00
brianc
406357b9c6 Better indication that pg.pools is a private api 2016-06-21 22:03:25 -05:00
Brian C
0aa62f2854 Make tcp-keepalive configurable (#1058) 2016-06-21 21:38:10 -05:00
Konstantin Petryaev
ad65c7b1bc Fix of pool leaking by TCP-keepalive (#918)
* fix of bug with pool leaking by TCP keep-alives

* add test for check setKeepAlive on connect

* fix mistake with var

* fix mistake with var
2016-06-21 14:49:41 -05:00
Brian C
796a44f54f Remove internal pool (#1049)
* Initial work on removing internal pool

* Port backwards-compabible properties

* Cleanup test execution & makefile cruft

* Attempt to fix flakey error test
2016-06-21 09:53:09 -05:00
Jos Kuijpers
1596a933eb Fix SSL configuration error and add tests. #848 (#1055) 2016-06-21 09:42:30 -05:00
Brian C
2fd9c77085 Make Query & NativeQuery implement the promise interface (#1047)
* Make Query & NativeQuery implement the promise interface

* Fix test

* Use older node API for checking listener length

* Do not test for promises on node@v0.10.0
2016-06-10 17:18:19 -05:00
Brian Dunavant
01e5d726da Support for defaults.connectionString (#910) 2016-06-07 16:09:22 -05:00
twisha16
90600f2b47 Adding returnToHead in clientConfig param (#1007) 2016-06-07 16:05:55 -05:00
Muhammad Raihan Muhaimin
667953fd5c Proper error message for undefined where options (#1022)
When user provides a knex select statement with an undefined options in where clause it is not properly handled an give an ambiguous error message telling `Unhandled rejection TypeError: Cannot read property 'toString' of undefined.` This PR will helpful to users at it will tell them the exact problem.
2016-06-07 16:04:52 -05:00
Pavel Lang
ad2ffce986 pg.native returns null if pg-native is missing (#950)
`require('pg').native` will be `null` and report error once to `stdout` when `pg-native` is missing.
2016-06-07 16:02:07 -05:00
Tristan Davies
55abbaa844 don't mutate params when preparing statement (#992) 2016-04-28 14:46:33 -05:00
Martynas Kunigėlis
6fddc566f0 Use Buffer concatenation for binary data instead of binary strings. Fixes Node.js v6.0.0 breakage. (#1001) 2016-04-27 13:52:28 -05:00
Martin Kuba
52aa25d8e8 added Client constructor back on pool to enable instrumentation (#998) 2016-04-26 17:41:11 -05:00
Brian C
a8bd44a6ec Requiring native bindings polutes 'global' (#984)
There was some nasty global-ish variable reference updating happening when the native module 'initializes' after its require with `require('pg').native`

This fixes the issue by making sure both `require('pg')` and `require('pg').native` each initialize their own context in isolation and no weird global-ish references are used & subsequently stomped on.
2016-04-08 18:46:10 -05:00
Dorian Johnson
eb7b15c623 Fix byte representation of CancelRequest message
I noticed that query cancellation was not working when connecting through pgbouncer,
even though it worked fine when directly connected. This is because we're appending an
extra null byte, and pgbouncer is strict about the packet length.
(per http://www.postgresql.org/docs/9.1/static/protocol-message-formats.html)

This removes the extraneous byte, which fixes cancellation against pgbouncer.
2016-03-09 16:13:54 -08:00