Skip to content

Commit

Permalink
Merge branch 'release/2.0.0-alpha'
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Sep 20, 2018
2 parents 417d0c5 + 4c70c51 commit 9f7592f
Show file tree
Hide file tree
Showing 39 changed files with 2,493 additions and 1,011 deletions.
828 changes: 20 additions & 808 deletions README.md

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions benchmarks/benchs/bench_promise_insert.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,17 @@ module.exports.initFct = function(conn) {
return Promise.all([
conn.query("DROP TABLE IF EXISTS testn.perfTestText"),
conn.query(sqlTable + " COLLATE='utf8mb4_unicode_ci'")
])
]);
})
.catch(e => {
console.log(e);
throw e;
});

};

module.exports.onComplete = function(conn) {
conn.query("TRUNCATE TABLE testn.perfTestText")
.catch(e => {
console.log(e);
throw e;
});
conn.query("TRUNCATE TABLE testn.perfTestText").catch(e => {
console.log(e);
throw e;
});
};
13 changes: 5 additions & 8 deletions benchmarks/benchs/bench_promise_insert_pipelining.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ module.exports.benchFct = function(conn, deferred) {
}
};


module.exports.initFct = function(conn) {
return Promise.all([
conn.query("DROP TABLE IF EXISTS testn.perfTestTextPipe"),
Expand All @@ -52,19 +51,17 @@ module.exports.initFct = function(conn) {
return Promise.all([
conn.query("DROP TABLE IF EXISTS testn.perfTestTextPipe"),
conn.query(sqlTable + " COLLATE='utf8mb4_unicode_ci'")
])
]);
})
.catch(e => {
console.log(e);
throw e;
});

};

module.exports.onComplete = function(conn) {
conn.query("TRUNCATE TABLE testn.perfTestTextPipe")
.catch(e => {
console.log(e);
throw e;
});
conn.query("TRUNCATE TABLE testn.perfTestTextPipe").catch(e => {
console.log(e);
throw e;
});
};
35 changes: 18 additions & 17 deletions benchmarks/common_benchmarks.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ try {
function Bench() {
this.dbReady = 0;
this.reportData = {};

this.driverLen = 2;

this.ready = 0;
Expand Down Expand Up @@ -192,12 +191,14 @@ function Bench() {
bench.initFcts[i].call(this, bench.CONN.MARIADB.drv);
}
}
this.currentNb = 0;
console.log("initializing test data done");
},

// called between running benchmarks
onCycle: function(event) {
pingAll(connList);
this.currentNb++;
if (this.currentNb < this.length) pingAll(connList);
//to avoid mysql2 taking all the server memory
if (promiseMysql2 && promiseMysql2.clearParserCache) promiseMysql2.clearParserCache();
if (mysql2 && mysql2.clearParserCache) mysql2.clearParserCache();
Expand Down Expand Up @@ -250,11 +251,11 @@ Bench.prototype.endConnection = function(conn) {
console.log(err);
}
if (conn.pool) {
conn.pool.end()
.catch(err => {
console.log("ending error for pool '" + conn.desc + "'");
console.log(err);
});
if (conn.pool.on) conn.pool.on("error", err => {});
conn.pool.end().catch(err => {
console.log("ending error for pool '" + conn.desc + "'");
console.log(err);
});
}
};

