mysql2 2.3.0 → 2.3.3
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/commands/command.js +5 -0
- package/lib/commands/execute.js +2 -2
- package/lib/commands/query.js +7 -7
- package/lib/constants/errors.js +202 -99
- package/lib/packets/column_definition.js +19 -8
- package/lib/packets/packet.js +17 -11
- package/lib/parsers/binary_parser.js +14 -12
- package/lib/parsers/parser_cache.js +1 -7
- package/lib/parsers/string.js +3 -3
- package/lib/parsers/text_parser.js +58 -49
- package/package.json +19 -18
- package/typings/mysql/lib/protocol/packets/ResultSetHeader.d.ts +1 -0
- package/Changelog.md +0 -593
package/lib/commands/command.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const EventEmitter = require('events').EventEmitter;
|
|
4
|
+
const Timers = require('timers');
|
|
4
5
|
|
|
5
6
|
class Command extends EventEmitter {
|
|
6
7
|
constructor() {
|
|
@@ -27,6 +28,10 @@ class Command extends EventEmitter {
|
|
|
27
28
|
if (packet && packet.isError()) {
|
|
28
29
|
const err = packet.asError(connection.clientEncoding);
|
|
29
30
|
err.sql = this.sql || this.query;
|
|
31
|
+
if (this.queryTimeout) {
|
|
32
|
+
Timers.clearTimeout(this.queryTimeout);
|
|
33
|
+
this.queryTimeout = null;
|
|
34
|
+
}
|
|
30
35
|
if (this.onResult) {
|
|
31
36
|
this.onResult(err);
|
|
32
37
|
this.emit('end');
|
package/lib/commands/execute.js
CHANGED
|
@@ -85,10 +85,10 @@ class Execute extends Command {
|
|
|
85
85
|
if (!packet.isEOF()) {
|
|
86
86
|
return connection.protocolError('Expected EOF packet');
|
|
87
87
|
}
|
|
88
|
-
this._rowParser = this.buildParserFromFields(
|
|
88
|
+
this._rowParser = new (this.buildParserFromFields(
|
|
89
89
|
this._fields[this._resultIndex],
|
|
90
90
|
connection
|
|
91
|
-
);
|
|
91
|
+
))();
|
|
92
92
|
return Execute.prototype.row;
|
|
93
93
|
}
|
|
94
94
|
}
|
package/lib/commands/query.js
CHANGED
|
@@ -9,7 +9,6 @@ const Command = require('./command.js');
|
|
|
9
9
|
const Packets = require('../packets/index.js');
|
|
10
10
|
const getTextParser = require('../parsers/text_parser.js');
|
|
11
11
|
const ServerStatus = require('../constants/server_status.js');
|
|
12
|
-
const CharsetToEncoding = require('../constants/charset_encodings.js');
|
|
13
12
|
|
|
14
13
|
const EmptyPacket = new Packets.Packet(0, Buffer.allocUnsafe(4), 0, 4);
|
|
15
14
|
|
|
@@ -44,7 +43,8 @@ class Query extends Command {
|
|
|
44
43
|
throw new Error(err);
|
|
45
44
|
}
|
|
46
45
|
|
|
47
|
-
|
|
46
|
+
/* eslint no-unused-vars: ["error", { "argsIgnorePattern": "^_" }] */
|
|
47
|
+
start(_packet, connection) {
|
|
48
48
|
if (connection.config.debug) {
|
|
49
49
|
// eslint-disable-next-line
|
|
50
50
|
console.log(' Sending query command: %s', this.sql);
|
|
@@ -212,7 +212,7 @@ class Query extends Command {
|
|
|
212
212
|
if (this._receivedFieldsCount === this._fieldCount) {
|
|
213
213
|
const fields = this._fields[this._resultIndex];
|
|
214
214
|
this.emit('fields', fields);
|
|
215
|
-
this._rowParser = getTextParser(fields, this.options, connection.config);
|
|
215
|
+
this._rowParser = new (getTextParser(fields, this.options, connection.config))(fields);
|
|
216
216
|
return Query.prototype.fieldsEOF;
|
|
217
217
|
}
|
|
218
218
|
return Query.prototype.readField;
|
|
@@ -226,7 +226,8 @@ class Query extends Command {
|
|
|
226
226
|
return this.row;
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
|
|
229
|
+
/* eslint no-unused-vars: ["error", { "argsIgnorePattern": "^_" }] */
|
|
230
|
+
row(packet, _connection) {
|
|
230
231
|
if (packet.isEOF()) {
|
|
231
232
|
const status = packet.eofStatusFlags();
|
|
232
233
|
const moreResults = status & ServerStatus.SERVER_MORE_RESULTS_EXISTS;
|
|
@@ -238,11 +239,10 @@ class Query extends Command {
|
|
|
238
239
|
}
|
|
239
240
|
let row;
|
|
240
241
|
try {
|
|
241
|
-
row =
|
|
242
|
+
row = this._rowParser.next(
|
|
242
243
|
packet,
|
|
243
244
|
this._fields[this._resultIndex],
|
|
244
|
-
this.options
|
|
245
|
-
CharsetToEncoding
|
|
245
|
+
this.options
|
|
246
246
|
);
|
|
247
247
|
} catch (err) {
|
|
248
248
|
this._localStreamError = err;
|