Oracle 5.0 Reference Manual page 2605

Table of Contents

Advertisement

Attention has to be paid on escaping strings with a certain charset but using the result on a connection
that uses a different charset. Please note, that PECL/mysqlnd_ms manipulates connections and
one application level connection represents a pool of multiple connections that all may have different
default charsets. It is recommended to configure the servers involved to use the same default
charsets. The configuration setting
server_charset, the plugin will set the given charset on all newly opened connections.
20.7.6.5.3. Transaction handling
Copyright 1997-2012 the PHP Documentation Group. [2230]
Transaction handling is fundamentally changed. An SQL transaction is a unit of work that is run on one
database server. The unit of work consists of one or more SQL statements.
By default the plugin is not aware of SQL transactions. The plugin may switch connections for load
balancing at any point in time. Connection switches may happen in the middle of a transaction. This is
against the nature of an SQL transaction. By default, the plugin is not transaction safe.
Any kind of MySQL load balancer must be hinted about the begin and end of a transaction. Hinting can
either be done implicitly by monitoring API calls or using SQL hints. Both options are supported by the
plugin, depending on your PHP version. API monitoring requires PHP 5.4.0 or newer. The plugin, like
any other MySQL load balancer, cannot detect transaction boundaries based on the MySQL Client
Server Protocol. Thus, entirely transparent transaction aware load balancing is not possible. The least
intrusive option is API monitoring, which requires little to no application changes, depending on your
application.
Please, find examples of using SQL hints or the API monitoring in the
behind the API monitoring, which makes the plugin transaction aware, are described below.
Beginning with PHP 5.4.0, the
set_autocommit(), to detect the status of
The PHP MySQL extensions either issue a query (such as
use the mysqlnd library call
an extension makes use of set_autocommit(), the plugin can be made transaction
aware. Transaction awareness cannot be achieved if using SQL to set the autocommit
mode. The library function
PDO::setAttribute(PDO::ATTR_AUTOCOMMIT)
The plugin configuration option
aware. In this mode, the plugin stops load balancing if autocommit becomes disabled, and directs all
statements to the master until autocommit gets enabled.
An application that does not want to set SQL hints for transactions but wants to use the transparent
API monitoring to avoid application changes must make sure that the autocommit settings is changed
exclusively through the listed API calls.
API based transaction boundary detection has been improved with PHP 5.5.0 and PECL/mysqlnd_ms
1.5.0 to cover not only calls to
mysqli_rollback.
20.7.6.5.4. Error handling
Copyright 1997-2012 the PHP Documentation Group. [2230]
Applications using PECL/mysqlnd_ms should implement proper error handling for all user API
calls. And because the plugin changes the semantics of a connection handle, API calls may return
unexpected errors. If using the plugin on a connection handle that no longer represents an individual
network connection, but a connection pool, an error code and error message will be set on the
connection handle whenever an error occurs on any of the network connections behind.
Mysqlnd replication and load balancing plugin (mysqlnd_ms)
server_charset
mysqlnd
set_autocommit()
set_autocommit()
trx_stickiness=master
mysqli_autocommit
does help with this situation as well. If using
library allows this plugin to subclass the library C API call
mode.
autocommit
SET
to control the
is called by the
user API calls.
can be used to make the plugin transactional
but also mysqli_begin,
2585
examples
section. The details
AUTOCOMMIT=0|1), or
setting. If
autocommit
mysqli_autocommit
mysqli_commit
and
and

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents