mysql2 3.4.4 → 3.4.5

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ## Node MySQL 2
1
+ ## MySQL 2
2
2
 
3
3
  [![Greenkeeper badge](https://badges.greenkeeper.io/sidorares/node-mysql2.svg)](https://greenkeeper.io/)
4
4
  [![NPM Version][npm-image]][npm-url]
@@ -73,10 +73,19 @@ class Prepare extends Command {
73
73
  return Prepare.prototype.readField;
74
74
  }
75
75
  return this.prepareDone(connection);
76
-
77
76
  }
78
77
 
79
78
  readParameter(packet, connection) {
79
+ // there might be scenarios when mysql server reports more parameters than
80
+ // are actually present in the array of parameter definitions.
81
+ // if EOF packet is received we switch to "read fields" state if there are
82
+ // any fields reported by the server, otherwise we finish the command.
83
+ if (packet.isEOF()) {
84
+ if (this.fieldCount > 0) {
85
+ return Prepare.prototype.readField;
86
+ }
87
+ return this.prepareDone(connection);
88
+ }
80
89
  const def = new Packets.ColumnDefinition(packet, connection.clientEncoding);
81
90
  this.parameterDefinitions.push(def);
82
91
  if (this.parameterDefinitions.length === this.parameterCount) {
@@ -86,6 +95,9 @@ class Prepare extends Command {
86
95
  }
87
96
 
88
97
  readField(packet, connection) {
98
+ if (packet.isEOF()) {
99
+ return this.prepareDone(connection);
100
+ }
89
101
  const def = new Packets.ColumnDefinition(packet, connection.clientEncoding);
90
102
  this.fields.push(def);
91
103
  if (this.fields.length === this.fieldCount) {
package/lib/connection.js CHANGED
@@ -489,14 +489,23 @@ class Connection extends EventEmitter {
489
489
  }
490
490
  this._bumpSequenceId(packet.numPackets);
491
491
  }
492
- const done = this._command.execute(packet, this);
493
- if (done) {
494
- this._command = this._commands.shift();
495
- if (this._command) {
496
- this.sequenceId = 0;
497
- this.compressedSequenceId = 0;
498
- this.handlePacket();
492
+ try {
493
+ if (this._fatalError) {
494
+ // skip remaining packets after client is in the error state
495
+ return;
496
+ }
497
+ const done = this._command.execute(packet, this);
498
+ if (done) {
499
+ this._command = this._commands.shift();
500
+ if (this._command) {
501
+ this.sequenceId = 0;
502
+ this.compressedSequenceId = 0;
503
+ this.handlePacket();
504
+ }
499
505
  }
506
+ } catch (err) {
507
+ this._handleFatalError(err);
508
+ this.stream.destroy();
500
509
  }
501
510
  }
502
511
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mysql2",
3
- "version": "3.4.4",
3
+ "version": "3.4.5",
4
4
  "description": "fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -12,6 +12,7 @@
12
12
  "lint:code": "eslint index.js promise.js index.d.ts promise.d.ts \"typings/**/*.ts\" \"lib/**/*.js\" \"test/**/*.{js,ts}\" \"benchmarks/**/*.js\"",
13
13
  "lint:docs": "eslint Contributing.md README.md \"documentation/**/*.md\" \"examples/*.js\"",
14
14
  "test": "node ./test/run.js",
15
+ "test:builtin-node-runner": "NODE_V8_COVERAGE=./coverage node --test --experimental-test-coverage test/builtin-runner",
15
16
  "test:tsc-build": "cd \"test/tsc-build\" && npx tsc -p \"tsconfig.json\"",
16
17
  "coverage-test": "c8 -r cobertura -r lcov -r text node ./test/run.js",
17
18
  "benchmark": "node ./benchmarks/benchmark.js",