Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
# Conflicts:
#	.travis.yml
#	test/integration/test-connection-opts.js
  • Loading branch information
rusher committed Dec 18, 2023
2 parents fd6cdde + 8e20d41 commit d0d55dc
Show file tree
Hide file tree
Showing 29 changed files with 593 additions and 219 deletions.
103 changes: 16 additions & 87 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,113 +1,45 @@
os: linux
dist: jammy
language: node_js
services: docker
node_js: 20
addons:
hosts:
- mariadb.example.com

version: ~> 1.0

before_install:
- git clone https://github.com/mariadb-corporation/connector-test-machine.git


install:
- |-
case $TRAVIS_OS_NAME in
windows)
powershell -Command Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe -Outfile codecov.exe
;;
linux)
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
ls -lrt
;;
esac
- |-
case $TRAVIS_OS_NAME in
windows)
choco install -y --force nodejs-lts
# force refresh path
export PATH=$(cmd.exe //c "refreshenv > nul & C:\Progra~1\Git\bin\bash -c 'echo \$PATH' ")
connector-test-machine/launch.bat -t "$srv" -v "$v" -d testn
;;
linux)
source connector-test-machine/launch.sh -t "$srv" -v "$v" -d testn -l "$local" -c "$CLEAR_TEXT" -s "$DISABLE_SSL"
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
ls -lrt
;;
esac
env:
global:
- RUN_LONG_TEST=1
- CLEAR_TEXT=0
global: RUN_LONG_TEST=1 CLEAR_TEXT=0 DB=testn

stages:
- Minimal
- name: Enterprise
if: type = push AND fork = false
- Community
import: mariadb-corporation/connector-test-machine:common-build.yml@master

jobs:
fast_finish: true
allow_failures:
- env: srv=build
- env: srv=xpand RUN_LONG_TEST=0
include:
- stage: Minimal
env: srv=mariadb v=10.6 local=1 packet=40
name: "CS 10.6"
- env: srv=mariadb-es v=10.6
name: "ES 10.6"
if: type = push AND fork = false

- stage: Enterprise
env: srv=mariadb-es v=10.4
name: "ES 10.4"
if: type = push AND fork = false
- env: srv=mariadb-es v=10.5
name: "ES 10.5"
if: type = push AND fork = false
- env: srv=mariadb-es-test v=23.08
name: "ES 23.08"
if: type = push AND fork = false
- env: srv=maxscale
name: "Maxscale"
- env: srv=xpand RUN_LONG_TEST=0
name: "Xpand"

- stage: Community
env: srv=mariadb v=10.6
os: windows
language: shell
name: "CS 10.6 - Windows"
- env: srv=mariadb v=10.4 local=1
dist: bionic
node_js: 16
name: "CS 10.4"
- env: srv=mariadb v=10.5 local=1 DISABLE_SSL=1
dist: bionic
name: "CS 10.5 - node.js 14"
node_js: 14
- env: srv=mariadb v=10.11 local=1
- stage: Language
env: srv=mariadb v=10.11 local=1
name: "CS 10.11 - node.js 16"
node_js: 16
- env: srv=mariadb v=11.0 local=1 CLEAR_TEXT=1
- stage: Language
env: srv=mariadb v=10.11 local=1 CLEAR_TEXT=1
node_js: 18
name: "CS 11.0 - node.js 18"
- env: srv=mariadb v=11.1 local=1
name: "CS 11.1 - node.js 20"
name: "CS 10.11 - node.js 18"
- stage: Language
env: srv=mariadb v=10.11 local=1 DISABLE_SSL=1
name: "CS 10.11 - node.js 20"
node_js: 20
- env: srv=mysql v=5.7
name: "MySQL 5.7"
- env: srv=mysql v=8.0
name: "MySQL 8.0"
- env: srv=mariadb v=10.6 BENCH=1 local=1
- stage: Benchmarks
env: srv=mariadb v=10.11 BENCH=1 local=1
name: "Benchmarks"
node_js: 18
dist: focal
- env: srv=build
name: "CS build"

script:
- npm install
Expand All @@ -131,6 +63,3 @@ script:
after_success:
- if [ -z "$BENCH" ] ; then npm run coverage:report; fi

after_failure:
- if [ "$srv" == "maxscale" ] ; then docker-compose -f ${COMPOSE_FILE} exec -u root maxscale tail -500 /var/log/maxscale/maxscale.log; fi
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Change Log

## [3.2.3](https://github.com/mariadb-corporation/mariadb-connector-nodejs/tree/3.2.3) (Dec 2023)
[Full Changelog](https://github.com/mariadb-corporation/mariadb-connector-nodejs/compare/3.2.2...3.2.3)

* CONJS-207 Add support for connection redirection
* CONJS-271 wrong binary decoding of 00:00:00 TIME values
* CONJS-272 Error doesn't always have parameters according to option
* CONJS-273 Bulk insert error when last bunch of parameters is reaching max_allowed_packet
* CONJS-274 permit disabling BULK insert for one batch
* CONJS-207 Add support for connection redirection


## [3.2.2](https://github.com/mariadb-corporation/mariadb-connector-nodejs/tree/3.2.2) (Oct 2023)
[Full Changelog](https://github.com/mariadb-corporation/mariadb-connector-nodejs/compare/3.2.1...3.2.2)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

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

MariaDB and MySQL client, 100% JavaScript, with TypeScript definition, with the Promise API.
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)


## Documentation
Expand Down
6 changes: 3 additions & 3 deletions documentation/callback-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -523,9 +523,9 @@ https.get("https://node.green/#ES2018-features-Promise-prototype-finally-basic-s

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:

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

```js
connection.query(
Expand Down
2 changes: 1 addition & 1 deletion documentation/promise-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ https.get(
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:

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

```js
Expand Down
15 changes: 7 additions & 8 deletions lib/cmd/batch-bulk.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class BatchBulk extends Parser {
*/
sendComStmtBulkExecute(out, opts, info) {
if (opts.logger.query)
opts.logger.query(`BULK: (${this.prepare.id}) sql: ${opts.logger.logParam ? this.displaySql() : this.sql}`);
opts.logger.query(`BULK: (${this.prepare.id}) sql: ${opts.logParam ? this.displaySql() : this.sql}`);
const parameterCount = this.prepare.parameterCount;
this.rowIdx = 0;
this.vals = this.values[this.rowIdx++];
Expand Down Expand Up @@ -250,7 +250,7 @@ class BatchBulk extends Parser {
out.writeBuffer(lastCmdData, 0, lastCmdData.length);
out.mark();
lastCmdData = null;
if (!this.rowIdx >= this.values.length) {
if (this.rowIdx >= this.values.length) {
break;
}
this.vals = this.values[this.rowIdx++];
Expand Down Expand Up @@ -353,10 +353,9 @@ class BatchBulk extends Parser {
for (let i = 0; i < this.initialValues.length; i++) {
if (i !== 0) sqlMsg += ',';
let param = this.initialValues[i];
sqlMsg = this.logParameters(sqlMsg, param);
sqlMsg = Parser.logParameters(this.opts, sqlMsg, param);
if (sqlMsg.length > this.opts.debugLen) {
sqlMsg = sqlMsg.substring(0, this.opts.debugLen) + '...';
break;
return sqlMsg.substring(0, this.opts.debugLen) + '...';
}
}
sqlMsg += ']';
Expand Down Expand Up @@ -482,9 +481,9 @@ class BatchBulk extends Parser {
if (this.values[r].length < nbParameter) {
this.emit('send_end');
this.throwNewError(
`Expect ${nbParameter} parameters, but at index ${r}, parameters only contains ${
this.values[r].length
}\n ${this.displaySql()}`,
`Expect ${nbParameter} parameters, but at index ${r}, parameters only contains ${this.values[r].length}\n ${
this.opts.logParam ? this.displaySql() : this.sql
}`,
false,
info,
'HY000',
Expand Down
13 changes: 12 additions & 1 deletion lib/cmd/class/prepare-result-packet.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
const CommandParameter = require('../../command-parameter');
const Errors = require('../../misc/errors');
const ExecuteStream = require('../execute-stream');
const Parser = require('../parser');

/**
* Prepare result
Expand Down Expand Up @@ -37,12 +38,22 @@ class PrepareResultPacket {
}

if (this.isClose()) {
let sql = this.query;
if (this.conn.opts.logParam) {
if (this.query.length > this.conn.opts.debugLen) {
sql = this.query.substring(0, this.conn.opts.debugLen) + '...';
} else {
let sqlMsg = this.query + ' - parameters:';
sql = Parser.logParameters(this.conn.opts, sqlMsg, values);
}
}

const error = Errors.createError(
`Execute fails, prepare command as already been closed`,
Errors.ER_PREPARE_CLOSED,
null,
'22000',
this.query
sql
);

if (!_cb) {
Expand Down
4 changes: 2 additions & 2 deletions lib/cmd/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Command extends EventEmitter {
errno,
info,
sqlState,
this.displaySql(),
this.opts && this.opts.logParam ? this.displaySql() : this.sql,
fatal,
this.cmdParam ? this.cmdParam.stack : null,
false
Expand Down Expand Up @@ -80,7 +80,7 @@ class Command extends EventEmitter {
* @param info connection information
*/
sendCancelled(msg, errno, info) {
const err = Errors.createError(msg, errno, info, 'HY000', this.displaySql());
const err = Errors.createError(msg, errno, info, 'HY000', this.opts.logParam ? this.displaySql() : this.sql);
this.emit('send_end');
this.throwError(err, info);
}
Expand Down
10 changes: 5 additions & 5 deletions lib/cmd/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ class Execute extends Parser {
Buffer.isBuffer(value))
) {
if (opts.logger.query)
opts.logger.query(
`EXECUTE: (${this.prepare.id}) sql: ${opts.logger.logParam ? this.displaySql() : this.sql}`
);
opts.logger.query(`EXECUTE: (${this.prepare.id}) sql: ${opts.logParam ? this.displaySql() : this.sql}`);
if (!this.longDataStep) {
this.longDataStep = true;
this.registerStreamSendEvent(out, info);
Expand All @@ -73,7 +71,7 @@ class Execute extends Parser {
if (!this.longDataStep) {
// no stream parameter, so can send directly
if (opts.logger.query)
opts.logger.query(`EXECUTE: (${this.prepare.id}) sql: ${opts.logger.logParam ? this.displaySql() : this.sql}`);
opts.logger.query(`EXECUTE: (${this.prepare.id}) sql: ${opts.logParam ? this.displaySql() : this.sql}`);
this.sendComStmtExecute(out, info);
}
}
Expand All @@ -88,7 +86,9 @@ class Execute extends Parser {
//validate parameter size.
if (this.prepare.parameterCount > this.values.length) {
this.sendCancelled(
`Parameter at position ${this.values.length} is not set\\nsql: ${this.displaySql()}`,
`Parameter at position ${this.values.length} is not set\\nsql: ${
this.opts.logParam ? this.displaySql() : this.sql
}`,
Errors.ER_MISSING_PARAMETER,
info
);
Expand Down
10 changes: 8 additions & 2 deletions lib/cmd/handshake/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Authentication extends Command {
packet.skipLengthCodedNumber(); //skip affected rows
packet.skipLengthCodedNumber(); //skip last insert id
info.status = packet.readUInt16();

let mustRedirect = false;
if (info.status & ServerStatus.SESSION_STATE_CHANGED) {
packet.skip(2); //skip warning count
packet.skipLengthCodedNumber();
Expand Down Expand Up @@ -97,6 +97,11 @@ class Authentication extends Command {
opts.emit('collation', info.collation);
break;

case 'redirect_url':
mustRedirect = true;
info.redirect(value, this.successEnd);
break;

case 'connection_id':
info.threadId = parseInt(value);
break;
Expand All @@ -116,7 +121,8 @@ class Authentication extends Command {
}
}
}
return this.successEnd();
if (!mustRedirect) this.successEnd();
return;

//*********************************************************************************************************
//* ERR_Packet
Expand Down
Loading

0 comments on commit d0d55dc

Please sign in to comment.