MySQL 8.0.37
Source Code Documentation
gtid.h
Go to the documentation of this file.
1/* Copyright (c) 2021, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef BINARY_LOG_GTIDS_GTID_INCLUDED
25#define BINARY_LOG_GTIDS_GTID_INCLUDED
26
27#include <set>
28#include <sstream>
29
31
32namespace binary_log::gtids {
33
34/**
35 * @brief Represents a MySQL Global Transaction Identifier.
36 *
37 * This class abstracts the representation of a Global Transaction Identifier.
38 *
39 * It contains two fields, a UUID and a sequence number.
40 */
41class Gtid {
42 public:
43 /// In 'UUID:SEQNO', this is the ':'
44 static const inline std::string SEPARATOR_UUID_SEQNO{":"};
45
46 protected:
49
50 public:
51 /**
52 * @brief Construct a new Gtid object
53 *
54 * @param uuid the uuid part of the transaction identifier.
55 * @param gno The gno part of the transaction identfier.
56 */
57 Gtid(const Uuid &uuid, gno_t gno);
58
59 /**
60 * @brief Destroy the Gtid object
61 *
62 */
63 virtual ~Gtid();
64
65 /**
66 * @brief Get the sequence number of this transaction identifier.
67 *
68 * @return The sequence number part of this transaction identifier.
69 */
70 virtual gno_t get_gno() const;
71
72 /**
73 * @brief Get the uuid of this transaction identifier.
74 *
75 * @return The uuid part of this transaction identifier.
76 */
77 virtual const Uuid &get_uuid() const;
78
79 /**
80 * @brief Gets a human readable representation of this transaction identifier.
81 *
82 * @return A human readable representation of this transaction identifier.
83 */
84 virtual std::string to_string() const;
85
86 /**
87 * @brief Compares two identifiers and returns whether they match or not.
88 *
89 * @param other The other transaction identifier to compare to this one.
90 * @return true if the identifiers are equal.
91 * @return false otherwise.
92 */
93 virtual bool operator==(const Gtid &other) const;
94
95 /**
96 * @brief Compares two identifiers and returns whether they are different.
97 *
98 * @param other The other transaction identifier to compare to this one.
99 * @return true if the identifiers are different.
100 * @return false otherwise.
101 */
102 virtual bool operator!=(const Gtid &other) const;
103
104 /**
105 * @brief Copy assignment.
106 *
107 * Note that this operator will do a deep copy of the other identifier.
108 *
109 * @param other Copies the uuid and gno of the other identifier.
110 * @return a copy of the other identifier.
111 */
112 virtual Gtid &operator=(const Gtid &other);
113
114 /**
115 * @brief Construct a new Gtid object from another one, by deep copying its
116 * contents.
117 *
118 * @param other the other gtid to construct this gtid from.
119 */
120 Gtid(const Gtid &other);
121};
122
123} // namespace binary_log::gtids
124
125#endif
Represents a MySQL Global Transaction Identifier.
Definition: gtid.h:41
virtual ~Gtid()
Destroy the Gtid object.
virtual std::string to_string() const
Gets a human readable representation of this transaction identifier.
Definition: gtid.cpp:37
virtual bool operator==(const Gtid &other) const
Compares two identifiers and returns whether they match or not.
Definition: gtid.cpp:52
Gtid(const Uuid &uuid, gno_t gno)
Construct a new Gtid object.
Definition: gtid.cpp:30
Uuid m_uuid
Definition: gtid.h:47
virtual Gtid & operator=(const Gtid &other)
Copy assignment.
Definition: gtid.cpp:43
virtual gno_t get_gno() const
Get the sequence number of this transaction identifier.
Definition: gtid.cpp:34
gno_t m_gno
Definition: gtid.h:48
virtual const Uuid & get_uuid() const
Get the uuid of this transaction identifier.
Definition: gtid.cpp:35
virtual bool operator!=(const Gtid &other) const
Compares two identifiers and returns whether they are different.
Definition: gtid.cpp:56
static const std::string SEPARATOR_UUID_SEQNO
In 'UUID:SEQNO', this is the ':'.
Definition: gtid.h:44
Definition: global.h:32
std::int64_t gno_t
Definition: global.h:34
This is a POD.
Definition: uuid.h:61