mysql2 3.10.3 → 3.11.1

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.
@@ -51,6 +51,7 @@ module.exports.YEAR = 0x0d; // aka YEAR, 1 byte (don't ask)
51
51
  module.exports.NEWDATE = 0x0e; // aka ?
52
52
  module.exports.VARCHAR = 0x0f; // aka VARCHAR (?)
53
53
  module.exports.BIT = 0x10; // aka BIT, 1-8 byte
54
+ module.exports.VECTOR = 0xf2;
54
55
  module.exports.JSON = 0xf5;
55
56
  module.exports.NEWDECIMAL = 0xf6; // aka DECIMAL
56
57
  module.exports.ENUM = 0xf7; // aka ENUM
@@ -608,6 +608,16 @@ class Packet {
608
608
  return parseGeometry();
609
609
  }
610
610
 
611
+ parseVector() {
612
+ const bufLen = this.readLengthCodedNumber();
613
+ const vectorEnd = this.offset + bufLen;
614
+ const result = [];
615
+ while (this.offset < vectorEnd && this.offset < this.end) {
616
+ result.push(this.readFloat());
617
+ }
618
+ return result;
619
+ }
620
+
611
621
  parseDate(timezone) {
612
622
  const strLen = this.readLengthCodedNumber();
613
623
  if (strLen === null) {
@@ -55,6 +55,8 @@ function readCodeFor(field, config, options, fieldNum) {
55
55
  return 'packet.readLengthCodedString("ascii");';
56
56
  case Types.GEOMETRY:
57
57
  return 'packet.parseGeometryValue();';
58
+ case Types.VECTOR:
59
+ return 'packet.parseVector()';
58
60
  case Types.JSON:
59
61
  // Since for JSON columns mysql always returns charset 63 (BINARY),
60
62
  // we have to handle it according to JSON specs and use "utf8",
@@ -59,6 +59,8 @@ function readCodeFor(type, charset, encodingExpr, config, options) {
59
59
  return 'packet.readLengthCodedString("ascii")';
60
60
  case Types.GEOMETRY:
61
61
  return 'packet.parseGeometryValue()';
62
+ case Types.VECTOR:
63
+ return 'packet.parseVector()';
62
64
  case Types.JSON:
63
65
  // Since for JSON columns mysql always returns charset 63 (BINARY),
64
66
  // we have to handle it according to JSON specs and use "utf8",
package/lib/pool.js CHANGED
@@ -200,9 +200,10 @@ class Pool extends EventEmitter {
200
200
  this._removeIdleTimeoutConnectionsTimer = setTimeout(() => {
201
201
  try {
202
202
  while (
203
- this._freeConnections.length > this.config.maxIdle &&
204
- Date.now() - this._freeConnections.get(0).lastActiveTime >
205
- this.config.idleTimeout
203
+ this._freeConnections.length > this.config.maxIdle ||
204
+ (this._freeConnections.length > 0 &&
205
+ Date.now() - this._freeConnections.get(0).lastActiveTime >
206
+ this.config.idleTimeout)
206
207
  ) {
207
208
  this._freeConnections.get(0).destroy();
208
209
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mysql2",
3
- "version": "3.10.3",
3
+ "version": "3.11.1",
4
4
  "description": "fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS",
5
5
  "main": "index.js",
6
6
  "typings": "typings/mysql/index",
@@ -69,7 +69,7 @@
69
69
  "sqlstring": "^2.3.2"
70
70
  },
71
71
  "devDependencies": {
72
- "@types/node": "^20.0.0",
72
+ "@types/node": "^22.0.0",
73
73
  "@typescript-eslint/eslint-plugin": "^5.42.1",
74
74
  "@typescript-eslint/parser": "^5.42.1",
75
75
  "assert-diff": "^3.0.2",
package/promise.js CHANGED
@@ -451,10 +451,10 @@ class PromisePoolCluster extends EventEmitter {
451
451
  inheritEvents(poolCluster, this, ['warn', 'remove']);
452
452
  }
453
453
 
454
- getConnection() {
454
+ getConnection(pattern, selector) {
455
455
  const corePoolCluster = this.poolCluster;
456
456
  return new this.Promise((resolve, reject) => {
457
- corePoolCluster.getConnection((err, coreConnection) => {
457
+ corePoolCluster.getConnection(pattern, selector, (err, coreConnection) => {
458
458
  if (err) {
459
459
  reject(err);
460
460
  } else {
@@ -16,6 +16,7 @@ interface Types {
16
16
  0x0e: string;
17
17
  0x0f: string;
18
18
  0x10: string;
19
+ 0xf2: string;
19
20
  0xf5: string;
20
21
  0xf6: string;
21
22
  0xf7: string;
@@ -45,6 +46,7 @@ interface Types {
45
46
  NEWDATE: number;
46
47
  VARCHAR: number;
47
48
  BIT: number;
49
+ VECTOR: number;
48
50
  JSON: number;
49
51
  NEWDECIMAL: number;
50
52
  ENUM: number;
@@ -25,6 +25,7 @@ export type Type = {
25
25
  | 'NEWDATE'
26
26
  | 'VARCHAR'
27
27
  | 'BIT'
28
+ | 'VECTOR'
28
29
  | 'JSON'
29
30
  | 'NEWDECIMAL'
30
31
  | 'ENUM'