Expand Down Expand Up @@ -413,16 +414,16 @@ const pingAll = function(conns) {
conns[keys[k]].drv.ping();
if (conns[keys[k]].pool) {
for (let i = 0; i < 4; i++) {
conns[keys[k]].pool.getConnection()
.then(conn => {
conn.ping()
.then(() => {
conn.release();
})
.catch(err => {
conn.release();
})
})
conns[keys[k]].pool.getConnection().then(conn => {
conn
.ping()
.then(() => {
conn.release();
})
.catch(err => {
conn.release();
});
});
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion documentation/callback-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Install the mariadb Connector using npm
$ npm install mariadb
```

You can then uses the Connector in your application code with the Callback API. Fir instance,
You can then uses the Connector in your application code with the Callback API. For instance,

```js
const mariadb = require('mariadb/callback');
Expand Down
16 changes: 14 additions & 2 deletions documentation/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
#### 07-07-2018
#### 2.0.0-alpha - 20-09-2018

* First alpha version
* [CONJS-42] check other connections in pool when an unexpected connection error occur
* [CONJS-44] Create option to permit setting Object to one prepareStatement parameter
* [CONJS-43] Callback API is missing
* [CONJS-39] support geometric GeoJSON structure format
* [CONJS-24] new option "sessionVariables" to permit setting session variable at connection
* [misc] connection.end() immediate resolution on socket QUIT packet send.
* [misc] improve documentation and set Promise API documentation to a dedicated page.
* [misc] change pool implementation to permit node 6 compatibility (removal of async await)


#### 0.7.0 - 18-07-2018

* First alpha version
31 changes: 17 additions & 14 deletions documentation/connection-options.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Connection options
# Connection Options

- [Essential options](#essential-option)
- [Support for big integer](#support-for-big-integer)
Expand All @@ -10,13 +10,13 @@
- [Other options](#other-options)
- [F.A.Q.](#faq)

## Essential options
## Essential Options

| option| description| type| default|
| ---: | --- | :---: | :---: |
| **user** | User to access database |*string* |
| **password** | User password |*string* |
| **host** | IP address or DNS of database server. *Not used when using option `socketPath`*|*string*| "localhost"|
| **host** | IP address or DNS of database server. *Not used when using the `socketPath` option*|*string*| "localhost"|
| **port** | Database server port number|*integer*| 3306|
| **database** | Default database to use when establishing the connection | *string* |
| **socketPath** | Permit connecting to the database via Unix domain socket or named pipe, if the server allows it| *string* |
Expand All @@ -36,8 +36,8 @@ The Connector provides two options to address this issue.

|option|description|type|default|
|---:|---|:---:|:---:|
| **bigNumberStrings** | When an integer is not in the safe range, the Connector interprets the value as a string |*boolean* |false|
| **supportBigNumbers** | When an integer is not in the safe range, the Connector interprets the value as a [Long](https://www.npmjs.com/package/long) object |*boolean* |false|
| **bigNumberStrings** | When an integer is not in the safe range, the Connector interprets the value as a string. |*boolean* |false|
| **supportBigNumbers** | When an integer is not in the safe range, the Connector interprets the value as a [Long](https://www.npmjs.com/package/long) object. |*boolean* |false|


## SSL
Expand Down Expand Up @@ -74,7 +74,7 @@ For more information, see the [MariaDB Server](https://mariadb.com/kb/en/library

Enabling the `ssl` system variable on the server, the Connector uses one-way SSL authentication to connect to the server. Additionally, it's recommended that you also configure your users to connect through SSL. This ensures that their accounts can only be used with an SSL connection.

For the `GRANT` statements, use the `REQUIRE SSL` option for one-way SSL authentication and the `REQUIRE X509` option for two-way SSL authentication. For more information, see the [`CREATE USER`](https://mariadb.com/kb/en/library/create-user/) documentation.
For `GRANT` statements, use the `REQUIRE SSL` option for one-way SSL authentication and the `REQUIRE X509` option for two-way SSL authentication. For more information, see the [`CREATE USER`](https://mariadb.com/kb/en/library/create-user/) documentation.


```sql
Expand Down Expand Up @@ -116,7 +116,7 @@ The Connector uses the Node.js implementation of TLS. For more information, see

#### Trusted CA

By default, Node.js trusts the well-know root Certificate Authorities (CA), based on Mozilla. For a complete list, (including the popular and free Let's Encrypt), see the [CA Certificate List](https://ccadb-public.secure.force.com/mozilla/IncludedCACertificateReport).
By default, Node.js trusts the well-known root Certificate Authorities (CA), based on Mozilla. For a complete list, (including the popular and free Let's Encrypt), see the [CA Certificate List](https://ccadb-public.secure.force.com/mozilla/IncludedCACertificateReport).

When using a certificate signed with a certificate chain from a root CA known to Node.js, the only configuration you need to do is enable the `ssl` option.

Expand All @@ -128,17 +128,17 @@ A certificate chain is a list of certificates that were issued from the same Cer
In cases where intermediate or root certificates are not trusted by the Connector, the Connector rejects the connection and issues an error.


#### Hostname verification (SNI)
#### Hostname Verification (SNI)

Certificates can provide hostname verification to the driver. By default this is done against the certificate's `subjectAlternativeName` DNS name field.


### One-way SSL authentication
### One-way SSL Authentication

When the server certificate is signed using the certificate chain that uses a root CA known in the JavaScript trust store, setting the `ssl` option enables one-way SSL authentication.


For instance,
For example,

```javascript
const mariadb = require('mariadb');
Expand Down Expand Up @@ -190,7 +190,7 @@ mariadb
```


#### Using specific TLS Protocols or Ciphers
#### Using Specific TLS Protocols or Ciphers

In situations where you don't like the default TLS protocol or cipher or where you would like to use a specific version, you force he Connector to use the one you want using the `secureProtocol` and `cipher` options.

Expand All @@ -214,7 +214,7 @@ mariadb
For more information on what's available, see [possible protocol](https://www.openssl.org/docs/man1.0.2/ssl/ssl.html#DEALING-WITH-PROTOCOL-METHODS) values.


### Two-way SSL authentication
### Two-way SSL Authentication

Mutual SSL authentication or certificate-based mutual authentication refers to two parties authenticating each other by verifying the provided digital certificates. This allows both parties to be assured of the other's identity. In order to use mutual authentication, you must set the `REQUIRE X509` option in the `GRANT` statement. For instance,

Expand Down Expand Up @@ -310,20 +310,23 @@ mariadb.createConnection({
| **foundRows** | When enabled, the update number corresponds to update rows. When disabled, it indicates the real rows changed. | *boolean* |true|
| **multipleStatements** | Allows you to issue several SQL statements in a single `quer()` call. (That is, `INSERT INTO a VALUES('b'); INSERT INTO c VALUES('d');`). <br/><br/>This may be a **security risk** as it allows for SQL Injection attacks. |*boolean* |false|
| **namedPlaceholders** | Allows the use of named placeholders. |*boolean* |false|
| **permitLocalInfile** | Allows the use of `LOAD DATA INFILE` statements.<br/><br/>Loading data from a file from the client may be a security issue, as a man-in-the-middle proxy server can change the actual file the server loads. Being able to executing a query on the client gives you access to files on the client. |*boolean* |false|
| **permitLocalInfile** | Allows the use of `LOAD DATA INFILE` statements.<br/><br/>Loading data from a file from the client may be a security issue, as a man-in-the-middle proxy server can change the actual file the server loads. Being able to execute a query on the client gives you access to files on the client. |*boolean* |false|
| **timezone** | Forces use of the indicated timezone, rather than the current Node.js timezone. Possible values are `Z` for UTC, `local` or `±HH:MM` format |*string* |
| **nestTables** | Presents result-sets by table to avoid results with colliding fields. See the `query()` description for more information. |*boolean* |false|
| **pipelining** | Sends queries one by one without waiting on the results of the previous entry. For more information, see [Pipelining](/documentation/pipelining.md) |*boolean* |true|
| **trace** | Adds the stack trace at the time of query creation to the error stack trace, making it easier to identify the part of the code that issued the query. Note: This feature is disabled by default due to the performance cost of stack creation. Only turn it on when you need to debug issues. |*boolean* |false|
| **typeCast** | Allows you to cast result types. |*function* |
| **connectAttributes** | Sends information, (client name, version, operating system, Node.js version, and so on) to the [Performance Schema](https://mariadb.com/kb/en/library/performance-schema-session_connect_attrs-table/). When enabled, the Connector sends JSON attributes in addition to the defaults. |*boolean/json* |false|
| **metaAsArray** | Compatibility option, causes Promise to return an array object, `[rows, metadata]` rather than the rows as JSON objects with a `meta` property. |*boolean* |false|
| **permitSetMultiParamEntries** | Compatibility option to permit setting multiple value by a JSON object to replace one question mark. key values will replace the question mark with format like `key1`=val,`key2`='val2'. Since it doesn't respect the usual prepared statement format that one value is for one question mark, this can lead to incomprehension, even if badly use to possible injection.|*boolean* |false|
| **sessionVariables** | Permit to set session variables when connecting. Example: sessionVariables:{'idle_transaction_timeout':10000}|*json* |


## F.A.Q.

#### error Hostname/IP doesn't match certificate's altnames

Clients verify certificate SAN (subject alternative names) and CN to ensure that the certificate corresponds to the hostname. If the certificate's SAN/CN does not correspond to the `host` option, it returns an error like:
Clients verify certificate SAN (subject alternative names) and CN to ensure that the certificate corresponds to the hostname. If the certificate's SAN/CN does not correspond to the `host` option, it returns an error such as:

```
Hostname/IP doesn't match certificate's altnames: "Host: other.example.com. is not cert's CN: mariadb.example.com"
Expand Down
Binary file added documentation/misc/pip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9f7592f

Please sign in to comment.