@tachybase/module-multi-app 1.6.0 → 1.6.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.
- package/dist/externalVersion.js +5 -5
- package/dist/node_modules/mariadb/callback.js +43 -8
- package/dist/node_modules/mariadb/check-node.js +30 -0
- package/dist/node_modules/mariadb/lib/cluster-callback.js +84 -0
- package/dist/node_modules/mariadb/lib/cluster.js +446 -0
- package/dist/node_modules/mariadb/lib/cmd/batch-bulk.js +576 -177
- package/dist/node_modules/mariadb/lib/cmd/change-user.js +54 -44
- package/dist/node_modules/mariadb/lib/cmd/class/ok-packet.js +3 -2
- package/dist/node_modules/mariadb/lib/cmd/class/prepare-cache-wrapper.js +46 -0
- package/dist/node_modules/mariadb/lib/cmd/class/prepare-result-packet.js +141 -0
- package/dist/node_modules/mariadb/lib/cmd/class/prepare-wrapper.js +70 -0
- package/dist/node_modules/mariadb/lib/cmd/close-prepare.js +38 -0
- package/dist/node_modules/mariadb/lib/cmd/column-definition.js +145 -47
- package/dist/node_modules/mariadb/lib/cmd/command.js +41 -75
- package/dist/node_modules/mariadb/lib/cmd/decoder/binary-decoder.js +282 -0
- package/dist/node_modules/mariadb/lib/cmd/decoder/text-decoder.js +210 -0
- package/dist/node_modules/mariadb/lib/cmd/{common-binary-cmd.js → encoder/binary-encoder.js} +34 -77
- package/dist/node_modules/mariadb/lib/cmd/encoder/text-encoder.js +311 -0
- package/dist/node_modules/mariadb/lib/cmd/execute-stream.js +61 -0
- package/dist/node_modules/mariadb/lib/cmd/execute.js +338 -0
- package/dist/node_modules/mariadb/lib/cmd/handshake/auth/caching-sha2-password-auth.js +25 -62
- package/dist/node_modules/mariadb/lib/cmd/handshake/auth/clear-password-auth.js +39 -6
- package/dist/node_modules/mariadb/lib/cmd/handshake/auth/ed25519-password-auth.js +48 -16
- package/dist/node_modules/mariadb/lib/cmd/handshake/auth/handshake.js +198 -0
- package/dist/node_modules/mariadb/lib/cmd/handshake/{initial-handshake.js → auth/initial-handshake.js} +10 -8
- package/dist/node_modules/mariadb/lib/cmd/handshake/auth/native-password-auth.js +22 -9
- package/dist/node_modules/mariadb/lib/cmd/handshake/auth/pam-password-auth.js +9 -4
- package/dist/node_modules/mariadb/lib/cmd/handshake/auth/parsec-auth.js +115 -0
- package/dist/node_modules/mariadb/lib/cmd/handshake/auth/plugin-auth.js +12 -5
- package/dist/node_modules/mariadb/lib/cmd/handshake/auth/sha256-password-auth.js +44 -33
- package/dist/node_modules/mariadb/lib/cmd/handshake/authentication.js +335 -0
- package/dist/node_modules/mariadb/lib/cmd/handshake/client-capabilities.js +20 -19
- package/dist/node_modules/mariadb/lib/cmd/handshake/ssl-request.js +6 -3
- package/dist/node_modules/mariadb/lib/cmd/parser.js +861 -0
- package/dist/node_modules/mariadb/lib/cmd/ping.js +17 -18
- package/dist/node_modules/mariadb/lib/cmd/prepare.js +170 -0
- package/dist/node_modules/mariadb/lib/cmd/query.js +281 -144
- package/dist/node_modules/mariadb/lib/cmd/quit.js +9 -6
- package/dist/node_modules/mariadb/lib/cmd/reset.js +15 -19
- package/dist/node_modules/mariadb/lib/cmd/stream.js +21 -6
- package/dist/node_modules/mariadb/lib/config/cluster-options.js +23 -0
- package/dist/node_modules/mariadb/lib/config/connection-options.js +196 -132
- package/dist/node_modules/mariadb/lib/config/pool-options.js +27 -19
- package/dist/node_modules/mariadb/lib/connection-callback.js +492 -120
- package/dist/node_modules/mariadb/lib/connection-promise.js +372 -0
- package/dist/node_modules/mariadb/lib/connection.js +1739 -1016
- package/dist/node_modules/mariadb/lib/const/capabilities.js +36 -30
- package/dist/node_modules/mariadb/lib/const/collations.js +972 -36
- package/dist/node_modules/mariadb/lib/const/connection_status.js +3 -0
- package/dist/node_modules/mariadb/lib/const/error-code.js +35 -11
- package/dist/node_modules/mariadb/lib/const/field-detail.js +3 -0
- package/dist/node_modules/mariadb/lib/const/field-type.js +7 -4
- package/dist/node_modules/mariadb/lib/const/server-status.js +4 -1
- package/dist/node_modules/mariadb/lib/const/state-change.js +3 -0
- package/dist/node_modules/mariadb/lib/filtered-cluster-callback.js +136 -0
- package/dist/node_modules/mariadb/lib/filtered-cluster.js +118 -0
- package/dist/node_modules/mariadb/lib/io/compression-input-stream.js +14 -13
- package/dist/node_modules/mariadb/lib/io/compression-output-stream.js +21 -18
- package/dist/node_modules/mariadb/lib/io/packet-input-stream.js +75 -64
- package/dist/node_modules/mariadb/lib/io/packet-node-encoded.js +13 -9
- package/dist/node_modules/mariadb/lib/io/packet-node-iconv.js +12 -10
- package/dist/node_modules/mariadb/lib/io/packet-output-stream.js +402 -134
- package/dist/node_modules/mariadb/lib/io/packet.js +287 -202
- package/dist/node_modules/mariadb/lib/lru-prepare-cache.js +84 -0
- package/dist/node_modules/mariadb/lib/misc/connection-information.js +15 -32
- package/dist/node_modules/mariadb/lib/misc/errors.js +68 -25
- package/dist/node_modules/mariadb/lib/misc/parse.js +207 -711
- package/dist/node_modules/mariadb/lib/misc/utils.js +34 -62
- package/dist/node_modules/mariadb/lib/pool-callback.js +213 -174
- package/dist/node_modules/mariadb/lib/pool-promise.js +228 -94
- package/dist/node_modules/mariadb/lib/pool.js +951 -0
- package/dist/node_modules/mariadb/package.json +1 -1
- package/dist/node_modules/mariadb/promise.js +1 -34
- package/dist/node_modules/mariadb/types/callback.d.ts +207 -0
- package/dist/node_modules/mariadb/types/index.d.ts +94 -674
- package/dist/node_modules/mariadb/types/share.d.ts +804 -0
- package/dist/node_modules/qs/package.json +1 -1
- package/dist/server/actions/apps.js +2 -2
- package/dist/server/app-lifecycle.d.ts +1 -1
- package/dist/server/app-lifecycle.js +4 -4
- package/dist/server/models/application.d.ts +1 -1
- package/package.json +7 -7
- package/dist/node_modules/mariadb/lib/cmd/batch-rewrite.js +0 -372
- package/dist/node_modules/mariadb/lib/cmd/common-text-cmd.js +0 -427
- package/dist/node_modules/mariadb/lib/cmd/handshake/client-handshake-response.js +0 -126
- package/dist/node_modules/mariadb/lib/cmd/handshake/handshake.js +0 -292
- package/dist/node_modules/mariadb/lib/cmd/resultset.js +0 -607
- package/dist/node_modules/mariadb/lib/config/pool-cluster-options.js +0 -19
- package/dist/node_modules/mariadb/lib/filtered-pool-cluster.js +0 -81
- package/dist/node_modules/mariadb/lib/io/bulk-packet.js +0 -590
- package/dist/node_modules/mariadb/lib/io/rewrite-packet.js +0 -481
- package/dist/node_modules/mariadb/lib/pool-base.js +0 -611
- package/dist/node_modules/mariadb/lib/pool-cluster-callback.js +0 -66
- package/dist/node_modules/mariadb/lib/pool-cluster.js +0 -407
|
@@ -1,160 +1,532 @@
|
|
|
1
|
+
// SPDX-License-Identifier: LGPL-2.1-or-later
|
|
2
|
+
// Copyright (c) 2015-2025 MariaDB Corporation Ab
|
|
3
|
+
|
|
1
4
|
'use strict';
|
|
2
5
|
|
|
3
|
-
const Connection = require('./connection');
|
|
4
|
-
const util = require('util');
|
|
5
6
|
const Errors = require('./misc/errors');
|
|
6
7
|
const { Status } = require('./const/connection_status');
|
|
8
|
+
const Query = require('./cmd/query');
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
class ConnectionCallback {
|
|
11
|
+
#conn;
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const queryPromise = this.query.bind(this);
|
|
15
|
-
const endPromise = this.end.bind(this);
|
|
16
|
-
const pingPromise = this.ping.bind(this);
|
|
17
|
-
const resetPromise = this.reset.bind(this);
|
|
18
|
-
const commitPromise = this.commit.bind(this);
|
|
19
|
-
const rollbackPromise = this.rollback.bind(this);
|
|
13
|
+
constructor(conn) {
|
|
14
|
+
this.#conn = conn;
|
|
15
|
+
}
|
|
20
16
|
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
get threadId() {
|
|
18
|
+
return this.#conn.info ? this.#conn.info.threadId : null;
|
|
19
|
+
}
|
|
23
20
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
get info() {
|
|
22
|
+
return this.#conn.info;
|
|
23
|
+
}
|
|
27
24
|
|
|
28
|
-
|
|
29
|
-
commitPromise()
|
|
30
|
-
.then(() => {
|
|
31
|
-
if (callback) callback(null, null, null);
|
|
32
|
-
})
|
|
33
|
-
.catch(callback || emptyError);
|
|
34
|
-
};
|
|
25
|
+
#noop = () => {};
|
|
35
26
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
})
|
|
41
|
-
.catch(callback || emptyError);
|
|
27
|
+
release = (cb) => {
|
|
28
|
+
this.#conn.release(() => {
|
|
29
|
+
if (cb) cb();
|
|
30
|
+
});
|
|
42
31
|
};
|
|
43
32
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Permit changing user during connection.
|
|
35
|
+
* All user variables will be reset, Prepare commands will be released.
|
|
36
|
+
* !!! mysql has a bug when CONNECT_ATTRS capability is set, that is default !!!!
|
|
37
|
+
*
|
|
38
|
+
* @param options connection options
|
|
39
|
+
* @param callback callback function
|
|
40
|
+
*/
|
|
41
|
+
changeUser(options, callback) {
|
|
42
|
+
let _options, _cb;
|
|
43
|
+
if (typeof options === 'function') {
|
|
44
|
+
_cb = options;
|
|
45
|
+
_options = undefined;
|
|
49
46
|
} else {
|
|
50
|
-
|
|
47
|
+
_options = options;
|
|
51
48
|
_cb = callback;
|
|
52
49
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
const cmdParam = {
|
|
51
|
+
opts: _options,
|
|
52
|
+
callback: _cb
|
|
53
|
+
};
|
|
54
|
+
if (this.#conn.opts.trace) Error.captureStackTrace(cmdParam);
|
|
57
55
|
|
|
58
|
-
|
|
59
|
-
resetPromise()
|
|
60
|
-
.then(callback || emptySuccess)
|
|
61
|
-
.catch(callback || emptyError);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const _beginTransactionCallback = (callback) => {
|
|
65
|
-
queryPromise('START TRANSACTION')
|
|
56
|
+
new Promise(this.#conn.changeUser.bind(this.#conn, cmdParam))
|
|
66
57
|
.then(() => {
|
|
67
|
-
if (callback) callback(null, null, null);
|
|
58
|
+
if (cmdParam.callback) cmdParam.callback(null, null, null);
|
|
68
59
|
})
|
|
69
|
-
.catch(callback ||
|
|
70
|
-
}
|
|
60
|
+
.catch(cmdParam.callback || this.#noop);
|
|
61
|
+
}
|
|
71
62
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Start transaction
|
|
65
|
+
*
|
|
66
|
+
* @param callback callback function
|
|
67
|
+
*/
|
|
68
|
+
beginTransaction(callback) {
|
|
69
|
+
this.query('START TRANSACTION', null, callback);
|
|
70
|
+
}
|
|
77
71
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Commit a transaction.
|
|
74
|
+
*
|
|
75
|
+
* @param callback callback function
|
|
76
|
+
*/
|
|
77
|
+
commit(callback) {
|
|
78
|
+
this.#conn.changeTransaction(
|
|
79
|
+
{ sql: 'COMMIT' },
|
|
80
|
+
() => {
|
|
81
|
+
if (callback) callback(null, null, null);
|
|
82
|
+
},
|
|
83
|
+
callback || this.#noop
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Roll back a transaction.
|
|
89
|
+
*
|
|
90
|
+
* @param callback callback function
|
|
91
|
+
*/
|
|
92
|
+
rollback(callback) {
|
|
93
|
+
this.#conn.changeTransaction(
|
|
94
|
+
{ sql: 'ROLLBACK' },
|
|
95
|
+
() => {
|
|
96
|
+
if (callback) callback(null, null, null);
|
|
97
|
+
},
|
|
98
|
+
callback || this.#noop
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Execute query using text protocol with callback emit columns/data/end/error
|
|
104
|
+
* events to permit streaming big result-set
|
|
105
|
+
*
|
|
106
|
+
* @param sql sql parameter Object can be used to supersede default option.
|
|
107
|
+
* Object must then have sql property.
|
|
108
|
+
* @param values object / array of placeholder values (not mandatory)
|
|
109
|
+
* @param callback callback function
|
|
110
|
+
*/
|
|
111
|
+
query(sql, values, callback) {
|
|
112
|
+
const cmdParam = ConnectionCallback._PARAM(this.#conn.opts, sql, values, callback);
|
|
113
|
+
return ConnectionCallback._QUERY_CMD(this.#conn, cmdParam);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Execute a query returning a Readable Object that will emit columns/data/end/error events
|
|
118
|
+
* to permit streaming big result-set
|
|
119
|
+
*
|
|
120
|
+
* @param sql sql parameter Object can be used to supersede the default option.
|
|
121
|
+
* Object must then have `sql` property.
|
|
122
|
+
* @param values object / array of placeholder values (not mandatory)
|
|
123
|
+
* @returns {Readable}
|
|
124
|
+
*/
|
|
125
|
+
queryStream(sql, values) {
|
|
126
|
+
const cmdParam = ConnectionCallback._PARAM(this.#conn.opts, sql, values);
|
|
127
|
+
const cmd = ConnectionCallback._QUERY_CMD(this.#conn, cmdParam);
|
|
128
|
+
return cmd.stream();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
static _QUERY_CMD(conn, cmdParam) {
|
|
132
|
+
let cmd;
|
|
133
|
+
if (cmdParam.callback) {
|
|
134
|
+
cmdParam.opts = cmdParam.opts ? Object.assign(cmdParam.opts, { metaAsArray: true }) : { metaAsArray: true };
|
|
135
|
+
cmd = new Query(
|
|
136
|
+
([rows, meta]) => {
|
|
137
|
+
cmdParam.callback(null, rows, meta);
|
|
138
|
+
},
|
|
139
|
+
cmdParam.callback,
|
|
140
|
+
conn.opts,
|
|
141
|
+
cmdParam
|
|
142
|
+
);
|
|
143
|
+
} else {
|
|
144
|
+
cmd = new Query(
|
|
145
|
+
() => {},
|
|
146
|
+
() => {},
|
|
147
|
+
conn.opts,
|
|
148
|
+
cmdParam
|
|
87
149
|
);
|
|
88
150
|
}
|
|
89
151
|
|
|
90
|
-
|
|
91
|
-
|
|
152
|
+
cmd.handleNewRows = (row) => {
|
|
153
|
+
cmd._rows[cmd._responseIndex].push(row);
|
|
154
|
+
cmd.emit('data', row);
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
conn.addCommand(cmd, true);
|
|
158
|
+
cmd.stream = (opt) => cmd._stream(conn.socket, opt);
|
|
159
|
+
return cmd;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
execute(sql, values, callback) {
|
|
163
|
+
const cmdParam = ConnectionCallback._PARAM(this.#conn.opts, sql, values, callback);
|
|
164
|
+
cmdParam.opts = cmdParam.opts ? Object.assign(cmdParam.opts, { metaAsArray: true }) : { metaAsArray: true };
|
|
165
|
+
this.#conn.prepareExecute(
|
|
166
|
+
cmdParam,
|
|
167
|
+
([rows, meta]) => {
|
|
168
|
+
if (cmdParam.callback) {
|
|
169
|
+
cmdParam.callback(null, rows, meta);
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
(err) => {
|
|
173
|
+
if (cmdParam.callback) {
|
|
174
|
+
cmdParam.callback(err);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
static _PARAM(options, sql, values, callback) {
|
|
181
|
+
let _cmdOpt,
|
|
182
|
+
_sql,
|
|
183
|
+
_values = values,
|
|
184
|
+
_cb = callback;
|
|
185
|
+
if (typeof values === 'function') {
|
|
186
|
+
_cb = values;
|
|
187
|
+
_values = undefined;
|
|
188
|
+
}
|
|
189
|
+
if (typeof sql === 'object') {
|
|
190
|
+
_cmdOpt = sql;
|
|
191
|
+
_sql = _cmdOpt.sql;
|
|
192
|
+
if (_cmdOpt.values) _values = _cmdOpt.values;
|
|
193
|
+
} else {
|
|
194
|
+
_sql = sql;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const cmdParam = {
|
|
198
|
+
sql: _sql,
|
|
199
|
+
values: _values,
|
|
200
|
+
opts: _cmdOpt,
|
|
201
|
+
callback: _cb
|
|
202
|
+
};
|
|
203
|
+
if (options.trace) Error.captureStackTrace(cmdParam, ConnectionCallback._PARAM);
|
|
204
|
+
return cmdParam;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
static _EXECUTE_CMD(conn, cmdParam) {
|
|
208
|
+
new Promise(conn.prepare.bind(conn, cmdParam))
|
|
209
|
+
.then((prepare) => {
|
|
210
|
+
const opts = cmdParam.opts ? Object.assign(cmdParam.opts, { metaAsArray: true }) : { metaAsArray: true };
|
|
211
|
+
return prepare
|
|
212
|
+
.execute(cmdParam.values, opts, null, cmdParam.stack)
|
|
213
|
+
.then(([rows, meta]) => {
|
|
214
|
+
if (cmdParam.callback) {
|
|
215
|
+
cmdParam.callback(null, rows, meta);
|
|
216
|
+
}
|
|
217
|
+
})
|
|
218
|
+
.finally(() => prepare.close());
|
|
219
|
+
})
|
|
220
|
+
.catch((err) => {
|
|
221
|
+
if (conn.opts.logger.error) conn.opts.logger.error(err);
|
|
222
|
+
if (cmdParam.callback) cmdParam.callback(err);
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
prepare(sql, callback) {
|
|
227
|
+
let _cmdOpt, _sql;
|
|
228
|
+
if (typeof sql === 'object') {
|
|
229
|
+
_cmdOpt = sql;
|
|
230
|
+
_sql = _cmdOpt.sql;
|
|
92
231
|
} else {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
232
|
+
_sql = sql;
|
|
233
|
+
}
|
|
234
|
+
const cmdParam = {
|
|
235
|
+
sql: _sql,
|
|
236
|
+
opts: _cmdOpt,
|
|
237
|
+
callback: callback
|
|
238
|
+
};
|
|
239
|
+
if (this.#conn.opts.trace) Error.captureStackTrace(cmdParam);
|
|
240
|
+
return new Promise(this.#conn.prepare.bind(this.#conn, cmdParam))
|
|
241
|
+
.then((prepare) => {
|
|
242
|
+
if (callback) callback(null, prepare, null);
|
|
243
|
+
})
|
|
244
|
+
.catch(callback || this.#noop);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Execute a batch
|
|
249
|
+
* events to permit streaming big result-set
|
|
250
|
+
*
|
|
251
|
+
* @param sql sql parameter Object can be used to supersede the default options.
|
|
252
|
+
* Object must then have `sql` property.
|
|
253
|
+
* @param values object / array of placeholder values (not mandatory)
|
|
254
|
+
* @param callback callback
|
|
255
|
+
*/
|
|
256
|
+
batch(sql, values, callback) {
|
|
257
|
+
const cmdParam = ConnectionCallback._PARAM(this.#conn.opts, sql, values, callback);
|
|
258
|
+
this.#conn.batch(
|
|
259
|
+
cmdParam,
|
|
260
|
+
(res) => {
|
|
261
|
+
if (cmdParam.callback) cmdParam.callback(null, res);
|
|
262
|
+
},
|
|
263
|
+
(err) => {
|
|
264
|
+
if (cmdParam.callback) cmdParam.callback(err);
|
|
110
265
|
}
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Import sql file.
|
|
271
|
+
*
|
|
272
|
+
* @param opts JSON array with 2 possible fields: file and database
|
|
273
|
+
* @param cb callback
|
|
274
|
+
*/
|
|
275
|
+
importFile(opts, cb) {
|
|
276
|
+
if (!opts || !opts.file) {
|
|
277
|
+
if (cb)
|
|
278
|
+
cb(
|
|
279
|
+
Errors.createError(
|
|
280
|
+
'SQL file parameter is mandatory',
|
|
281
|
+
Errors.ER_MISSING_SQL_PARAMETER,
|
|
282
|
+
this.#conn.info,
|
|
283
|
+
'HY000',
|
|
284
|
+
null,
|
|
285
|
+
false,
|
|
286
|
+
null
|
|
287
|
+
)
|
|
288
|
+
);
|
|
289
|
+
return;
|
|
111
290
|
}
|
|
112
|
-
|
|
291
|
+
new Promise(this.#conn.importFile.bind(this.#conn, { file: opts.file, database: opts.database }))
|
|
292
|
+
.then(() => {
|
|
293
|
+
if (cb) cb();
|
|
294
|
+
})
|
|
295
|
+
.catch((err) => {
|
|
296
|
+
if (cb) cb(err);
|
|
297
|
+
});
|
|
298
|
+
}
|
|
113
299
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
300
|
+
/**
|
|
301
|
+
* Send an empty MySQL packet to ensure connection is active, and reset @@wait_timeout
|
|
302
|
+
* @param timeout (optional) timeout value in ms. If reached, throw error and close connection
|
|
303
|
+
* @param callback callback
|
|
304
|
+
*/
|
|
305
|
+
ping(timeout, callback) {
|
|
306
|
+
let _cmdOpt = {},
|
|
307
|
+
_cb;
|
|
308
|
+
if (typeof timeout === 'function') {
|
|
309
|
+
_cb = timeout;
|
|
119
310
|
} else {
|
|
120
|
-
|
|
311
|
+
_cmdOpt.timeout = timeout;
|
|
121
312
|
_cb = callback;
|
|
122
313
|
}
|
|
314
|
+
const cmdParam = {
|
|
315
|
+
opts: _cmdOpt,
|
|
316
|
+
callback: _cb
|
|
317
|
+
};
|
|
318
|
+
if (this.#conn.opts.trace) Error.captureStackTrace(cmdParam);
|
|
319
|
+
new Promise(this.#conn.ping.bind(this.#conn, cmdParam)).then(_cb || this.#noop).catch(_cb || this.#noop);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Send a reset command that will
|
|
324
|
+
* - rollback any open transaction
|
|
325
|
+
* - reset transaction isolation level
|
|
326
|
+
* - reset session variables
|
|
327
|
+
* - delete user variables
|
|
328
|
+
* - remove temporary tables
|
|
329
|
+
* - remove all PREPARE statement
|
|
330
|
+
*
|
|
331
|
+
* @param callback callback
|
|
332
|
+
*/
|
|
333
|
+
reset(callback) {
|
|
334
|
+
const cmdParam = {};
|
|
335
|
+
if (this.#conn.opts.trace) Error.captureStackTrace(cmdParam);
|
|
336
|
+
return new Promise(this.#conn.reset.bind(this.#conn, cmdParam))
|
|
337
|
+
.then(callback || this.#noop)
|
|
338
|
+
.catch(callback || this.#noop);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Indicates the state of the connection as the driver knows it
|
|
343
|
+
* @returns {boolean}
|
|
344
|
+
*/
|
|
345
|
+
isValid() {
|
|
346
|
+
return this.#conn.isValid();
|
|
347
|
+
}
|
|
123
348
|
|
|
124
|
-
|
|
349
|
+
/**
|
|
350
|
+
* Terminate connection gracefully.
|
|
351
|
+
*
|
|
352
|
+
* @param callback callback
|
|
353
|
+
*/
|
|
354
|
+
end(callback) {
|
|
355
|
+
const cmdParam = {};
|
|
356
|
+
if (this.#conn.opts.trace) Error.captureStackTrace(cmdParam);
|
|
357
|
+
new Promise(this.#conn.end.bind(this.#conn, cmdParam))
|
|
125
358
|
.then(() => {
|
|
126
|
-
if (
|
|
359
|
+
if (callback) callback();
|
|
127
360
|
})
|
|
128
|
-
.catch(
|
|
129
|
-
}
|
|
361
|
+
.catch(callback || this.#noop);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Alias for destroy.
|
|
366
|
+
*/
|
|
367
|
+
close() {
|
|
368
|
+
this.destroy();
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Force connection termination by closing the underlying socket and killing server process if any.
|
|
373
|
+
*/
|
|
374
|
+
destroy() {
|
|
375
|
+
this.#conn.destroy();
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
pause() {
|
|
379
|
+
this.#conn.pause();
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
resume() {
|
|
383
|
+
this.#conn.resume();
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
format(sql, values) {
|
|
387
|
+
this.#conn.format(sql, values);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* return current connected server version information.
|
|
392
|
+
*
|
|
393
|
+
* @returns {*}
|
|
394
|
+
*/
|
|
395
|
+
serverVersion() {
|
|
396
|
+
return this.#conn.serverVersion();
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Change option "debug" during connection.
|
|
401
|
+
* @param val debug value
|
|
402
|
+
*/
|
|
403
|
+
debug(val) {
|
|
404
|
+
return this.#conn.debug(val);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
debugCompress(val) {
|
|
408
|
+
return this.#conn.debugCompress(val);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
escape(val) {
|
|
412
|
+
return this.#conn.escape(val);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
escapeId(val) {
|
|
416
|
+
return this.#conn.escapeId(val);
|
|
417
|
+
}
|
|
130
418
|
|
|
131
419
|
//*****************************************************************
|
|
132
|
-
//
|
|
420
|
+
// internal public testing methods
|
|
133
421
|
//*****************************************************************
|
|
134
422
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
423
|
+
get __tests() {
|
|
424
|
+
return this.#conn.__tests;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
connect(callback) {
|
|
428
|
+
if (!callback) {
|
|
429
|
+
throw new Errors.createError(
|
|
430
|
+
'missing mandatory callback parameter',
|
|
431
|
+
Errors.ER_MISSING_PARAMETER,
|
|
432
|
+
this.#conn.info
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
switch (this.#conn.status) {
|
|
436
|
+
case Status.NOT_CONNECTED:
|
|
437
|
+
case Status.CONNECTING:
|
|
438
|
+
case Status.AUTHENTICATING:
|
|
439
|
+
case Status.INIT_CMD:
|
|
440
|
+
this.once('connect', callback);
|
|
441
|
+
break;
|
|
442
|
+
case Status.CONNECTED:
|
|
443
|
+
callback.call(this);
|
|
444
|
+
break;
|
|
445
|
+
case Status.CLOSING:
|
|
446
|
+
case Status.CLOSED:
|
|
447
|
+
callback.call(
|
|
448
|
+
this,
|
|
449
|
+
Errors.createError(
|
|
450
|
+
'Connection closed',
|
|
451
|
+
Errors.ER_CONNECTION_ALREADY_CLOSED,
|
|
452
|
+
this.#conn.info,
|
|
453
|
+
'08S01',
|
|
454
|
+
null,
|
|
455
|
+
true
|
|
456
|
+
)
|
|
457
|
+
);
|
|
458
|
+
break;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
//*****************************************************************
|
|
463
|
+
// EventEmitter proxy methods
|
|
464
|
+
//*****************************************************************
|
|
465
|
+
|
|
466
|
+
on(eventName, listener) {
|
|
467
|
+
this.#conn.on.call(this.#conn, eventName, listener);
|
|
468
|
+
return this;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
off(eventName, listener) {
|
|
472
|
+
this.#conn.off.call(this.#conn, eventName, listener);
|
|
473
|
+
return this;
|
|
474
|
+
}
|
|
157
475
|
|
|
158
|
-
|
|
476
|
+
once(eventName, listener) {
|
|
477
|
+
this.#conn.once.call(this.#conn, eventName, listener);
|
|
478
|
+
return this;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
listeners(eventName) {
|
|
482
|
+
return this.#conn.listeners.call(this.#conn, eventName);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
addListener(eventName, listener) {
|
|
486
|
+
this.#conn.addListener.call(this.#conn, eventName, listener);
|
|
487
|
+
return this;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
eventNames() {
|
|
491
|
+
return this.#conn.eventNames.call(this.#conn);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
getMaxListeners() {
|
|
495
|
+
return this.#conn.getMaxListeners.call(this.#conn);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
listenerCount(eventName, listener) {
|
|
499
|
+
return this.#conn.listenerCount.call(this.#conn, eventName, listener);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
prependListener(eventName, listener) {
|
|
503
|
+
this.#conn.prependListener.call(this.#conn, eventName, listener);
|
|
504
|
+
return this;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
prependOnceListener(eventName, listener) {
|
|
508
|
+
this.#conn.prependOnceListener.call(this.#conn, eventName, listener);
|
|
509
|
+
return this;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
removeAllListeners(eventName, listener) {
|
|
513
|
+
this.#conn.removeAllListeners.call(this.#conn, eventName, listener);
|
|
514
|
+
return this;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
removeListener(eventName, listener) {
|
|
518
|
+
this.#conn.removeListener.call(this.#conn, eventName, listener);
|
|
519
|
+
return this;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
setMaxListeners(n) {
|
|
523
|
+
this.#conn.setMaxListeners.call(this.#conn, n);
|
|
524
|
+
return this;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
rawListeners(eventName) {
|
|
528
|
+
return this.#conn.rawListeners.call(this.#conn, eventName);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
159
531
|
|
|
160
532
|
module.exports = ConnectionCallback;
|