Skip to content

Commit d62a7af

Browse files
committed
docs: improve connection flags documentation
1 parent 282fa1d commit d62a7af

File tree

1 file changed

+57
-61
lines changed

1 file changed

+57
-61
lines changed

Readme.md

+57-61
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- [Establishing connections](#establishing-connections)
1818
- [Connection options](#connection-options)
1919
- [SSL options](#ssl-options)
20+
- [Connection flags](#connection-flags)
2021
- [Terminating connections](#terminating-connections)
2122
- [Pooling connections](#pooling-connections)
2223
- [Pool options](#pool-options)
@@ -56,10 +57,6 @@
5657
- [Buffer](#buffer)
5758
- [String](#string)
5859
- [Custom type casting](#custom-type-casting)
59-
- [Connection Flags](#connection-flags)
60-
- [Example](#example)
61-
- [Default Flags](#default-flags)
62-
- [Other Available Flags](#other-available-flags)
6360
- [Debugging and reporting problems](#debugging-and-reporting-problems)
6461
- [Security issues](#security-issues)
6562
- [Contributing](#contributing)
@@ -298,6 +295,62 @@ var connection = mysql.createConnection({
298295
});
299296
```
300297

298+
### Connection flags
299+
300+
If, for any reason, you would like to change the default connection flags, you
301+
can use the connection option `flags`. Pass a string with a comma separated list
302+
of items to add to the default flags. If you don't want a default flag to be used
303+
prepend the flag with a minus sign. To add a flag that is not in the default list,
304+
just write the flag name, or prefix it with a plus (case insensitive).
305+
306+
```js
307+
var connection = mysql.createConnection({
308+
// disable FOUND_ROWS flag, enable IGNORE_SPACE flag
309+
flags: '-FOUND_ROWS,IGNORE_SPACE'
310+
});
311+
```
312+
313+
The following flags are available:
314+
315+
- `COMPRESS` - Enable protocol compression. This feature is not currently supported
316+
by the Node.js implementation so cannot be turned on. (Default off)
317+
- `CONNECT_WITH_DB` - Ability to specify the database on connection. (Default on)
318+
- `FOUND_ROWS` - Send the found rows instead of the affected rows as `affectedRows`.
319+
(Default on)
320+
- `IGNORE_SIGPIPE` - Don't issue SIGPIPE if network failures. This flag has no effect
321+
on this Node.js implementation. (Default on)
322+
- `IGNORE_SPACE` - Let the parser ignore spaces before the `(` in queries. (Default on)
323+
- `INTERACTIVE` - Indicates to the MySQL server this is an "interactive" client. This
324+
will use the interactive timeouts on the MySQL server and report as interactive in
325+
the process list. (Default off)
326+
- `LOCAL_FILES` - Can use `LOAD DATA LOCAL`. (Default on)
327+
- `LONG_FLAG` - Longer flags in Protocol::ColumnDefinition320. (Default on)
328+
- `LONG_PASSWORD` - Use the improved version of Old Password Authentication.
329+
(Default on)
330+
- `MULTI_RESULTS` - Can handle multiple resultsets for queries. (Default on)
331+
- `MULTI_STATEMENTS` - The client may send multiple statement per query or
332+
statement prepare (separated by `;`). This flag is controlled by the connection
333+
option `multipleStatements`. (Default off)
334+
- `NO_SCHEMA`
335+
- `ODBC` Special handling of ODBC behaviour. This flag has no effect on this Node.js
336+
implementation. (Default on)
337+
- `PLUGIN_AUTH` - Uses the plugin authentication mechanism when connecting to the
338+
MySQL server. This feature is not currently supported by the Node.js implementation
339+
so cannot be turned on. (Default off)
340+
- `PROTOCOL_41` - Uses the 4.1 protocol. (Default on)
341+
- `PS_MULTI_RESULTS` - Can handle multiple resultsets for execute. (Default on)
342+
- `REMEMBER_OPTIONS` - This is specific to the C client, and has no effect on this
343+
Node.js implementation. (Default off)
344+
- `RESERVED` - Old flag for the 4.1 protocol. (Default on)
345+
- `SECURE_CONNECTION` - Support native 4.1 authentication. (Default on)
346+
- `SSL` - Use SSL after handshake to encrypt data in transport. This feature is
347+
controlled though the `ssl` connection option, so the flag has no effect.
348+
(Default off)
349+
- `SSL_VERIFY_SERVER_CERT` - Verify the server certificate during SSL set up. This
350+
feature is controlled though the `ssl.rejectUnauthorized` connection option, so
351+
the flag has no effect. (Default off)
352+
- `TRANSACTIONS` - Asks for the transaction status flags. (Default on)
353+
301354
## Terminating connections
302355

303356
There are two ways to end a connection. Terminating a connection gracefully is
@@ -1375,63 +1428,6 @@ connection = mysql.createConnection({
13751428
__WARNING: YOU MUST INVOKE the parser using one of these three field functions
13761429
in your custom typeCast callback. They can only be called once.__
13771430

1378-
## Connection Flags
1379-
1380-
If, for any reason, you would like to change the default connection flags, you
1381-
can use the connection option `flags`. Pass a string with a comma separated list
1382-
of items to add to the default flags. If you don't want a default flag to be used
1383-
prepend the flag with a minus sign. To add a flag that is not in the default list,
1384-
just write the flag name, or prefix it with a plus (case insensitive).
1385-
1386-
**Please note that some available flags that are not supported (e.g.: Compression),
1387-
are still not allowed to be specified.**
1388-
1389-
### Example
1390-
1391-
The next example blacklists FOUND_ROWS flag from default connection flags.
1392-
1393-
```js
1394-
var connection = mysql.createConnection("mysql://localhost/test?flags=-FOUND_ROWS");
1395-
```
1396-
1397-
### Default Flags
1398-
1399-
The following flags are sent by default on a new connection:
1400-
1401-
- `CONNECT_WITH_DB` - Ability to specify the database on connection.
1402-
- `FOUND_ROWS` - Send the found rows instead of the affected rows as `affectedRows`.
1403-
- `IGNORE_SIGPIPE` - Old; no effect.
1404-
- `IGNORE_SPACE` - Let the parser ignore spaces before the `(` in queries.
1405-
- `LOCAL_FILES` - Can use `LOAD DATA LOCAL`.
1406-
- `LONG_FLAG`
1407-
- `LONG_PASSWORD` - Use the improved version of Old Password Authentication.
1408-
- `MULTI_RESULTS` - Can handle multiple resultsets for COM_QUERY.
1409-
- `ODBC` Old; no effect.
1410-
- `PROTOCOL_41` - Uses the 4.1 protocol.
1411-
- `PS_MULTI_RESULTS` - Can handle multiple resultsets for COM_STMT_EXECUTE.
1412-
- `RESERVED` - Old flag for the 4.1 protocol.
1413-
- `SECURE_CONNECTION` - Support native 4.1 authentication.
1414-
- `TRANSACTIONS` - Asks for the transaction status flags.
1415-
1416-
In addition, the following flag will be sent if the option `multipleStatements`
1417-
is set to `true`:
1418-
1419-
- `MULTI_STATEMENTS` - The client may send multiple statement per query or
1420-
statement prepare.
1421-
1422-
### Other Available Flags
1423-
1424-
There are other flags available. They may or may not function, but are still
1425-
available to specify.
1426-
1427-
- `COMPRESS`
1428-
- `INTERACTIVE`
1429-
- `NO_SCHEMA`
1430-
- `PLUGIN_AUTH`
1431-
- `REMEMBER_OPTIONS`
1432-
- `SSL`
1433-
- `SSL_VERIFY_SERVER_CERT`
1434-
14351431
## Debugging and reporting problems
14361432

14371433
If you are running into problems, one thing that may help is enabling the

0 commit comments

Comments
 (0)