pg 8.3.2 → 8.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client.js +10 -1
- package/lib/connection-parameters.js +5 -0
- package/lib/native/client.js +0 -5
- package/lib/query.js +27 -21
- package/package.json +14 -8
package/lib/client.js
CHANGED
|
@@ -57,6 +57,15 @@ class Client extends EventEmitter {
|
|
|
57
57
|
this.processID = null
|
|
58
58
|
this.secretKey = null
|
|
59
59
|
this.ssl = this.connectionParameters.ssl || false
|
|
60
|
+
// As with Password, make SSL->Key (the private key) non-enumerable.
|
|
61
|
+
// It won't show up in stack traces
|
|
62
|
+
// or if the client is console.logged
|
|
63
|
+
if (this.ssl && this.ssl.key) {
|
|
64
|
+
Object.defineProperty(this.ssl, 'key', {
|
|
65
|
+
enumerable: false,
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
|
|
60
69
|
this._connectionTimeoutMillis = c.connectionTimeoutMillis || 0
|
|
61
70
|
}
|
|
62
71
|
|
|
@@ -215,7 +224,7 @@ class Client extends EventEmitter {
|
|
|
215
224
|
} else if (this.password !== null) {
|
|
216
225
|
cb()
|
|
217
226
|
} else {
|
|
218
|
-
pgPass(this.connectionParameters,
|
|
227
|
+
pgPass(this.connectionParameters, (pass) => {
|
|
219
228
|
if (undefined !== pass) {
|
|
220
229
|
this.connectionParameters.password = this.password = pass
|
|
221
230
|
}
|
|
@@ -84,6 +84,11 @@ class ConnectionParameters {
|
|
|
84
84
|
if (this.ssl === 'no-verify') {
|
|
85
85
|
this.ssl = { rejectUnauthorized: false }
|
|
86
86
|
}
|
|
87
|
+
if (this.ssl && this.ssl.key) {
|
|
88
|
+
Object.defineProperty(this.ssl, 'key', {
|
|
89
|
+
enumerable: false,
|
|
90
|
+
})
|
|
91
|
+
}
|
|
87
92
|
|
|
88
93
|
this.client_encoding = val('client_encoding', config)
|
|
89
94
|
this.replication = val('replication', config)
|
package/lib/native/client.js
CHANGED
|
@@ -3,16 +3,11 @@
|
|
|
3
3
|
// eslint-disable-next-line
|
|
4
4
|
var Native = require('pg-native')
|
|
5
5
|
var TypeOverrides = require('../type-overrides')
|
|
6
|
-
var semver = require('semver')
|
|
7
6
|
var pkg = require('../../package.json')
|
|
8
|
-
var assert = require('assert')
|
|
9
7
|
var EventEmitter = require('events').EventEmitter
|
|
10
8
|
var util = require('util')
|
|
11
9
|
var ConnectionParameters = require('../connection-parameters')
|
|
12
10
|
|
|
13
|
-
var msg = 'Version >= ' + pkg.minNativeVersion + ' of pg-native required.'
|
|
14
|
-
assert(semver.gte(Native.version, pkg.minNativeVersion), msg)
|
|
15
|
-
|
|
16
11
|
var NativeQuery = require('./query')
|
|
17
12
|
|
|
18
13
|
var Client = (module.exports = function (config) {
|
package/lib/query.js
CHANGED
|
@@ -96,39 +96,28 @@ class Query extends EventEmitter {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
handleCommandComplete(msg,
|
|
99
|
+
handleCommandComplete(msg, connection) {
|
|
100
100
|
this._checkForMultirow()
|
|
101
101
|
this._result.addCommandComplete(msg)
|
|
102
102
|
// need to sync after each command complete of a prepared statement
|
|
103
|
-
if
|
|
104
|
-
|
|
103
|
+
// if we were using a row count which results in multiple calls to _getRows
|
|
104
|
+
if (this.rows) {
|
|
105
|
+
connection.sync()
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
// if a named prepared statement is created with empty query text
|
|
109
110
|
// the backend will send an emptyQuery message but *not* a command complete message
|
|
110
|
-
//
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
handleReadyForQuery(con) {
|
|
118
|
-
if (this._canceledDueToError) {
|
|
119
|
-
return this.handleError(this._canceledDueToError, con)
|
|
120
|
-
}
|
|
121
|
-
if (this.callback) {
|
|
122
|
-
this.callback(null, this._results)
|
|
111
|
+
// since we pipeline sync immediately after execute we don't need to do anything here
|
|
112
|
+
// unless we have rows specified, in which case we did not pipeline the intial sync call
|
|
113
|
+
handleEmptyQuery(connection) {
|
|
114
|
+
if (this.rows) {
|
|
115
|
+
connection.sync()
|
|
123
116
|
}
|
|
124
|
-
this.emit('end', this._results)
|
|
125
117
|
}
|
|
126
118
|
|
|
127
119
|
handleError(err, connection) {
|
|
128
120
|
// need to sync after error during a prepared statement
|
|
129
|
-
if (this.isPreparedStatement) {
|
|
130
|
-
connection.sync()
|
|
131
|
-
}
|
|
132
121
|
if (this._canceledDueToError) {
|
|
133
122
|
err = this._canceledDueToError
|
|
134
123
|
this._canceledDueToError = false
|
|
@@ -141,6 +130,16 @@ class Query extends EventEmitter {
|
|
|
141
130
|
this.emit('error', err)
|
|
142
131
|
}
|
|
143
132
|
|
|
133
|
+
handleReadyForQuery(con) {
|
|
134
|
+
if (this._canceledDueToError) {
|
|
135
|
+
return this.handleError(this._canceledDueToError, con)
|
|
136
|
+
}
|
|
137
|
+
if (this.callback) {
|
|
138
|
+
this.callback(null, this._results)
|
|
139
|
+
}
|
|
140
|
+
this.emit('end', this._results)
|
|
141
|
+
}
|
|
142
|
+
|
|
144
143
|
submit(connection) {
|
|
145
144
|
if (typeof this.text !== 'string' && typeof this.name !== 'string') {
|
|
146
145
|
return new Error('A query must have either text or a name. Supplying neither is unsupported.')
|
|
@@ -173,7 +172,14 @@ class Query extends EventEmitter {
|
|
|
173
172
|
portal: this.portal,
|
|
174
173
|
rows: rows,
|
|
175
174
|
})
|
|
176
|
-
|
|
175
|
+
// if we're not reading pages of rows send the sync command
|
|
176
|
+
// to indicate the pipeline is finished
|
|
177
|
+
if (!rows) {
|
|
178
|
+
connection.sync()
|
|
179
|
+
} else {
|
|
180
|
+
// otherwise flush the call out to read more rows
|
|
181
|
+
connection.flush()
|
|
182
|
+
}
|
|
177
183
|
}
|
|
178
184
|
|
|
179
185
|
// http://developer.postgresql.org/pgdocs/postgres/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pg",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.4.2",
|
|
4
4
|
"description": "PostgreSQL client - pure javascript & libpq with the same API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"database",
|
|
@@ -21,12 +21,11 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"buffer-writer": "2.0.0",
|
|
23
23
|
"packet-reader": "1.0.0",
|
|
24
|
-
"pg-connection-string": "^2.
|
|
25
|
-
"pg-pool": "^3.2.
|
|
26
|
-
"pg-protocol": "^1.
|
|
24
|
+
"pg-connection-string": "^2.4.0",
|
|
25
|
+
"pg-pool": "^3.2.2",
|
|
26
|
+
"pg-protocol": "^1.3.0",
|
|
27
27
|
"pg-types": "^2.1.0",
|
|
28
|
-
"pgpass": "1.x"
|
|
29
|
-
"semver": "4.3.2"
|
|
28
|
+
"pgpass": "1.x"
|
|
30
29
|
},
|
|
31
30
|
"devDependencies": {
|
|
32
31
|
"async": "0.9.0",
|
|
@@ -34,7 +33,14 @@
|
|
|
34
33
|
"co": "4.6.0",
|
|
35
34
|
"pg-copy-streams": "0.3.0"
|
|
36
35
|
},
|
|
37
|
-
"
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"pg-native": ">=2.0.0"
|
|
38
|
+
},
|
|
39
|
+
"peerDependenciesMeta": {
|
|
40
|
+
"pg-native": {
|
|
41
|
+
"optional": true
|
|
42
|
+
}
|
|
43
|
+
},
|
|
38
44
|
"scripts": {
|
|
39
45
|
"test": "make test-all"
|
|
40
46
|
},
|
|
@@ -46,5 +52,5 @@
|
|
|
46
52
|
"engines": {
|
|
47
53
|
"node": ">= 8.0.0"
|
|
48
54
|
},
|
|
49
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "b6d69d5bc2eb7df4f4e04bc864b133b795c76a7f"
|
|
50
56
|
}
|