Oracle 5.0 Reference Manual page 2594

Table of Contents

Advertisement

Mysqlnd replication and load balancing plugin (mysqlnd_ms)
string(1) "1"
}
The example runs three statements in auto commit mode on the master, causing three transactions
on the master. For every such statement, the plugin will inject the configured
before executing the users SQL statement. When the script ends the global transaction ID counter on
the master has been incremented by three.
The fourth SQL statement executed in the example, a SELECT, does not trigger an increment. Only
transactions (writes) executed on a master shall increment the GTID counter.
SQL for global transaction ID: efficient solution wanted!
The SQL used for the client-side global transaction ID emulation is inefficient.
It is optimized for clearity not for performance. Do not use it for production
environments. Please, help finding an efficient solution for inclusion in the
manual. We appreciate your input.
Example 20.241. Plugin config: SQL for fetching GTID
{
"myapp": {
"master": {
"master_0": {
"host": "localhost",
"socket": "\/tmp\/mysql.sock"
}
},
"slave": {
"slave_0": {
"host": "127.0.0.1",
"port": "3306"
}
},
"global_transaction_id_injection":{
"on_commit":"UPDATE test.trx SET trx_id = trx_id + 1",
"fetch_last_gtid" : "SELECT MAX(trx_id) FROM test.trx",
"report_error":true
}
}
}
Example 20.242. Obtaining GTID after injection
<?php
$mysqli = new mysqli("myapp", "username", "password", "database");
if (!$mysqli)
/* Of course, your error handling is nicer... */
die(sprintf("[%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()));
/* auto commit mode, transaction on master, GTID must be incremented */
if (!$mysqli->query("DROP TABLE IF EXISTS test"))
die(sprintf("[%d] %s\n", $mysqli->errno, $mysqli->error));
printf("GTID after transaction %s\n", mysqlnd_ms_get_last_gtid($mysqli));
/* auto commit mode, transaction on master, GTID must be incremented */
if (!$mysqli->query("CREATE TABLE test(id INT)"))
die(sprintf("[%d] %s\n", $mysqli->errno, $mysqli->error));
printf("GTID after transaction %s\n", mysqlnd_ms_get_last_gtid($mysqli));
?>
2574
transparently
UPDATE

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents