Skip to content

Commit

Permalink
Merge branch 'release/3.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Feb 2, 2023
2 parents f250817 + 367ae7e commit 21d7547
Show file tree
Hide file tree
Showing 78 changed files with 1,924 additions and 1,444 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,6 @@ 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
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,34 @@
# Change Log

## [3.1.0](https://github.com/mariadb-corporation/mariadb-connector-nodejs/tree/3.0.2) (Feb 2023)
[Full Changelog](https://github.com/mariadb-corporation/mariadb-connector-nodejs/compare/3.0.2...3.1.0)

## Notable changes

### Timezone handling (CONJS-237)

Connector now set session timezone, solving issue with [time function](https://mariadb.com/kb/en/time-zones/#time-zone-effects-on-functions),
removing needs of client side conversion.

This requires that when using timezone options, to having server TZ data filled in case client timezone differ from server.

### Performance
* CONJS-230 better metadata parsing performance
* CONJS-229 performance improvement when parsing lots of parameter
* CONJS-238 faster execution for known length packet

### Other changes
* CONJS-225 Make result set's meta property non-enumerable
* CONJS-235 Allow to pass TypeScript generic types without need of "as"


## Issues Fixed
* CONJS-231 executing batch and when parameter can be too long to fit in one mysql packet, parameter can have 4 byte missing
* CONJS-236 datatype TIME wrong binary decoding when not having microseconds
* CONJS-239 When using connection with callback, pre-commands (like `initSql`) might not always be executed first
* CONJS-232 in case of a long query running, connection.destroy() will close connection, but leaving server still running query for some time


## [3.0.2](https://github.com/mariadb-corporation/mariadb-connector-nodejs/tree/3.0.2) (Oct 2022)
[Full Changelog](https://github.com/mariadb-corporation/mariadb-connector-nodejs/compare/3.0.1...3.0.2)

Expand Down
37 changes: 22 additions & 15 deletions documentation/developers-guide.md → CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@

# Contribution
# Contribution

Developers interested in contributing to the MariaDB Node.js Connector can do so through GitHub. Each pull request should address a single issue, and contain both the fix as well as a description of how the changes work and tests to validate that the pull request fixes the issue in question.
Developers interested in contributing to the MariaDB Node.js Connector can do so through GitHub. Each pull request should address a single issue, and contain both the fix as well as a description of how the changes work and tests to validate that the pull request fixes the issue in question.

In the event that you would like to contribute to the development a significant feature, we like to have an open issue on the [MariaDB JIRA](https://jira.mariadb.org/projects/CONJS). Discussions of the issue will take place on the JIRA ticket.
In the event that you would like to contribute to the development a significant feature, we like to have an open issue on the [MariaDB JIRA](https://jira.mariadb.org/projects/CONJS).
Discussions of the issue will take place on the JIRA ticket.

## Development
## Development

Rather than downloading the source code for the Connector directly from GitHub or cloning this repository, instead fork the project onto your own account. Then send pull requests from your fork.
Rather than downloading the source code for the Connector directly from GitHub or cloning this repository, instead fork the project onto your own account.
Then send pull requests from your fork.

### Testing

Before submitting a pull request to the project, run local and continuous integration testing. This ensures that your patch works and can be accepted without breaking the Connector.
Before submitting a pull request to the project, run local and continuous integration testing.
This ensures that your patch works and can be accepted without breaking the Connector, and if code doesn't follow default code style, it will be automatically corrected


#### Running Local Tests

The repository contains a series of tests to evaluate the Connector and to make sure it can connect to and operate on MariaDB with the new code. Run local tests using npm.
The repository contains a series of tests to evaluate the Connector and to make sure it can connect to and operate on MariaDB with the new code.
Run local tests using npm.

In order for these tests to pass, you need to have a MariaDB or MySQL server installed, which by default it assumes is running at localhost:3306 with a database named `testn` and a user `root` without a password.
Alternatively you will need to create a user [with grant privilege](https://mariadb.com/kb/en/grant/#the-grant-option-privilege).
Expand All @@ -25,7 +30,7 @@ MariaDB [(none)]> create user anel@localhost identified by ('testpass');
MariaDB [(none)]> grant all privileges on *.* to anel@localhost WITH GRANT OPTION;
```
Once this is set up, you can run the tests with npm:

```
$ npm run test:base
```
Expand All @@ -34,12 +39,12 @@ Or via environment variables with specific user:
$ TEST_DB=testn TEST_USER=anel TEST_PASSWORD=testpass TEST_PORT=3306 TEST_HOST=localhost npm run test:base
```
The tests retrieve the host, password, database and port number from environmental variables, which you can manually set if you want to connect to MariaDB in other ways.

* `TEST_HOST` Hostname. By default, localhost.
* `TEST_PASSWORD` Password for `root`. Null by default.
* `TEST_DB` Database to run tests on. Defaults to `testn`.
* `TEST_PORT` Port to connect to. 3306 by default.
* `TEST_PORT` Port to connect to. 3306 by default.


On Windows, you can launch specific tests by calling them. For instance,

Expand All @@ -55,11 +60,12 @@ npm test

#### Running CI test

Continuous Integration testing for the Connector is set for [appveyor](https://www.appveyor.com/) and [travis](https://www.travis-ci.org/). You can test your own code using either, provided you configure them to validate your fork, rather than the project repository.
Continuous Integration testing for the Connector is set for [travis](https://app.travis-ci.com/github/mariadb-corporation/mariadb-connector-nodejs/).
You can test your own code using either, provided you configure them to validate your fork, rather than the project repository.

The advantage of CI tools over running tests locally is that it launches tests for different versions of Node.js and different versions of MariaDB and MySQL servers. This to ensure that your patch will work across other builds, in addition to the one you have on your local system.
The advantage of CI tools over running tests locally is that it launches tests for different versions of Node.js and different versions of MariaDB and MySQL servers. This to ensure that your patch will work across other builds, in addition to the one you have on your local system.

In order to do that, go to [Travis CI](https://travis-ci.org), connect your GitHub account and active your fork of the MariaDB Connector repository. Once this is done, Travis runs tests against every push you make to your repository on GitHub.
In order to do that, go to [Travis CI](https://app.travis-ci.com/github/), connect your GitHub account and active your fork of the MariaDB Connector repository. Once this is done, Travis runs tests against every push you make to your repository on GitHub.


#### Coverage test
Expand All @@ -71,7 +77,7 @@ npm install nyc -g
nyc npm test
```

results will be :
results will be :

```
... will run tests
Expand All @@ -96,6 +102,7 @@ All files | 95.71 | 84.26 | 90.3
parse.js | 100 | 100 | 100 | 100 | |
utils.js | 100 | 100 | 100 | 100 | |
-------------------------------------------------|----------|----------|----------|----------|-------------------|
```


### Submitting Pull Requests
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,28 +76,28 @@ For more information, see the [Batch](/documentation/batch.md) documentation.
MariaDB provides benchmarks comparing the Connector with other Node.js MariaDB/MySQL clients, including:

* [`promise-mysql`](https://www.npmjs.com/package/promise-mysql) version 5.2.0 + [`mysql`](https://www.npmjs.com/package/mysql) version 2.18.1
* [`mysql2`](https://www.npmjs.com/package/mysql2) version 2.3.3
* [`mysql2`](https://www.npmjs.com/package/mysql2) version 3.1.0

See the [Benchmarks](./documentation/benchmarks.md) page for multiple results.

#### query

```
select 20 * int, 20 * varchar(32)
mysql : 3,086 ops/s ± 0.6%
mysql2 : 2,799.6 ops/s ± 1.6% ( -9.3% )
mariadb : 4,710.8 ops/s ± 1% ( +52.7% )
select 100 int
mysql : 2,364.7 ops/s ± 1.6%
mysql2 : 1,977.8 ops/s ± 1.9% ( -16.4% )
mariadb : 3,869 ops/s ± 2.5% ( +63.6% )
```
![select 20 * int, 20 * varchar(32) benchmark results](https://quickchart.io/chart/render/zm-ef74089a-be91-49f1-b5a0-5b9ac5752435?data1=3086&data2=2800&data3=4711)
![select 100 int benchmark results](https://quickchart.io/chart/render/zm-ef74089a-be91-49f1-b5a0-5b9ac5752435?data1=2365&data2=1978&data3=3869)

#### execute

```
select 20 * int, 20 * varchar(32) using execute
mysql2 : 2,998 ops/s ± 1.3%
mariadb : 4,419.6 ops/s ± 1% ( +47.4% )
select 100 int using execute
mysql2 : 2,042.3 ops/s ± 2.3%
mariadb : 8,101.4 ops/s ± 1.2% ( +296.7% )
```
![select 20 * int, 20 * varchar(32) using execute benchmark results](https://quickchart.io/chart/render/zm-36b213f4-8efe-4943-8f94-82edf94fce83?data1=2998&data2=4420)
![select 100 int - BINARY benchmark results](https://quickchart.io/chart/render/zm-36b213f4-8efe-4943-8f94-82edf94fce83?data1=2042&data2=8101)


## Quick Start
Expand Down Expand Up @@ -131,7 +131,7 @@ async function asyncFunction() {

## Contributing

If you would like to contribute to the MariaDB Node.js Connector, please follow the instructions given in the [Developers Guide.](/documentation/developers-guide.md)
If you would like to contribute to the MariaDB Node.js Connector, please follow the instructions given in the [contributing guide.](/CONTRIBUTING.md)

To file an issue or follow the development, see [JIRA](https://jira.mariadb.org/projects/CONJS/issues/).

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benchmark-one.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const fs = require('fs');
const createBenchSuite = require('./common-bench');

const launchBench = async function (path) {
const bench = require('./benchs/select_1000_rows_stream.js');
const bench = require('./benchs/select_1000_rows.js');
const suite = await createBenchSuite(bench);
suite.run();
};
Expand Down
15 changes: 14 additions & 1 deletion benchmarks/benchs/select_1000_rows.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
module.exports.title = 'select 1000 rows';
module.exports.displaySql = 'select * from 1000 rows (int + string(32))';
module.exports.benchFct = async function (conn, type, deferred) {
const res = await conn.query("select seq, 'abcdefghijabcdefghijabcdefghijaa' from seq_1_to_1000");
const res = await conn.query('select * from 1000rows');
deferred.resolve(res);
};

module.exports.initFct = function (conn) {
conn.query('DROP TABLE IF EXISTS 1000rows');
conn.query('CREATE TABLE 1000rows(id INT not null primary key auto_increment, val VARCHAR(32))');
let inserts = [];
for (let i = 0; i < 1000; i++) {
inserts.push(conn.query('INSERT INTO 1000rows(val) VALUES (?) ', ['abcdefghijabcdefghijabcdefghijaa']));
}
return Promise.all(inserts).catch((e) => {
console.log(e);
throw e;
});
};
20 changes: 20 additions & 0 deletions benchmarks/benchs/select_1000_rows_execute.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports.title = 'select 1000 rows - BINARY';
module.exports.displaySql = 'select * from 1000 rows (int + string(32))';
module.exports.requireExecute = true;
module.exports.benchFct = async function (conn, type, deferred) {
const res = await conn.execute('select * from 1000rows');
deferred.resolve(res);
};

module.exports.initFct = function (conn) {
conn.query('DROP TABLE IF EXISTS 1000rows');
conn.query('CREATE TABLE 1000rows(id INT SIGNED not null primary key auto_increment, val VARCHAR(32))');
let inserts = [];
for (let i = 0; i < 1000; i++) {
inserts.push(conn.query('INSERT INTO 1000rows(val) VALUES (?) ', ['abcdefghijabcdefghijabcdefghijaa']));
}
return Promise.all(inserts).catch((e) => {
console.log(e);
throw e;
});
};
2 changes: 1 addition & 1 deletion benchmarks/benchs/select_100_int_execute.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports.title = 'select 100 int/varchar(32) - BINARY';
module.exports.title = 'select 100 int - BINARY';
module.exports.displaySql = 'select * FROM test100';
module.exports.requireExecute = true;
module.exports.benchFct = async function (conn, type, deferred) {
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benchs/select_100_int_varchar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports.title = 'select 100 int/varchar(32)';
module.exports.title = 'select 100 int';
module.exports.displaySql = 'select * FROM test100';
module.exports.benchFct = async function (conn, type, deferred) {
const res = await conn.query('select * FROM test100');
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benchs/select_1_int_char_pool.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports.title = 'select 1 int + char';
module.exports.title = 'select 1 int + char with pool';
module.exports.displaySql = "select 1, 'abcdefghijabcdefghijabcdefghijaa'";
module.exports.pool = true;
module.exports.benchFct = async function (pool, type, deferred) {
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benchs/select_1_int_char_random.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports.title = 'select 1 int + char';
module.exports.title = 'select 1 random int + char';
module.exports.displaySql = "select 1, 'abcdefghijabcdefghijabcdefghijaa'";
module.exports.benchFct = async function (conn, type, deferred) {
const randVal = Math.floor(Math.random() * 1000000);
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/common-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ try {
//************************************************
const conf = require('../test/conf');
const logUtility = require('./log-utility');
const config = Object.assign({}, conf.baseConfig, { charsetNumber: 45, trace: false });
const config = Object.assign({}, conf.baseConfig, { charset: 'utf8mb4', trace: false });
console.log(config);
const minimumSamples = 2;
const minimumSamples = 200;

//************************************************
// bench suite
Expand Down Expand Up @@ -57,7 +57,7 @@ const createBenchSuite = async (bench) => {
}

suite.on('cycle', function (event) {
//console.log(chalk.grey(' ' + String(event.target)));
console.log(chalk.grey(' ' + String(event.target)));
const type = event.target.name;
const iteration = 1 / event.target.times.period;
const variation = event.target.stats.rme;
Expand Down
Loading

0 comments on commit 21d7547

Please sign in to comment.