Skip to content

Commit d0d55dc

Browse files
committed
Merge branch 'develop'
# Conflicts: # .travis.yml # test/integration/test-connection-opts.js
2 parents fd6cdde + 8e20d41 commit d0d55dc

29 files changed

+593
-219
lines changed

.travis.yml

Lines changed: 16 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,45 @@
1-
os: linux
2-
dist: jammy
31
language: node_js
4-
services: docker
52
node_js: 20
6-
addons:
7-
hosts:
8-
- mariadb.example.com
9-
3+
version: ~> 1.0
104

115
before_install:
12-
- git clone https://github.com/mariadb-corporation/connector-test-machine.git
13-
14-
15-
install:
166
- |-
177
case $TRAVIS_OS_NAME in
188
windows)
199
powershell -Command Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe -Outfile codecov.exe
20-
;;
21-
linux)
22-
curl -Os https://uploader.codecov.io/latest/linux/codecov
23-
chmod +x codecov
24-
ls -lrt
25-
;;
26-
esac
27-
- |-
28-
case $TRAVIS_OS_NAME in
29-
windows)
3010
choco install -y --force nodejs-lts
3111
# force refresh path
3212
export PATH=$(cmd.exe //c "refreshenv > nul & C:\Progra~1\Git\bin\bash -c 'echo \$PATH' ")
33-
connector-test-machine/launch.bat -t "$srv" -v "$v" -d testn
3413
;;
3514
linux)
36-
source connector-test-machine/launch.sh -t "$srv" -v "$v" -d testn -l "$local" -c "$CLEAR_TEXT" -s "$DISABLE_SSL"
15+
curl -Os https://uploader.codecov.io/latest/linux/codecov
16+
chmod +x codecov
17+
ls -lrt
3718
;;
3819
esac
3920
4021
env:
41-
global:
42-
- RUN_LONG_TEST=1
43-
- CLEAR_TEXT=0
22+
global: RUN_LONG_TEST=1 CLEAR_TEXT=0 DB=testn
4423

45-
stages:
46-
- Minimal
47-
- name: Enterprise
48-
if: type = push AND fork = false
49-
- Community
24+
import: mariadb-corporation/connector-test-machine:common-build.yml@master
5025

5126
jobs:
52-
fast_finish: true
53-
allow_failures:
54-
- env: srv=build
55-
- env: srv=xpand RUN_LONG_TEST=0
5627
include:
57-
- stage: Minimal
58-
env: srv=mariadb v=10.6 local=1 packet=40
59-
name: "CS 10.6"
60-
- env: srv=mariadb-es v=10.6
61-
name: "ES 10.6"
62-
if: type = push AND fork = false
63-
64-
- stage: Enterprise
65-
env: srv=mariadb-es v=10.4
66-
name: "ES 10.4"
67-
if: type = push AND fork = false
68-
- env: srv=mariadb-es v=10.5
69-
name: "ES 10.5"
70-
if: type = push AND fork = false
71-
- env: srv=mariadb-es-test v=23.08
72-
name: "ES 23.08"
73-
if: type = push AND fork = false
74-
- env: srv=maxscale
75-
name: "Maxscale"
76-
- env: srv=xpand RUN_LONG_TEST=0
77-
name: "Xpand"
78-
79-
- stage: Community
80-
env: srv=mariadb v=10.6
81-
os: windows
82-
language: shell
83-
name: "CS 10.6 - Windows"
84-
- env: srv=mariadb v=10.4 local=1
85-
dist: bionic
86-
node_js: 16
87-
name: "CS 10.4"
88-
- env: srv=mariadb v=10.5 local=1 DISABLE_SSL=1
89-
dist: bionic
90-
name: "CS 10.5 - node.js 14"
91-
node_js: 14
92-
- env: srv=mariadb v=10.11 local=1
28+
- stage: Language
29+
env: srv=mariadb v=10.11 local=1
9330
name: "CS 10.11 - node.js 16"
9431
node_js: 16
95-
- env: srv=mariadb v=11.0 local=1 CLEAR_TEXT=1
32+
- stage: Language
33+
env: srv=mariadb v=10.11 local=1 CLEAR_TEXT=1
9634
node_js: 18
97-
name: "CS 11.0 - node.js 18"
98-
- env: srv=mariadb v=11.1 local=1
99-
name: "CS 11.1 - node.js 20"
35+
name: "CS 10.11 - node.js 18"
36+
- stage: Language
37+
env: srv=mariadb v=10.11 local=1 DISABLE_SSL=1
38+
name: "CS 10.11 - node.js 20"
10039
node_js: 20
101-
- env: srv=mysql v=5.7
102-
name: "MySQL 5.7"
103-
- env: srv=mysql v=8.0
104-
name: "MySQL 8.0"
105-
- env: srv=mariadb v=10.6 BENCH=1 local=1
40+
- stage: Benchmarks
41+
env: srv=mariadb v=10.11 BENCH=1 local=1
10642
name: "Benchmarks"
107-
node_js: 18
108-
dist: focal
109-
- env: srv=build
110-
name: "CS build"
11143

