@tachybase/module-multi-app 1.6.0 → 1.6.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/README.md +34 -34
- package/README.zh-CN.md +34 -34
- package/client.d.ts +1 -1
- package/client.js +1 -1
- package/dist/externalVersion.js +5 -5
- package/dist/locale/en-US.json +48 -48
- package/dist/locale/es-ES.json +9 -9
- package/dist/locale/ko_KR.json +11 -11
- package/dist/locale/pt-BR.json +9 -9
- package/dist/locale/zh-CN.json +58 -58
- 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/server.d.ts +2 -2
- package/server.js +1 -1
- 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,3 +1,8 @@
|
|
|
1
|
+
// SPDX-License-Identifier: LGPL-2.1-or-later
|
|
2
|
+
// Copyright (c) 2015-2024 MariaDB Corporation Ab
|
|
3
|
+
|
|
4
|
+
// noinspection JSBitwiseOperatorUsage
|
|
5
|
+
|
|
1
6
|
'use strict';
|
|
2
7
|
|
|
3
8
|
const Iconv = require('iconv-lite');
|
|
@@ -5,26 +10,26 @@ const Capabilities = require('../const/capabilities');
|
|
|
5
10
|
const Ed25519PasswordAuth = require('./handshake/auth/ed25519-password-auth');
|
|
6
11
|
const NativePasswordAuth = require('./handshake/auth/native-password-auth');
|
|
7
12
|
const Collations = require('../const/collations');
|
|
8
|
-
const
|
|
13
|
+
const Authentication = require('./handshake/authentication');
|
|
9
14
|
|
|
10
15
|
/**
|
|
11
16
|
* send a COM_CHANGE_USER: resets the connection and re-authenticates with the given credentials
|
|
12
17
|
* see https://mariadb.com/kb/en/library/com_change_user/
|
|
13
18
|
*/
|
|
14
|
-
class ChangeUser extends
|
|
15
|
-
constructor(
|
|
16
|
-
super(resolve, reject, () => {},
|
|
17
|
-
this.opts
|
|
19
|
+
class ChangeUser extends Authentication {
|
|
20
|
+
constructor(cmdParam, connOpts, resolve, reject, getSocket) {
|
|
21
|
+
super(cmdParam, resolve, reject, () => {}, getSocket);
|
|
22
|
+
this.configAssign(connOpts, cmdParam.opts);
|
|
18
23
|
}
|
|
19
24
|
|
|
20
25
|
start(out, opts, info) {
|
|
21
|
-
|
|
26
|
+
if (opts.logger.query) opts.logger.query(`CHANGE USER to '${this.opts.user || ''}'`);
|
|
22
27
|
let authToken;
|
|
23
28
|
const pwd = Array.isArray(this.opts.password) ? this.opts.password[0] : this.opts.password;
|
|
24
29
|
switch (info.defaultPluginName) {
|
|
25
30
|
case 'mysql_native_password':
|
|
26
31
|
case '':
|
|
27
|
-
authToken = NativePasswordAuth.
|
|
32
|
+
authToken = NativePasswordAuth.encryptSha1Password(pwd, info.seed);
|
|
28
33
|
break;
|
|
29
34
|
case 'client_ed25519':
|
|
30
35
|
authToken = Ed25519PasswordAuth.encryptPassword(pwd, info.seed);
|
|
@@ -52,8 +57,20 @@ class ChangeUser extends Handshake {
|
|
|
52
57
|
out.writeInt8(0);
|
|
53
58
|
info.database = this.opts.database;
|
|
54
59
|
}
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
// handle default collation.
|
|
61
|
+
if (this.opts.collation) {
|
|
62
|
+
// collation has been set using charset.
|
|
63
|
+
// If server use same charset, use server collation.
|
|
64
|
+
if (!this.opts.charset || info.collation.charset !== this.opts.collation.charset) {
|
|
65
|
+
info.collation = this.opts.collation;
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
// if not utf8mb4 and no configuration, force to use UTF8MB4_UNICODE_CI
|
|
69
|
+
if (info.collation.charset !== 'utf8' || info.collation.maxLength === 3) {
|
|
70
|
+
info.collation = Collations.fromIndex(224);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
out.writeInt16(info.collation.index);
|
|
57
74
|
|
|
58
75
|
if (info.clientCapabilities & Capabilities.PLUGIN_AUTH) {
|
|
59
76
|
out.writeString(info.defaultPluginName);
|
|
@@ -65,23 +82,23 @@ class ChangeUser extends Handshake {
|
|
|
65
82
|
let initPos = out.pos; //save position, assuming connection attributes length will be less than 2 bytes length
|
|
66
83
|
out.writeInt16(0);
|
|
67
84
|
|
|
68
|
-
const encoding =
|
|
85
|
+
const encoding = info.collation.charset;
|
|
69
86
|
|
|
70
|
-
|
|
71
|
-
|
|
87
|
+
writeAttribute(out, '_client_name', encoding);
|
|
88
|
+
writeAttribute(out, 'MariaDB connector/Node', encoding);
|
|
72
89
|
|
|
73
90
|
let packageJson = require('../../package.json');
|
|
74
|
-
|
|
75
|
-
|
|
91
|
+
writeAttribute(out, '_client_version', encoding);
|
|
92
|
+
writeAttribute(out, packageJson.version, encoding);
|
|
76
93
|
|
|
77
|
-
|
|
78
|
-
|
|
94
|
+
writeAttribute(out, '_node_version', encoding);
|
|
95
|
+
writeAttribute(out, process.versions.node, encoding);
|
|
79
96
|
|
|
80
97
|
if (opts.connectAttributes !== true) {
|
|
81
98
|
let attrNames = Object.keys(this.opts.connectAttributes);
|
|
82
99
|
for (let k = 0; k < attrNames.length; ++k) {
|
|
83
|
-
|
|
84
|
-
|
|
100
|
+
writeAttribute(out, attrNames[k], encoding);
|
|
101
|
+
writeAttribute(out, this.opts.connectAttributes[attrNames[k]], encoding);
|
|
85
102
|
}
|
|
86
103
|
}
|
|
87
104
|
|
|
@@ -89,8 +106,8 @@ class ChangeUser extends Handshake {
|
|
|
89
106
|
out.writeInt16AtPos(initPos);
|
|
90
107
|
}
|
|
91
108
|
|
|
92
|
-
out.
|
|
93
|
-
this.onPacketReceive = this.handshakeResult;
|
|
109
|
+
out.flush();
|
|
110
|
+
this.plugin.onPacketReceive = this.handshakeResult.bind(this);
|
|
94
111
|
}
|
|
95
112
|
|
|
96
113
|
/**
|
|
@@ -98,50 +115,43 @@ class ChangeUser extends Handshake {
|
|
|
98
115
|
* a little faster than Object.assign() since doest copy all information
|
|
99
116
|
*
|
|
100
117
|
* @param connOpts connection global configuration
|
|
101
|
-
* @param
|
|
118
|
+
* @param cmdOpts current options
|
|
102
119
|
*/
|
|
103
|
-
configAssign(connOpts,
|
|
104
|
-
if (!
|
|
120
|
+
configAssign(connOpts, cmdOpts) {
|
|
121
|
+
if (!cmdOpts) {
|
|
105
122
|
this.opts = connOpts;
|
|
106
123
|
return;
|
|
107
124
|
}
|
|
108
|
-
this.opts
|
|
109
|
-
this.opts.connectAttributes = opt.connectAttributes
|
|
110
|
-
? opt.connectAttributes
|
|
111
|
-
: connOpts.connectAttributes;
|
|
125
|
+
this.opts = cmdOpts ? Object.assign({}, connOpts, cmdOpts) : connOpts;
|
|
112
126
|
|
|
113
|
-
if (
|
|
114
|
-
this.opts.collation = Collations.fromCharset(
|
|
127
|
+
if (cmdOpts.charset && typeof cmdOpts.charset === 'string') {
|
|
128
|
+
this.opts.collation = Collations.fromCharset(cmdOpts.charset.toLowerCase());
|
|
115
129
|
if (this.opts.collation === undefined) {
|
|
116
|
-
this.opts.collation = Collations.fromName(
|
|
130
|
+
this.opts.collation = Collations.fromName(cmdOpts.charset.toUpperCase());
|
|
117
131
|
if (this.opts.collation !== undefined) {
|
|
118
|
-
|
|
132
|
+
this.opts.logger.warning(
|
|
119
133
|
"warning: please use option 'collation' " +
|
|
120
134
|
"in replacement of 'charset' when using a collation name ('" +
|
|
121
|
-
|
|
135
|
+
cmdOpts.charset +
|
|
122
136
|
"')\n" +
|
|
123
137
|
"(collation looks like 'UTF8MB4_UNICODE_CI', charset like 'utf8')."
|
|
124
138
|
);
|
|
125
139
|
}
|
|
126
140
|
}
|
|
127
|
-
if (this.opts.collation === undefined)
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const initial = opt.collation;
|
|
141
|
+
if (this.opts.collation === undefined) throw new RangeError("Unknown charset '" + cmdOpts.charset + "'");
|
|
142
|
+
} else if (cmdOpts.collation && typeof cmdOpts.collation === 'string') {
|
|
143
|
+
const initial = cmdOpts.collation;
|
|
131
144
|
this.opts.collation = Collations.fromName(initial.toUpperCase());
|
|
132
|
-
if (this.opts.collation === undefined)
|
|
133
|
-
throw new RangeError("Unknown collation '" + initial + "'");
|
|
145
|
+
if (this.opts.collation === undefined) throw new RangeError("Unknown collation '" + initial + "'");
|
|
134
146
|
} else {
|
|
135
|
-
this.opts.collation = Collations.fromIndex(
|
|
147
|
+
this.opts.collation = Collations.fromIndex(cmdOpts.charsetNumber) || connOpts.collation;
|
|
136
148
|
}
|
|
137
|
-
connOpts.password =
|
|
149
|
+
connOpts.password = cmdOpts.password;
|
|
138
150
|
}
|
|
139
151
|
}
|
|
140
152
|
|
|
141
|
-
function
|
|
142
|
-
let param = Buffer.isEncoding(encoding)
|
|
143
|
-
? Buffer.from(val, encoding)
|
|
144
|
-
: Iconv.encode(val, encoding);
|
|
153
|
+
function writeAttribute(out, val, encoding) {
|
|
154
|
+
let param = Buffer.isEncoding(encoding) ? Buffer.from(val, encoding) : Iconv.encode(val, encoding);
|
|
145
155
|
out.writeLengthCoded(param.length);
|
|
146
156
|
out.writeBuffer(param, 0, param.length);
|
|
147
157
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// SPDX-License-Identifier: LGPL-2.1-or-later
|
|
2
|
+
// Copyright (c) 2015-2024 MariaDB Corporation Ab
|
|
3
|
+
|
|
4
|
+
'use strict';
|
|
5
|
+
|
|
6
|
+
const PrepareWrapper = require('./prepare-wrapper');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Prepare cache wrapper
|
|
10
|
+
* see https://mariadb.com/kb/en/com_stmt_prepare/#com_stmt_prepare_ok
|
|
11
|
+
*/
|
|
12
|
+
class PrepareCacheWrapper {
|
|
13
|
+
#use = 0;
|
|
14
|
+
#cached;
|
|
15
|
+
#prepare;
|
|
16
|
+
|
|
17
|
+
constructor(prepare) {
|
|
18
|
+
this.#prepare = prepare;
|
|
19
|
+
this.#cached = true;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
incrementUse() {
|
|
23
|
+
this.#use += 1;
|
|
24
|
+
return new PrepareWrapper(this, this.#prepare);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
unCache() {
|
|
28
|
+
this.#cached = false;
|
|
29
|
+
if (this.#use === 0) {
|
|
30
|
+
this.#prepare.close();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
decrementUse() {
|
|
35
|
+
this.#use -= 1;
|
|
36
|
+
if (this.#use === 0 && !this.#cached) {
|
|
37
|
+
this.#prepare.close();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
toString() {
|
|
42
|
+
return 'Prepare{use:' + this.#use + ',cached:' + this.#cached + '}';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = PrepareCacheWrapper;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// SPDX-License-Identifier: LGPL-2.1-or-later
|
|
2
|
+
// Copyright (c) 2015-2024 MariaDB Corporation Ab
|
|
3
|
+
|
|
4
|
+
'use strict';
|
|
5
|
+
const Errors = require('../../misc/errors');
|
|
6
|
+
const ExecuteStream = require('../execute-stream');
|
|
7
|
+
const Parser = require('../parser');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Prepare result
|
|
11
|
+
* see https://mariadb.com/kb/en/com_stmt_prepare/#com_stmt_prepare_ok
|
|
12
|
+
*/
|
|
13
|
+
class PrepareResultPacket {
|
|
14
|
+
#conn;
|
|
15
|
+
constructor(statementId, parameterCount, columns, database, sql, placeHolderIndex, conn) {
|
|
16
|
+
this.id = statementId;
|
|
17
|
+
this.parameterCount = parameterCount;
|
|
18
|
+
this.columns = columns;
|
|
19
|
+
this.database = database;
|
|
20
|
+
this.query = sql;
|
|
21
|
+
this.closed = false;
|
|
22
|
+
this._placeHolderIndex = placeHolderIndex;
|
|
23
|
+
this.#conn = conn;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
get conn() {
|
|
27
|
+
return this.#conn;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
execute(values, opts, cb, stack) {
|
|
31
|
+
let _opts = opts,
|
|
32
|
+
_cb = cb;
|
|
33
|
+
|
|
34
|
+
if (typeof _opts === 'function') {
|
|
35
|
+
_cb = _opts;
|
|
36
|
+
_opts = undefined;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (this.isClose()) {
|
|
40
|
+
let sql = this.query;
|
|
41
|
+
if (this.conn.opts.logParam) {
|
|
42
|
+
if (this.query.length > this.conn.opts.debugLen) {
|
|
43
|
+
sql = this.query.substring(0, this.conn.opts.debugLen) + '...';
|
|
44
|
+
} else {
|
|
45
|
+
let sqlMsg = this.query + ' - parameters:';
|
|
46
|
+
sql = Parser.logParameters(this.conn.opts, sqlMsg, values);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const error = Errors.createError(
|
|
51
|
+
`Execute fails, prepare command as already been closed`,
|
|
52
|
+
Errors.ER_PREPARE_CLOSED,
|
|
53
|
+
null,
|
|
54
|
+
'22000',
|
|
55
|
+
sql
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
if (!_cb) {
|
|
59
|
+
return Promise.reject(error);
|
|
60
|
+
} else {
|
|
61
|
+
_cb(error);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const cmdParam = {
|
|
67
|
+
sql: this.query,
|
|
68
|
+
values: values,
|
|
69
|
+
opts: _opts,
|
|
70
|
+
callback: _cb
|
|
71
|
+
};
|
|
72
|
+
if (stack) cmdParam.stack = stack;
|
|
73
|
+
const conn = this.conn;
|
|
74
|
+
const promise = new Promise((resolve, reject) => conn.executePromise.call(conn, cmdParam, this, resolve, reject));
|
|
75
|
+
if (!_cb) {
|
|
76
|
+
return promise;
|
|
77
|
+
} else {
|
|
78
|
+
promise
|
|
79
|
+
.then((res) => {
|
|
80
|
+
if (_cb) _cb(null, res, null);
|
|
81
|
+
})
|
|
82
|
+
.catch(_cb || function (err) {});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
executeStream(values, opts, cb, stack) {
|
|
87
|
+
let _opts = opts,
|
|
88
|
+
_cb = cb;
|
|
89
|
+
|
|
90
|
+
if (typeof _opts === 'function') {
|
|
91
|
+
_cb = _opts;
|
|
92
|
+
_opts = undefined;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (this.isClose()) {
|
|
96
|
+
const error = Errors.createError(
|
|
97
|
+
`Execute fails, prepare command as already been closed`,
|
|
98
|
+
Errors.ER_PREPARE_CLOSED,
|
|
99
|
+
null,
|
|
100
|
+
'22000',
|
|
101
|
+
this.query
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
if (!_cb) {
|
|
105
|
+
throw error;
|
|
106
|
+
} else {
|
|
107
|
+
_cb(error);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const cmdParam = {
|
|
113
|
+
sql: this.query,
|
|
114
|
+
values: values,
|
|
115
|
+
opts: _opts,
|
|
116
|
+
callback: _cb
|
|
117
|
+
};
|
|
118
|
+
if (stack) cmdParam.stack = stack;
|
|
119
|
+
|
|
120
|
+
const cmd = new ExecuteStream(cmdParam, this.conn.opts, this, this.conn.socket);
|
|
121
|
+
if (this.conn.opts.logger.error) cmd.on('error', this.conn.opts.logger.error);
|
|
122
|
+
this.conn.addCommand(cmd, true);
|
|
123
|
+
return cmd.inStream;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
isClose() {
|
|
127
|
+
return this.closed;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
close() {
|
|
131
|
+
if (!this.closed) {
|
|
132
|
+
this.closed = true;
|
|
133
|
+
this.#conn.emit('close_prepare', this);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
toString() {
|
|
137
|
+
return 'Prepare{closed:' + this.closed + '}';
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
module.exports = PrepareResultPacket;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// SPDX-License-Identifier: LGPL-2.1-or-later
|
|
2
|
+
// Copyright (c) 2015-2024 MariaDB Corporation Ab
|
|
3
|
+
|
|
4
|
+
'use strict';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Prepare result wrapper
|
|
8
|
+
* This permit to ensure that cache can be close only one time cache.
|
|
9
|
+
*/
|
|
10
|
+
class PrepareWrapper {
|
|
11
|
+
#closed = false;
|
|
12
|
+
#cacheWrapper;
|
|
13
|
+
#prepare;
|
|
14
|
+
#conn;
|
|
15
|
+
|
|
16
|
+
constructor(cacheWrapper, prepare) {
|
|
17
|
+
this.#cacheWrapper = cacheWrapper;
|
|
18
|
+
this.#prepare = prepare;
|
|
19
|
+
this.#conn = prepare.conn;
|
|
20
|
+
this.execute = this.#prepare.execute;
|
|
21
|
+
this.executeStream = this.#prepare.executeStream;
|
|
22
|
+
}
|
|
23
|
+
get conn() {
|
|
24
|
+
return this.#conn;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
get id() {
|
|
28
|
+
return this.#prepare.id;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
get parameterCount() {
|
|
32
|
+
return this.#prepare.parameterCount;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
get _placeHolderIndex() {
|
|
36
|
+
return this.#prepare._placeHolderIndex;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
get columns() {
|
|
40
|
+
return this.#prepare.columns;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
set columns(columns) {
|
|
44
|
+
this.#prepare.columns = columns;
|
|
45
|
+
}
|
|
46
|
+
get database() {
|
|
47
|
+
return this.#prepare.database;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
get query() {
|
|
51
|
+
return this.#prepare.query;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
isClose() {
|
|
55
|
+
return this.#closed;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
close() {
|
|
59
|
+
if (!this.#closed) {
|
|
60
|
+
this.#closed = true;
|
|
61
|
+
this.#cacheWrapper.decrementUse();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
toString() {
|
|
66
|
+
return 'PrepareWrapper{closed:' + this.#closed + ',cache:' + this.#cacheWrapper + '}';
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
module.exports = PrepareWrapper;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// SPDX-License-Identifier: LGPL-2.1-or-later
|
|
2
|
+
// Copyright (c) 2015-2024 MariaDB Corporation Ab
|
|
3
|
+
|
|
4
|
+
'use strict';
|
|
5
|
+
|
|
6
|
+
const Command = require('./command');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Close prepared statement
|
|
10
|
+
* see https://mariadb.com/kb/en/3-binary-protocol-prepared-statements-com_stmt_close/
|
|
11
|
+
*/
|
|
12
|
+
class ClosePrepare extends Command {
|
|
13
|
+
constructor(cmdParam, resolve, reject, prepare) {
|
|
14
|
+
super(cmdParam, resolve, reject);
|
|
15
|
+
this.prepare = prepare;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
start(out, opts, info) {
|
|
19
|
+
if (opts.logger.query) opts.logger.query(`CLOSE PREPARE: (${this.prepare.id}) ${this.prepare.query}`);
|
|
20
|
+
const closeCmd = new Uint8Array([
|
|
21
|
+
5,
|
|
22
|
+
0,
|
|
23
|
+
0,
|
|
24
|
+
0,
|
|
25
|
+
0x19,
|
|
26
|
+
this.prepare.id,
|
|
27
|
+
this.prepare.id >> 8,
|
|
28
|
+
this.prepare.id >> 16,
|
|
29
|
+
this.prepare.id >> 24
|
|
30
|
+
]);
|
|
31
|
+
out.fastFlush(this, closeCmd);
|
|
32
|
+
this.onPacketReceive = null;
|
|
33
|
+
this.emit('send_end');
|
|
34
|
+
this.emit('end');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports = ClosePrepare;
|