Skip to content

Commit 993003b

Browse files
committed
[misc] documentation improvement for connection.reset().
Error now indicate that minimum version server is required.
1 parent 940bdbc commit 993003b

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

documentation/callback-api.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ Specific options for pools are :
229229
| **`minimumIdle`** | Permit to set a minimum number of connection in pool. **Recommendation is to use fixed pool, so not setting this value**.|*integer* | *set to connectionLimit value* |
230230
| **`minDelayValidation`** | When asking a connection to pool, the pool will validate the connection state. "minDelayValidation" permits disabling this validation if the connection has been borrowed recently avoiding useless verifications in case of frequent reuse of connections. 0 means validation is done each time the connection is asked. (in ms) |*integer*| 500|
231231
| **`noControlAfterUse`** | After giving back connection to pool (connection.end) connector will reset or rollback connection to ensure a valid state. This option permit to disable those controls|*boolean*| false|
232+
| **`resetAfterUse`** | When a connection is given back to pool, reset the connection if the server allows it (MariaDB >=10.2.4 / MySQL >= 5.7.3). If disabled or server version doesn't allows reset, pool will only rollback open transaction if any|*boolean*| true|
232233

233234
## Pool events
234235

@@ -565,6 +566,10 @@ reset the connection. Reset will:
565566
* remove temporary tables
566567
* remove all PREPARE statement
567568
569+
This command is only available for MariaDB >=10.2.4 or MySQL >= 5.7.3.
570+
function will be rejected with error "Reset command not permitted for server XXX" if version doesn't permit reset.
571+
572+
For previous MariaDB version, reset connection can be done using [`connection.changeUser(options[, callback])`](#connectionchangeuseroptions-callback) that do the same + redo authentication phase.
568573
569574
## `connection.isValid() → boolean`
570575

documentation/promise-api.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ Specific options for pools are :
232232
| **`minimumIdle`** | Permit to set a minimum number of connection in pool. **Recommendation is to use fixed pool, so not setting this value**.|*integer* | *set to connectionLimit value* |
233233
| **`minDelayValidation`** | When asking a connection to pool, the pool will validate the connection state. "minDelayValidation" permits disabling this validation if the connection has been borrowed recently avoiding useless verifications in case of frequent reuse of connections. 0 means validation is done each time the connection is asked. (in ms) |*integer*| 500|
234234
| **`noControlAfterUse`** | After giving back connection to pool (connection.end) connector will reset or rollback connection to ensure a valid state. This option permit to disable those controls|*boolean*| false|
235+
| **`resetAfterUse`** | When a connection is given back to pool, reset the connection if the server allows it (MariaDB >=10.2.4 / MySQL >= 5.7.3). If disabled or server version doesn't allows reset, pool will only rollback open transaction if any|*boolean*| true|
235236

236237
### `createPoolCluster(options) → PoolCluster`
237238

@@ -777,6 +778,10 @@ reset the connection. Reset will:
777778
* remove temporary tables
778779
* remove all PREPARE statement
779780

781+
This command is only available for MariaDB >=10.2.4 or MySQL >= 5.7.3.
782+
function will be rejected with error "Reset command not permitted for server XXX" if version doesn't permit reset.
783+
784+
For previous MariaDB version, reset connection can be done using [`connection.changeUser(options) → Promise`](#connectionchangeuseroptions--promise) that do the same + redo authentication phase.
780785

781786
## `connection.isValid() → boolean`
782787

lib/connection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ function Connection(options) {
256256
});
257257
}
258258
return Promise.reject(
259-
new Error('Reset command not permitted for server ' + this.info.serverVersion)
259+
new Error('Reset command not permitted for server ' + this.info.serverVersion + ' (requires server MariaDB version 10.2.4+ or MySQL 5.7.3+)')
260260
);
261261
};
262262

0 commit comments

Comments
 (0)