11244
script:
11345
- npm install
@@ -131,6 +63,3 @@ script:
13163
13264
after_success:
13365
- if [ -z "$BENCH" ] ; then npm run coverage:report; fi
134-
135-
after_failure:
136-
- if [ "$srv" == "maxscale" ] ; then docker-compose -f ${COMPOSE_FILE} exec -u root maxscale tail -500 /var/log/maxscale/maxscale.log; fi

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Change Log
22

3+
## [3.2.3](https://github.com/mariadb-corporation/mariadb-connector-nodejs/tree/3.2.3) (Dec 2023)
4+
[Full Changelog](https://github.com/mariadb-corporation/mariadb-connector-nodejs/compare/3.2.2...3.2.3)
5+
6+
* CONJS-207 Add support for connection redirection
7+
* CONJS-271 wrong binary decoding of 00:00:00 TIME values
8+
* CONJS-272 Error doesn't always have parameters according to option
9+
* CONJS-273 Bulk insert error when last bunch of parameters is reaching max_allowed_packet
10+
* CONJS-274 permit disabling BULK insert for one batch
11+
* CONJS-207 Add support for connection redirection
12+
13+
314
## [3.2.2](https://github.com/mariadb-corporation/mariadb-connector-nodejs/tree/3.2.2) (Oct 2023)
415
[Full Changelog](https://github.com/mariadb-corporation/mariadb-connector-nodejs/compare/3.2.1...3.2.2)
516

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
**Non-blocking MariaDB and MySQL client for Node.js.**
1515

16-
MariaDB and MySQL client, 100% JavaScript, with TypeScript definition, with the Promise API.
16+
MariaDB and MySQL client, 100% JavaScript, with TypeScript definition, with the Promise API, distributed under the LGPL license version 2.1 or later (LGPL-2.1-or-later)
1717

1818

1919
## Documentation

documentation/callback-api.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,9 +523,9 @@ https.get("https://node.green/#ES2018-features-Promise-prototype-finally-basic-s
523523

524524
Queries issued from the Connector return two different kinds of results: a JSON object and an array, depending on the type of query you issue. Queries that write to the database, such as `INSERT`, `DELETE` and `UPDATE` commands return a JSON object with the following properties:
525525

526-
* `affectedRows`: Indicates the number of rows affected by the query.
527-
* `insertId`: Shows the last auto-increment value from an `INSERT`.
528-
* `warningStatus`: Indicates whether the query ended with a warning.
526+
* `affectedRows`: An integer listing the number of affected rows.
527+
* `insertId`: An integer noting the auto-increment ID. In case multiple rows have been inserted, this corresponds to the FIRST auto-increment value.
528+
* `warningStatus`: An integer indicating whether the query ended with a warning.
529529

530530
```js
531531
connection.query(

documentation/promise-api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ https.get(
600600
Queries return two different kinds of results, depending on the type of query you execute. When you execute write statements, (such as `INSERT`, `DELETE` and `UPDATE`), the method returns a JSON object with the following properties:
601601

602602
* `affectedRows`: An integer listing the number of affected rows.
603-
* `insertId`: An integer noting the auto-increment ID of the last row written to the table.
603+
* `insertId`: An integer noting the auto-increment ID. In case multiple rows have been inserted, this corresponds to the FIRST auto-increment value.
604604
* `warningStatus`: An integer indicating whether the query ended with a warning.
605605

606606
```js

lib/cmd/batch-bulk.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ class BatchBulk extends Parser {
213213
*/
214214
sendComStmtBulkExecute(out, opts, info) {
215215
if (opts.logger.query)
216-
opts.logger.query(`BULK: (${this.prepare.id}) sql: ${opts.logger.logParam ? this.displaySql() : this.sql}`);
216+
opts.logger.query(`BULK: (${this.prepare.id}) sql: ${opts.logParam ? this.displaySql() : this.sql}`);
217217
const parameterCount = this.prepare.parameterCount;
218218
this.rowIdx = 0;
219219
this.vals = this.values[this.rowIdx++];
@@ -250,7 +250,7 @@ class BatchBulk extends Parser {
250250
out.writeBuffer(lastCmdData, 0, lastCmdData.length);
251251
out.mark();
252252
lastCmdData = null;
253-
if (!this.rowIdx >= this.values.length) {
253+
if (this.rowIdx >= this.values.length) {
254254
break;
255255
}
256256
this.vals = this.values[this.rowIdx++];
@@ -353,10 +353,9 @@ class BatchBulk extends Parser {
353353
for (let i = 0; i < this.initialValues.length; i++) {
354354
if (i !== 0) sqlMsg += ',';
355355
let param = this.initialValues[i];
356-
sqlMsg = this.logParameters(sqlMsg, param);
356+
sqlMsg = Parser.logParameters(this.opts, sqlMsg, param);
357357
if (sqlMsg.length > this.opts.debugLen) {
358-
sqlMsg = sqlMsg.substring(0, this.opts.debugLen) + '...';
359-
break;
358+
return sqlMsg.substring(0, this.opts.debugLen) + '...';
360359
}
361360
}
362361
sqlMsg += ']';
@@ -482,9 +481,9 @@ class BatchBulk extends Parser {
482481
if (this.values[r].length < nbParameter) {
483482
this.emit('send_end');
484483
this.throwNewError(
485-
`Expect ${nbParameter} parameters, but at index ${r}, parameters only contains ${
486-
this.values[r].length
487-
}\n ${this.displaySql()}`,
484+
`Expect ${nbParameter} parameters, but at index ${r}, parameters only contains ${this.values[r].length}\n ${
485+
this.opts.logParam ? this.displaySql() : this.sql
486+
}`,
488487
false,
489488
info,
490489
'HY000',

lib/cmd/class/prepare-result-packet.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
const CommandParameter = require('../../command-parameter');
66
const Errors = require('../../misc/errors');
77
const ExecuteStream = require('../execute-stream');
8+
const Parser = require('../parser');
89

910
/**
1011
* Prepare result
@@ -37,12 +38,22 @@ class PrepareResultPacket {
3738
}
3839

3940
if (this.isClose()) {
41+
let sql = this.query;
42+
if (this.conn.opts.logParam) {
43+
if (this.query.length > this.conn.opts.debugLen) {
44+
sql = this.query.substring(0, this.conn.opts.debugLen) + '...';
45+
} else {
46+
let sqlMsg = this.query + ' - parameters:';
47+
sql = Parser.logParameters(this.conn.opts, sqlMsg, values);
48+
}
49+
}
50+
4051
const error = Errors.createError(
4152
`Execute fails, prepare command as already been closed`,
4253
Errors.ER_PREPARE_CLOSED,
4354
null,
4455
'22000',
45-
this.query
56+
sql
4657
);
4758

4859
if (!_cb) {

lib/cmd/command.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Command extends EventEmitter {
4141
errno,
4242
info,
4343
sqlState,
44-
this.displaySql(),
44+
this.opts && this.opts.logParam ? this.displaySql() : this.sql,
4545
fatal,
4646
this.cmdParam ? this.cmdParam.stack : null,
4747
false
@@ -80,7 +80,7 @@ class Command extends EventEmitter {
8080
* @param info connection information
8181
*/
8282
sendCancelled(msg, errno, info) {
83-
const err = Errors.createError(msg, errno, info, 'HY000', this.displaySql());
83+
const err = Errors.createError(msg, errno, info, 'HY000', this.opts.logParam ? this.displaySql() : this.sql);
8484
this.emit('send_end');
8585
this.throwError(err, info);
8686
}

lib/cmd/execute.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ class Execute extends Parser {
5757
Buffer.isBuffer(value))
5858
) {
5959
if (opts.logger.query)
60-
opts.logger.query(
61-
`EXECUTE: (${this.prepare.id}) sql: ${opts.logger.logParam ? this.displaySql() : this.sql}`
62-
);
60+
opts.logger.query(`EXECUTE: (${this.prepare.id}) sql: ${opts.logParam ? this.displaySql() : this.sql}`);
6361
if (!this.longDataStep) {
6462
this.longDataStep = true;
6563
this.registerStreamSendEvent(out, info);
@@ -73,7 +71,7 @@ class Execute extends Parser {
7371
if (!this.longDataStep) {
7472
// no stream parameter, so can send directly
7573
if (opts.logger.query)
76-
opts.logger.query(`EXECUTE: (${this.prepare.id}) sql: ${opts.logger.logParam ? this.displaySql() : this.sql}`);
74+
opts.logger.query(`EXECUTE: (${this.prepare.id}) sql: ${opts.logParam ? this.displaySql() : this.sql}`);
7775
this.sendComStmtExecute(out, info);
7876
}
7977
}
@@ -88,7 +86,9 @@ class Execute extends Parser {
8886
//validate parameter size.
8987
if (this.prepare.parameterCount > this.values.length) {
9088
this.sendCancelled(
91-
`Parameter at position ${this.values.length} is not set\\nsql: ${this.displaySql()}`,
89+
`Parameter at position ${this.values.length} is not set\\nsql: ${
90+
this.opts.logParam ? this.displaySql() : this.sql
91+
}`,
9292
Errors.ER_MISSING_PARAMETER,
9393
info
9494
);

lib/cmd/handshake/authentication.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class Authentication extends Command {
6969
packet.skipLengthCodedNumber(); //skip affected rows
7070
packet.skipLengthCodedNumber(); //skip last insert id
7171
info.status = packet.readUInt16();
72-
72+
let mustRedirect = false;
7373
if (info.status & ServerStatus.SESSION_STATE_CHANGED) {
7474
packet.skip(2); //skip warning count
7575
packet.skipLengthCodedNumber();
@@ -97,6 +97,11 @@ class Authentication extends Command {
9797
opts.emit('collation', info.collation);
9898
break;
9999

100+
case 'redirect_url':
101+
mustRedirect = true;
102+
info.redirect(value, this.successEnd);
103+
break;
104+
100105
case 'connection_id':
101106
info.threadId = parseInt(value);
102107
break;
@@ -116,7 +121,8 @@ class Authentication extends Command {
116121
}
117122
}
118123
}
119-
return this.successEnd();
124+
if (!mustRedirect) this.successEnd();
125+
return;
120126

121127
//*********************************************************************************************************
122128
//* ERR_Packet

0 commit comments

Comments
 (0)