The functions described in this section are used with GTID-based replication (available in MySQL 5.6.5 and later). For more information about GTIDs and how these functions are used, see Section 16.1.3, “Replication with Global Transaction Identifiers”.
The union of two GTID sets is simply their string representations joined together with an interposed comma. In other words, you can define a very simple function for obtaining the union of two GTID sets like this:
CREATE FUNCTION GTID_UNION(g1 TEXT, g2 TEXT)
RETURNS TEXT DETERMINISTIC
RETURN CONCAT(g1,',',g2);
Table 12.19. GTID Functions
| Name | Description |
|---|---|
GTID_SUBSET() | Return true if all GTIDs in subset are also in set; otherwise false. |
GTID_SUBTRACT() | Return all GTIDs in set that are not in subset. |
SQL_THREAD_WAIT_AFTER_GTIDS()(deprecated 5.6.9) | OBSOLETE: Replaced by WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS() |
WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS() | Wait until the slave SQL thread has executed all the given GTIDs. Returns: the number of events that were executed (or NULL, if GTID mode is not enabled). |
Given two sets of global transaction IDs
subset and
set, returns true if all GTIDs in
subset are also in
set. Returns false otherwise.
This function was added in MySQL 5.6.5.
Given two sets of global transaction IDs
subset and
set, returns only those GTIDs from
set that are not in
subset.
This function was added in MySQL 5.6.5.
SQL_THREAD_WAIT_AFTER_GTIDS(
gtid_set[,
timeout])
SQL_THREAD_WAIT_AFTER_GTIDS() was added in
MySQL 5.6.5, and replaced by
WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS()
in MySQL 5.6.9. (Bug #14775984)
For more information, see Section 16.1.3, “Replication with Global Transaction Identifiers”.
WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS(
gtid_set[,
timeout])
Wait until the slave SQL thread has executed all of the
transactions whose global transaction identifiers are
contained in gtid_set (see
Section 16.1.3.1, “GTID Concepts”, for a definition
of “GTID sets”), or until
timeout seconds have elapsed,
whichever occurs first. timeout is
optional; the default timeout is 0 seconds, in which case the
master simply waits until all of the transactions in the GTID
set have been executed.
Prior to MySQL 5.6.9,
WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS() was
named
SQL_THREAD_WAIT_AFTER_GTIDS().
(Bug #14775984)
For more information, see Section 16.1.3, “Replication with Global Transaction Identifiers”.
mysql> SELECT WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS('3E11FA47-71CA-11E1-9E33-C80AA9429562:1-5');
-> 5
The return value is the number of transactional events that
were executed. Prior to MySQL 5.6.8, this function behaved
unpredictably if no timeout was set and it was invoked while
GTID-based replication was not active; in MySQL 5.6.8 and
later, the function returns NULL whenever
gtid_mode is
OFF. (Bug #14640065)

User Comments
Add your own comment.