@depup/mysql2 3.24.0-depup.0 → 3.24.2-depup.0
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 +1 -1
- package/changes.json +1 -1
- package/lib/packets/encode_parameter.js +16 -2
- package/lib/packets/execute.js +1 -1
- package/lib/packets/packet.js +13 -1
- package/lib/packets/prepare_statement.js +12 -0
- package/lib/packets/query.js +37 -26
- package/lib/packets/typed_parameter.js +18 -8
- package/lib/parsers/string.js +4 -0
- package/lib/pool_cluster.js +11 -0
- package/lib/promise/connection.js +24 -14
- package/lib/promise/pool.js +3 -1
- package/lib/promise/pool_cluster.js +6 -6
- package/lib/promise/prepared_statement_info.js +3 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ npm install @depup/mysql2
|
|
|
13
13
|
|
|
14
14
|
| Field | Value |
|
|
15
15
|
|-------|-------|
|
|
16
|
-
| Original | [mysql2](https://www.npmjs.com/package/mysql2) @ 3.24.
|
|
16
|
+
| Original | [mysql2](https://www.npmjs.com/package/mysql2) @ 3.24.2 |
|
|
17
17
|
| Processed | 2026-08-24 |
|
|
18
18
|
| Smoke test | passed |
|
|
19
19
|
| Deps updated | 0 |
|
package/changes.json
CHANGED
|
@@ -88,14 +88,28 @@ function toParameter(value, encoding, timezone, jsonAsString, hint) {
|
|
|
88
88
|
length = 0;
|
|
89
89
|
writer = writeNothing;
|
|
90
90
|
}
|
|
91
|
+
let byteLength;
|
|
91
92
|
if (length === undefined) {
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
// a non-string here (e.g. a Uint8Array) keeps the Buffer.from coercion
|
|
94
|
+
// inside StringParser.encode
|
|
95
|
+
if (
|
|
96
|
+
typeof value === 'string' &&
|
|
97
|
+
StringParser.hasFastUtf8Write &&
|
|
98
|
+
(encoding === 'utf8' || encoding === 'utf-8')
|
|
99
|
+
) {
|
|
100
|
+
byteLength = Buffer.byteLength(value, 'utf8');
|
|
101
|
+
length = Packet.lengthCodedNumberLength(byteLength) + byteLength;
|
|
102
|
+
writer = Packet.prototype.writeLengthCodedUtf8String;
|
|
103
|
+
} else {
|
|
104
|
+
value = StringParser.encode(value, encoding);
|
|
105
|
+
length = Packet.lengthCodedNumberLength(value.length) + value.length;
|
|
106
|
+
}
|
|
94
107
|
}
|
|
95
108
|
return {
|
|
96
109
|
value,
|
|
97
110
|
type,
|
|
98
111
|
length,
|
|
112
|
+
byteLength,
|
|
99
113
|
writer,
|
|
100
114
|
unsigned: false,
|
|
101
115
|
isNull: type === Types.NULL,
|
package/lib/packets/execute.js
CHANGED
|
@@ -206,7 +206,7 @@ class Execute {
|
|
|
206
206
|
for (let i = 0; i < totalParams; i++) {
|
|
207
207
|
const parameter = allParams[i];
|
|
208
208
|
if (!parameter.isNull) {
|
|
209
|
-
parameter.writer.call(packet, parameter.value);
|
|
209
|
+
parameter.writer.call(packet, parameter.value, parameter.byteLength);
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
}
|
package/lib/packets/packet.js
CHANGED
|
@@ -1030,6 +1030,18 @@ class Packet {
|
|
|
1030
1030
|
this.offset += buf.length;
|
|
1031
1031
|
}
|
|
1032
1032
|
|
|
1033
|
+
// byteLength, when the caller sized the packet, must be
|
|
1034
|
+
// Buffer.byteLength(string, 'utf8'); only used where
|
|
1035
|
+
// Buffer.prototype.utf8Write exists
|
|
1036
|
+
writeLengthCodedUtf8String(string, byteLength) {
|
|
1037
|
+
if (byteLength === undefined) {
|
|
1038
|
+
byteLength = Buffer.byteLength(string, 'utf8');
|
|
1039
|
+
}
|
|
1040
|
+
this.writeLengthCodedNumber(byteLength);
|
|
1041
|
+
this.buffer.utf8Write(string, this.offset, byteLength);
|
|
1042
|
+
this.offset += byteLength;
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1033
1045
|
writeLengthCodedBuffer(b) {
|
|
1034
1046
|
this.writeLengthCodedNumber(b.length);
|
|
1035
1047
|
b.copy(this.buffer, this.offset);
|
|
@@ -1123,7 +1135,7 @@ class Packet {
|
|
|
1123
1135
|
return 3;
|
|
1124
1136
|
}
|
|
1125
1137
|
if (n < 0xffffff) {
|
|
1126
|
-
return
|
|
1138
|
+
return 4;
|
|
1127
1139
|
}
|
|
1128
1140
|
return 9;
|
|
1129
1141
|
}
|
|
@@ -13,6 +13,18 @@ class PrepareStatement {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
toPacket() {
|
|
16
|
+
if (
|
|
17
|
+
StringParser.hasFastUtf8Write &&
|
|
18
|
+
(this.encoding === 'utf8' || this.encoding === 'utf-8')
|
|
19
|
+
) {
|
|
20
|
+
const length = 5 + Buffer.byteLength(this.query, 'utf8');
|
|
21
|
+
const buffer = Buffer.allocUnsafe(length);
|
|
22
|
+
buffer[4] = CommandCodes.STMT_PREPARE;
|
|
23
|
+
buffer.utf8Write(this.query, 5, length - 5);
|
|
24
|
+
const packet = new Packet(0, buffer, 0, length);
|
|
25
|
+
packet.offset = length;
|
|
26
|
+
return packet;
|
|
27
|
+
}
|
|
16
28
|
const buf = StringParser.encode(this.query, this.encoding);
|
|
17
29
|
const length = 5 + buf.length;
|
|
18
30
|
const buffer = Buffer.allocUnsafe(length);
|
package/lib/packets/query.js
CHANGED
|
@@ -7,6 +7,19 @@ const CharsetToEncoding = require('../constants/charset_encodings.js');
|
|
|
7
7
|
const ClientConstants = require('../constants/client.js');
|
|
8
8
|
const { toParameter } = require('./encode_parameter.js');
|
|
9
9
|
|
|
10
|
+
const { hasFastUtf8Write } = StringParser;
|
|
11
|
+
|
|
12
|
+
function toQueryPacket(buffer, headerLength, length) {
|
|
13
|
+
buffer[4] = CommandCode.QUERY;
|
|
14
|
+
if (headerLength === 7) {
|
|
15
|
+
buffer[5] = 0; // parameter_count
|
|
16
|
+
buffer[6] = 1; // parameter_set_count, always 1
|
|
17
|
+
}
|
|
18
|
+
const packet = new Packet(0, buffer, 0, length);
|
|
19
|
+
packet.offset = length;
|
|
20
|
+
return packet;
|
|
21
|
+
}
|
|
22
|
+
|
|
10
23
|
class Query {
|
|
11
24
|
constructor(sql, charsetNumber, attributes, clientFlags) {
|
|
12
25
|
this.query = sql;
|
|
@@ -25,36 +38,30 @@ class Query {
|
|
|
25
38
|
: 0;
|
|
26
39
|
|
|
27
40
|
if (attributeCount === 0) {
|
|
28
|
-
// fast path: no attribute values to serialize, so the packet
|
|
29
|
-
//
|
|
41
|
+
// fast path: no attribute values to serialize, so the packet is the
|
|
42
|
+
// header plus the encoded SQL
|
|
30
43
|
const headerLength = useQueryAttributes ? 7 : 5;
|
|
44
|
+
if (
|
|
45
|
+
hasFastUtf8Write &&
|
|
46
|
+
(this.encoding === 'utf8' || this.encoding === 'utf-8')
|
|
47
|
+
) {
|
|
48
|
+
const length = headerLength + Buffer.byteLength(this.query, 'utf8');
|
|
49
|
+
const buffer = Buffer.allocUnsafe(length);
|
|
50
|
+
buffer.utf8Write(this.query, headerLength, length - headerLength);
|
|
51
|
+
return toQueryPacket(buffer, headerLength, length);
|
|
52
|
+
}
|
|
31
53
|
if (Buffer.isEncoding(this.encoding)) {
|
|
32
|
-
const
|
|
33
|
-
|
|
54
|
+
const length =
|
|
55
|
+
headerLength + Buffer.byteLength(this.query, this.encoding);
|
|
34
56
|
const buffer = Buffer.allocUnsafe(length);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
packet.writeInt8(CommandCode.QUERY);
|
|
38
|
-
if (useQueryAttributes) {
|
|
39
|
-
packet.writeInt8(0); // parameter_count
|
|
40
|
-
packet.writeInt8(1); // parameter_set_count, always 1
|
|
41
|
-
}
|
|
42
|
-
buffer.write(this.query, packet.offset, this.encoding);
|
|
43
|
-
packet.offset = length;
|
|
44
|
-
return packet;
|
|
57
|
+
buffer.write(this.query, headerLength, this.encoding);
|
|
58
|
+
return toQueryPacket(buffer, headerLength, length);
|
|
45
59
|
}
|
|
46
|
-
const
|
|
47
|
-
const length = headerLength +
|
|
60
|
+
const sqlBuffer = StringParser.encode(this.query, this.encoding);
|
|
61
|
+
const length = headerLength + sqlBuffer.length;
|
|
48
62
|
const buffer = Buffer.allocUnsafe(length);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
packet.writeInt8(CommandCode.QUERY);
|
|
52
|
-
if (useQueryAttributes) {
|
|
53
|
-
packet.writeInt8(0); // parameter_count
|
|
54
|
-
packet.writeInt8(1); // parameter_set_count, always 1
|
|
55
|
-
}
|
|
56
|
-
packet.writeBuffer(buf);
|
|
57
|
-
return packet;
|
|
63
|
+
sqlBuffer.copy(buffer, headerLength);
|
|
64
|
+
return toQueryPacket(buffer, headerLength, length);
|
|
58
65
|
}
|
|
59
66
|
|
|
60
67
|
const names = Object.keys(this.attributes);
|
|
@@ -120,7 +127,11 @@ class Query {
|
|
|
120
127
|
|
|
121
128
|
for (let i = 0; i < attributeCount; i++) {
|
|
122
129
|
if (!parameters[i].isNull) {
|
|
123
|
-
parameters[i].writer.call(
|
|
130
|
+
parameters[i].writer.call(
|
|
131
|
+
packet,
|
|
132
|
+
parameters[i].value,
|
|
133
|
+
parameters[i].byteLength
|
|
134
|
+
);
|
|
124
135
|
}
|
|
125
136
|
}
|
|
126
137
|
|
|
@@ -238,15 +238,25 @@ function timeEncoder() {
|
|
|
238
238
|
|
|
239
239
|
function lengthCodedEncoder(encoding) {
|
|
240
240
|
return (value) => {
|
|
241
|
-
|
|
242
|
-
? value
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
241
|
+
if (!Buffer.isBuffer(value)) {
|
|
242
|
+
const string = typeof value === 'string' ? value : String(value);
|
|
243
|
+
if (
|
|
244
|
+
StringParser.hasFastUtf8Write &&
|
|
245
|
+
(encoding === 'utf8' || encoding === 'utf-8')
|
|
246
|
+
) {
|
|
247
|
+
const byteLength = Buffer.byteLength(string, 'utf8');
|
|
248
|
+
return {
|
|
249
|
+
value: string,
|
|
250
|
+
length: Packet.lengthCodedNumberLength(byteLength) + byteLength,
|
|
251
|
+
byteLength,
|
|
252
|
+
writer: Packet.prototype.writeLengthCodedUtf8String,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
value = StringParser.encode(string, encoding);
|
|
256
|
+
}
|
|
247
257
|
return {
|
|
248
|
-
value
|
|
249
|
-
length: Packet.lengthCodedNumberLength(
|
|
258
|
+
value,
|
|
259
|
+
length: Packet.lengthCodedNumberLength(value.length) + value.length,
|
|
250
260
|
writer: Packet.prototype.writeLengthCodedBuffer,
|
|
251
261
|
};
|
|
252
262
|
};
|
package/lib/parsers/string.js
CHANGED
|
@@ -15,6 +15,10 @@ const hasFastSlices =
|
|
|
15
15
|
typeof Buffer.prototype.latin1Slice === 'function' &&
|
|
16
16
|
typeof Buffer.prototype.asciiSlice === 'function';
|
|
17
17
|
|
|
18
|
+
// utf8Write skips the per-call encoding normalization and dispatch inside
|
|
19
|
+
// buffer.write(); same stability story as the slice methods above
|
|
20
|
+
exports.hasFastUtf8Write = typeof Buffer.prototype.utf8Write === 'function';
|
|
21
|
+
|
|
18
22
|
exports.decode = function (buffer, encoding, start, end, options) {
|
|
19
23
|
if (hasFastSlices) {
|
|
20
24
|
// replicate buffer.toString() bounds coercion exactly (the *Slice
|
package/lib/pool_cluster.js
CHANGED
|
@@ -141,6 +141,17 @@ class PoolNamespace {
|
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
get trace() {
|
|
145
|
+
const nodeIds = this._cluster._findNodeIds(this._pattern, true);
|
|
146
|
+
for (let i = 0; i < nodeIds.length; i++) {
|
|
147
|
+
const node = this._cluster._getNode(nodeIds[i]);
|
|
148
|
+
if (node?.pool.config.connectionConfig.trace) {
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return nodeIds.length === 0;
|
|
153
|
+
}
|
|
154
|
+
|
|
144
155
|
_getClusterNode() {
|
|
145
156
|
const foundNodeIds = this._cluster._findNodeIds(this._pattern);
|
|
146
157
|
if (foundNodeIds.length === 0) {
|
|
@@ -82,9 +82,9 @@ class PromiseConnection extends EventEmitter {
|
|
|
82
82
|
|
|
83
83
|
beginTransaction() {
|
|
84
84
|
const c = this.connection;
|
|
85
|
-
const stackHolder =
|
|
86
|
-
PromiseConnection.prototype.beginTransaction
|
|
87
|
-
|
|
85
|
+
const stackHolder = c.config.trace
|
|
86
|
+
? captureStackHolder(PromiseConnection.prototype.beginTransaction)
|
|
87
|
+
: undefined;
|
|
88
88
|
return new this.Promise((resolve, reject) => {
|
|
89
89
|
const done = makeDoneCb(resolve, reject, stackHolder);
|
|
90
90
|
c.beginTransaction(done);
|
|
@@ -93,7 +93,9 @@ class PromiseConnection extends EventEmitter {
|
|
|
93
93
|
|
|
94
94
|
commit() {
|
|
95
95
|
const c = this.connection;
|
|
96
|
-
const stackHolder =
|
|
96
|
+
const stackHolder = c.config.trace
|
|
97
|
+
? captureStackHolder(PromiseConnection.prototype.commit)
|
|
98
|
+
: undefined;
|
|
97
99
|
return new this.Promise((resolve, reject) => {
|
|
98
100
|
const done = makeDoneCb(resolve, reject, stackHolder);
|
|
99
101
|
c.commit(done);
|
|
@@ -102,9 +104,9 @@ class PromiseConnection extends EventEmitter {
|
|
|
102
104
|
|
|
103
105
|
rollback() {
|
|
104
106
|
const c = this.connection;
|
|
105
|
-
const stackHolder =
|
|
106
|
-
PromiseConnection.prototype.rollback
|
|
107
|
-
|
|
107
|
+
const stackHolder = c.config.trace
|
|
108
|
+
? captureStackHolder(PromiseConnection.prototype.rollback)
|
|
109
|
+
: undefined;
|
|
108
110
|
return new this.Promise((resolve, reject) => {
|
|
109
111
|
const done = makeDoneCb(resolve, reject, stackHolder);
|
|
110
112
|
c.rollback(done);
|
|
@@ -113,7 +115,9 @@ class PromiseConnection extends EventEmitter {
|
|
|
113
115
|
|
|
114
116
|
ping() {
|
|
115
117
|
const c = this.connection;
|
|
116
|
-
const stackHolder =
|
|
118
|
+
const stackHolder = c.config.trace
|
|
119
|
+
? captureStackHolder(PromiseConnection.prototype.ping)
|
|
120
|
+
: undefined;
|
|
117
121
|
return new this.Promise((resolve, reject) => {
|
|
118
122
|
c.ping((err) => {
|
|
119
123
|
if (err) {
|
|
@@ -128,7 +132,9 @@ class PromiseConnection extends EventEmitter {
|
|
|
128
132
|
|
|
129
133
|
reset() {
|
|
130
134
|
const c = this.connection;
|
|
131
|
-
const stackHolder =
|
|
135
|
+
const stackHolder = c.config.trace
|
|
136
|
+
? captureStackHolder(PromiseConnection.prototype.reset)
|
|
137
|
+
: undefined;
|
|
132
138
|
return new this.Promise((resolve, reject) => {
|
|
133
139
|
c.reset((err) => {
|
|
134
140
|
if (err) {
|
|
@@ -143,7 +149,9 @@ class PromiseConnection extends EventEmitter {
|
|
|
143
149
|
|
|
144
150
|
connect() {
|
|
145
151
|
const c = this.connection;
|
|
146
|
-
const stackHolder =
|
|
152
|
+
const stackHolder = c.config.trace
|
|
153
|
+
? captureStackHolder(PromiseConnection.prototype.connect)
|
|
154
|
+
: undefined;
|
|
147
155
|
return new this.Promise((resolve, reject) => {
|
|
148
156
|
c.connect((err, param) => {
|
|
149
157
|
if (err) {
|
|
@@ -159,7 +167,9 @@ class PromiseConnection extends EventEmitter {
|
|
|
159
167
|
prepare(options) {
|
|
160
168
|
const c = this.connection;
|
|
161
169
|
const promiseImpl = this.Promise;
|
|
162
|
-
const stackHolder =
|
|
170
|
+
const stackHolder = c.config.trace
|
|
171
|
+
? captureStackHolder(PromiseConnection.prototype.prepare)
|
|
172
|
+
: undefined;
|
|
163
173
|
return new this.Promise((resolve, reject) => {
|
|
164
174
|
c.prepare(options, (err, statement) => {
|
|
165
175
|
if (err) {
|
|
@@ -178,9 +188,9 @@ class PromiseConnection extends EventEmitter {
|
|
|
178
188
|
|
|
179
189
|
changeUser(options) {
|
|
180
190
|
const c = this.connection;
|
|
181
|
-
const stackHolder =
|
|
182
|
-
PromiseConnection.prototype.changeUser
|
|
183
|
-
|
|
191
|
+
const stackHolder = c.config.trace
|
|
192
|
+
? captureStackHolder(PromiseConnection.prototype.changeUser)
|
|
193
|
+
: undefined;
|
|
184
194
|
return new this.Promise((resolve, reject) => {
|
|
185
195
|
c.changeUser(options, (err) => {
|
|
186
196
|
if (err) {
|
package/lib/promise/pool.js
CHANGED
|
@@ -77,7 +77,9 @@ class PromisePool extends EventEmitter {
|
|
|
77
77
|
|
|
78
78
|
end() {
|
|
79
79
|
const corePool = this.pool;
|
|
80
|
-
const stackHolder =
|
|
80
|
+
const stackHolder = corePool.config.connectionConfig.trace
|
|
81
|
+
? captureStackHolder(PromisePool.prototype.end)
|
|
82
|
+
: undefined;
|
|
81
83
|
return new this.Promise((resolve, reject) => {
|
|
82
84
|
corePool.end((err) => {
|
|
83
85
|
if (err) {
|
|
@@ -25,9 +25,9 @@ class PromisePoolNamespace {
|
|
|
25
25
|
|
|
26
26
|
query(sql, values) {
|
|
27
27
|
const corePoolNamespace = this.poolNamespace;
|
|
28
|
-
const stackHolder =
|
|
29
|
-
PromisePoolNamespace.prototype.query
|
|
30
|
-
|
|
28
|
+
const stackHolder = corePoolNamespace.trace
|
|
29
|
+
? captureStackHolder(PromisePoolNamespace.prototype.query)
|
|
30
|
+
: undefined;
|
|
31
31
|
if (typeof values === 'function') {
|
|
32
32
|
throw new Error(
|
|
33
33
|
'Callback function is not available with promise clients.'
|
|
@@ -41,9 +41,9 @@ class PromisePoolNamespace {
|
|
|
41
41
|
|
|
42
42
|
execute(sql, values) {
|
|
43
43
|
const corePoolNamespace = this.poolNamespace;
|
|
44
|
-
const stackHolder =
|
|
45
|
-
PromisePoolNamespace.prototype.execute
|
|
46
|
-
|
|
44
|
+
const stackHolder = corePoolNamespace.trace
|
|
45
|
+
? captureStackHolder(PromisePoolNamespace.prototype.execute)
|
|
46
|
+
: undefined;
|
|
47
47
|
if (typeof values === 'function') {
|
|
48
48
|
throw new Error(
|
|
49
49
|
'Callback function is not available with promise clients.'
|
|
@@ -11,9 +11,9 @@ class PromisePreparedStatementInfo {
|
|
|
11
11
|
|
|
12
12
|
execute(parameters) {
|
|
13
13
|
const s = this.statement;
|
|
14
|
-
const stackHolder =
|
|
15
|
-
PromisePreparedStatementInfo.prototype.execute
|
|
16
|
-
|
|
14
|
+
const stackHolder = s._connection.config.trace
|
|
15
|
+
? captureStackHolder(PromisePreparedStatementInfo.prototype.execute)
|
|
16
|
+
: undefined;
|
|
17
17
|
return new this.Promise((resolve, reject) => {
|
|
18
18
|
const done = makeDoneCb(resolve, reject, stackHolder);
|
|
19
19
|
if (parameters) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@depup/mysql2",
|
|
3
|
-
"version": "3.24.
|
|
3
|
+
"version": "3.24.2-depup.0",
|
|
4
4
|
"description": "fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS (with updated dependencies)",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"typings": "typings/mysql/index",
|
|
@@ -95,8 +95,8 @@
|
|
|
95
95
|
"changes": {},
|
|
96
96
|
"depsUpdated": 0,
|
|
97
97
|
"originalPackage": "mysql2",
|
|
98
|
-
"originalVersion": "3.24.
|
|
99
|
-
"processedAt": "2026-08-
|
|
98
|
+
"originalVersion": "3.24.2",
|
|
99
|
+
"processedAt": "2026-08-24T16:12:32.885Z",
|
|
100
100
|
"smokeTest": "passed"
|
|
101
101
|
}
|
|
102
102
|
}
|