mysql2 3.11.0 → 3.11.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/connection.js +4 -4
- package/lib/parsers/parser_cache.js +3 -3
- package/lib/parsers/string.js +2 -2
- package/lib/pool.js +4 -3
- package/package.json +3 -3
- package/promise.js +2 -2
package/lib/connection.js
CHANGED
|
@@ -22,7 +22,7 @@ const EventEmitter = require('events').EventEmitter;
|
|
|
22
22
|
const Readable = require('stream').Readable;
|
|
23
23
|
const Queue = require('denque');
|
|
24
24
|
const SqlString = require('sqlstring');
|
|
25
|
-
const
|
|
25
|
+
const { createLRU } = require('lru.min');
|
|
26
26
|
|
|
27
27
|
const PacketParser = require('./packet_parser.js');
|
|
28
28
|
const Packets = require('./packets/index.js');
|
|
@@ -75,9 +75,9 @@ class Connection extends EventEmitter {
|
|
|
75
75
|
this._command = null;
|
|
76
76
|
this._paused = false;
|
|
77
77
|
this._paused_packets = new Queue();
|
|
78
|
-
this._statements =
|
|
78
|
+
this._statements = createLRU({
|
|
79
79
|
max: this.config.maxPreparedStatements,
|
|
80
|
-
|
|
80
|
+
onEviction: function(_, statement) {
|
|
81
81
|
statement.close();
|
|
82
82
|
}
|
|
83
83
|
});
|
|
@@ -411,7 +411,7 @@ class Connection extends EventEmitter {
|
|
|
411
411
|
err.code = code || 'PROTOCOL_ERROR';
|
|
412
412
|
this.emit('error', err);
|
|
413
413
|
}
|
|
414
|
-
|
|
414
|
+
|
|
415
415
|
get fatalError() {
|
|
416
416
|
return this._fatalError;
|
|
417
417
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const { createLRU } = require('lru.min');
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const parserCache = createLRU({
|
|
6
6
|
max: 15000,
|
|
7
7
|
});
|
|
8
8
|
|
|
@@ -51,7 +51,7 @@ function getParser(type, fields, options, config, compiler) {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
function setMaxCache(max) {
|
|
54
|
-
parserCache
|
|
54
|
+
parserCache.resize(max);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
function clearCache() {
|
package/lib/parsers/string.js
CHANGED
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
|
-
|
|
205
|
-
this.
|
|
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.11.
|
|
3
|
+
"version": "3.11.2",
|
|
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",
|
|
@@ -63,13 +63,13 @@
|
|
|
63
63
|
"generate-function": "^2.3.1",
|
|
64
64
|
"iconv-lite": "^0.6.3",
|
|
65
65
|
"long": "^5.2.1",
|
|
66
|
-
"lru
|
|
66
|
+
"lru.min": "^1.0.0",
|
|
67
67
|
"named-placeholders": "^1.1.3",
|
|
68
68
|
"seq-queue": "^0.0.5",
|
|
69
69
|
"sqlstring": "^2.3.2"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@types/node": "^
|
|
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 {
|