-
A session now can acquire a lock for documents or rows returned by find or select statements, to prevent the returned values from being changed from other sessions while the lock is held (provided that appropriate isolation levels are used). Locks can be requested several times for a given find or select statement. Only the final request is acted upon. An acquired lock is held until the end of the current transaction.
For X DevAPI,
CollectionFind
andTableSelect
implement.lockExclusive()
and.lockShared()
methods, which request exclusive or shared locks, respectively, on returned documents or rows. These methods can be called after.bind()
and before the final.execute()
.For X DevAPI for C, the new
mysqlx_set_locking(
function can be called to request exclusive or shared locks on returned documents or rows, or to release locks. Thestmt
,lock
)lock
parameter can beROW_LOCK_EXCLUSIVE
,ROW_LOCK_SHARED
, orROW_LOCK_NONE
. The first two values specify a type of lock to be acquired.ROW_LOCK_NONE
removes any row locking request from the statement. (WL #10980) -
For X DevAPI, a new
auth
option can be specified in connection strings or URIs to indicate the authentication mechanism. Permitted values arePLAIN
andMYSQL41
. The option name and value are not case sensitive. TheSessionSettings::Options
object supports a newAUTH
enumeration, with the same permitted values.For X DevAPI for C, a new
auth
setting can be specified in connection strings or URIs to indicate the authentication mechanism. Permitted values arePLAIN
andMYSQL41
. The option name and value are not case sensitive. A newMYSQLX_OPT_AUTH
constant is recognized by themysqlx_options_set()
function, with permitted valuesMYSQLX_AUTH_PLAIN
andMYSQLX_AUTH_MYSQL41
.If the authentication mechanism is not specified, it defaults to
PLAIN
for secure (TLS) connections, orMYSQL41
for insecure connections. For Unix socket connections, the default isPLAIN
. (WL #10718) -
Boolean expressions used in queries and statements now support a variant of the
IN
operator for which the right hand side operand is any expression that evaluates to an array or document.X DevAPI example:
coll.find("'car' IN $.toys").execute();
X DevAPI for C example:
res = mysqlx_collection_find(coll, "'car' IN $.toys");
In this form, the
IN
operator is equivalent to theJSON_CONTAINS()
SQL function. (WL #10979) -
On Unix and Unix-like systems, Unix domain socket files are now supported as a connection transport for X DevAPI or X DevAPI for C connections. The socket file can be given in a connection string or in the session creation options.
X DevAPI examples:
XSession sess("mysqlx://user:password@(/path/to/mysql.sock)/schema"); XSession sess({ SessionSettings::USER, "user", SessionSettings::PWD, "password, SessionSettings::SOCKET, "/path/to/mysql.sock" SessionSettings::DB, "schema" });
X DevAPI for C examples:
mysqlx_session_t *sess = mysqlx_get_session_from_url( "mysqlx://user:password@(/path/to/mysql.sock)/schema", err_buf, &err_code ); mysqlx_opt_type_t *sess_opt = mysqlx_session_option_new(); mysqlx_session_option_set(sess_opt, MYSQLX_OPT_SOCKET, "/path/to/mysql.sock", MYSQLX_OPT_USER, "user", MYSQLX_OPT_PWD, "password", MYSQLX_OPT_DB, "schema"); mysqlx_session_t *sess = mysqlx_get_session_from_options( sess_opt, err_buf, &err_code );
(WL #9953)
-
These drop API changes were made:
Session::dropTable(
andschema
,table
)Session::dropCollection(
were replaced byschema
,coll
)Schema::dropTable(
andtable
)Schema::dropCollection(
, respectively.coll
)Schema::dropView()
is now a direct-execute method returningvoid
rather thanExecutable
.All
drop
methods succeed if the dropped objects do not exist.XXX
()
(WL #10787)
-
The following
Collection
methods were added:addOrReplaceOne()
,getOne()
,replaceOne()
, andremoveOne()
.The
addOrReplaceOne()
andreplaceOne()
methods work only with MySQL 8.0.3 and higher servers. For older servers, they report an error. (WL #10981)