-
Connector/Node.js now supports connection attributes as key-value pairs that application programs can pass to the server. Connector/Node.js defines a default set of attributes, which can be disabled or enabled. In addition to these default attributes, applications can also provide their own set of custom attributes, as listed here:
-
The application can specify connection attributes as a
connection-attributes
parameter in a connection string, or by using theconnectionAttributes
property using either a plain JavaScript object or JSON notation to specify the connection configuration options.The
connection-attributes
parameter value must be empty (the same as specifyingtrue
), aBoolean
value (true
orfalse
to enable or disable the default attribute set), or a list of zero or morekey=value
pair specifiers separated by commas (to be sent in addition to the default attribute set). Within a list, a missing key value evaluates asNULL
.The
connectionAttributes
property allows passing user-defined attributes to the application using either a plain JavaScript object or JSON notation to specify the connection configuration options. In such cases, define each attribute in a nested object underconnectionAttributes
, where the property names match the attribute names and the property values match the attribute values. Unlikeconnection-attributes
, and while using plain JavaScript objects or JSON notation, if theconnectionAttributes
object contains duplicate keys then no error is thrown and the last value specified for a duplicate object key is chosen as the effective attribute value.Examples:
Not sending the default client-defined attributes:
mysqlx.getSession('{ "user": "root", "connectionAttributes": false }') mysqlx.getSession('mysqlx://root@localhost?connection-attributes=false') mysqlx.getSession({ user: 'root', connectionAttributes: { foo: 'bar', baz: 'qux', quux: '' } }) mysqlx.getSession('mysqlx://root@localhost?connection-attributes=[foo=bar,baz=qux,quux]')
Attribute names defined by applications cannot begin with
_
; such names are reserved for internal attributes.If connection attributes are not specified in a valid way, an error occurs and the connection attempt fails.
For general information about connection attributes, see Performance Schema Connection Attribute Tables. (WL #12495)
-
Optimized the reuse of existing connections through
client.getSession()
by reauthenticating only if required. (WL #12484)For X DevAPI, performance for statements that are executed repeatedly is improved by using serverside prepared statements for the second and any subsequent executions. This happens internally; applications need take no action and API behavior should be the same as previously. For statements that change, repreparation occurs as needed. Providing different data values, or different
offset()
orlimit()
values, does not count as a change for this purpose. Instead, the new values are passed to a new invocation of the previously prepared statement. (WL #12482)
Idle pooled connections to MySQL Server were not reused; new connections had to be recreated instead. (Bug #29436892)
Executing
client.close()
did not close all associated connections in the connection pool. (Bug #29428477)connectTimeout
instead ofmaxIdleTime
determined whether idle connections in the connection pool were reused rather than creating new connections. (Bug #29427271)Released connections from the connection pool were not reset and reused; new connections were made instead. (Bug #29392088)
Date values in documents were converted to empty objects when inserted into a collection. (Bug #29179767, Bug #93839)
A
queueTimeout
value other than 0 (infinite) prevented the acquisition of old released connections from the connection pool. (Bug #29179372, Bug #93841)