12.15 GTID Functions

The functions described in this section are used with GTID-based replication (available in MySQL 5.6.5 and later). It is important to keep in mind that all of these functions take string representations of GTID sets as arguments—as such, the GTID sets must always be quoted when used with them.

The union of two GTID sets is simply their representations as strings, joined together with an interposed comma. In other words, you can define a very simple function for obtaining the union of two GTID sets, similar to that created here:

CREATE FUNCTION GTID_UNION(g1 TEXT, g2 TEXT) 
    RETURNS TEXT DETERMINISTIC
    RETURN CONCAT(g1,',',g2);  

For more information about GTIDs and how these GTID functions are used in practice, see Section 17.1.3, “Replication with Global Transaction Identifiers”.

Table 12.19 GTID Functions

NameDescription
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. Return: the number of events that were executed (or NULL, if GTID mode is not enabled).