12.19 Functions Used with Global Transaction Identifiers (GTIDs)与全局事务标识符(GTID)一起使用的函数

The functions described in this section are used with GTID-based replication. 本节中描述的功能用于基于GTID的复制。It is important to keep in mind that all of these functions take string representations of GTID sets as arguments. 请务必记住,所有这些函数都将GTID集的字符串表示形式作为参数。As such, the GTID sets must always be quoted when used with them. 因此,与GTID集一起使用时,必须始终引用GTID集。See GTID Sets for more information.有关详细信息,请参见GTID集

The union of two GTID sets is simply their representations as strings, joined together with an interposed comma. 两个GTID集的并集只是它们作为字符串的表示,用插入的逗号连接在一起。In other words, you can define a very simple function for obtaining the union of two GTID sets, similar to that created here:换句话说,您可以定义一个非常简单的函数来获得两个GTID集的并集,类似于这里创建的:

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”.有关GTID以及如何在实践中使用这些GTID函数的更多信息,请参阅第17.1.3节,“使用全局事务标识符的复制”

Table 12.24 GTID FunctionsGTID函数

Name名称Description描述Deprecated退出版本
GTID_SUBSET()Return true if all GTIDs in subset are also in set; otherwise false.如果子集中的所有GTID也在集合中,则返回true;否则为false
GTID_SUBTRACT()Return all GTIDs in set that are not in subset.返回集合中所有不在子集中的gtid。
WAIT_FOR_EXECUTED_GTID_SET()Wait until the given GTIDs have executed on the replica.等待给定的gtid在复制副本上执行。
WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS()Use WAIT_FOR_EXECUTED_GTID_SET().使用WAIT _FOR _EXECUTED _GTID_SET()8.0.18