MySQL 9.1.0
Source Code Documentation
|
Represents a set of GTIDs. More...
#include <rpl_gtid.h>
Classes | |
class | Const_interval_iterator |
Iterator over intervals of a const Gtid_set. More... | |
class | Free_intervals_lock |
Class representing a lock on free_intervals_mutex. More... | |
class | Gtid_iterator |
Iterator over all gtids in a Gtid_set. More... | |
struct | Interval |
Represents one element in the linked list of intervals associated with a SIDNO. More... | |
struct | Interval_chunk |
Contains a list of intervals allocated by this Gtid_set. More... | |
class | Interval_iterator |
Iterator over intervals of a non-const Gtid_set, with additional methods to modify the Gtid_set. More... | |
class | Interval_iterator_base |
Iterator over intervals for a given SIDNO. More... | |
struct | String_format |
Class Gtid_set::String_format defines the separators used by Gtid_set::to_string. More... | |
Public Member Functions | |
Gtid_set (Tsid_map *tsid_map, Checkable_rwlock *tsid_lock=nullptr) | |
Constructs a new, empty Gtid_set. More... | |
Gtid_set (Tsid_map *tsid_map, const char *text, enum_return_status *status, Checkable_rwlock *tsid_lock=nullptr) | |
Constructs a new Gtid_set that contains the gtids in the given string, in the same format as add_gtid_text(char *). More... | |
~Gtid_set () | |
Destroy this Gtid_set. More... | |
void | claim_memory_ownership (bool claim) |
Claim ownership of memory. More... | |
void | clear () |
Removes all gtids from this Gtid_set. More... | |
void | clear_set_and_tsid_map () |
Removes all gtids from this Gtid_set and clear all the sidnos used by the Gtid_set and it's TSID map. More... | |
void | _add_gtid (rpl_sidno sidno, rpl_gno gno) |
Adds the given GTID to this Gtid_set. More... | |
void | _remove_gtid (rpl_sidno sidno, rpl_gno gno) |
Removes the given GTID from this Gtid_set. More... | |
void | _add_gtid (const Gtid >id) |
Adds the given GTID to this Gtid_set. More... | |
void | _remove_gtid (const Gtid >id) |
Removes the given GTID from this Gtid_set. More... | |
enum_return_status | add_gtid_set (const Gtid_set *other) |
Adds all gtids from the given Gtid_set to this Gtid_set. More... | |
void | remove_gtid_set (const Gtid_set *other) |
Removes all gtids in the given Gtid_set from this Gtid_set. More... | |
void | remove_intervals_for_sidno (Gtid_set *other, rpl_sidno sidno) |
Removes all intervals of 'other' for a given SIDNO, from 'this'. More... | |
enum_return_status | add_gtid_text (const char *text, bool *anonymous=nullptr, bool *starts_with_plus=nullptr) |
Adds the set of GTIDs represented by the given string to this Gtid_set. More... | |
enum_return_status | add_gtid (const mysql::gtid::Gtid >id) |
Adds specified GTID (TSID+GNO) to this Gtid_set. More... | |
enum_return_status | add_gtid_encoding (const uchar *encoded, size_t length, size_t *actual_length=nullptr) |
Decodes a Gtid_set from the given string. More... | |
bool | contains_gtid (rpl_sidno sidno, rpl_gno gno) const |
Return true iff the given GTID exists in this set. More... | |
bool | contains_gtid (const Gtid >id) const |
Return true iff the given GTID exists in this set. More... | |
rpl_gno | get_last_gno (rpl_sidno sidno) const |
rpl_sidno | get_max_sidno () const |
Returns the maximal sidno that this Gtid_set currently has space for. More... | |
enum_return_status | ensure_sidno (rpl_sidno sidno) |
Allocates space for all sidnos up to the given sidno in the array of intervals. More... | |
bool | is_subset (const Gtid_set *super) const |
Returns true if this Gtid_set is a subset of the other Gtid_set. More... | |
bool | is_subset_not_equals (const Gtid_set *super) const |
Returns true if this Gtid_set is a non equal subset of the other Gtid_set. More... | |
bool | is_subset_for_sidno (const Gtid_set *super, rpl_sidno superset_sidno, rpl_sidno subset_sidno) const |
Returns true if this Gtid_set is a subset of the given gtid_set on the given superset_sidno and subset_sidno. More... | |
bool | is_subset_for_sid (const Gtid_set *super, const rpl_sid &sid) const |
Returns true if this Gtid_set is a subset of the given gtid_set with respect to the given sid. More... | |
bool | is_intersection_nonempty (const Gtid_set *other) const |
Returns true if there is a least one element of this Gtid_set in the other Gtid_set. More... | |
enum_return_status | intersection (const Gtid_set *other, Gtid_set *result) |
Add the intersection of this Gtid_set and the other Gtid_set to result. More... | |
bool | is_empty () const |
Returns true if this Gtid_set is empty. More... | |
bool | is_size_greater_than_or_equal (ulonglong num) const |
Return true if the size of the set is greater than or equal to the given number. More... | |
ulonglong | get_gtid_count (rpl_sidno sidno) const |
What is the count of all the GTIDs in all intervals for a sidno. More... | |
std::size_t | get_count () const |
Returns the number of GTIDs. More... | |
bool | contains_sidno (rpl_sidno sidno) const |
Returns true if this Gtid_set contains at least one GTID with the given SIDNO. More... | |
bool | contains_tags () const |
Checks if this Gtid set contains any tagged GTIDs. More... | |
size_t | get_string_length (const String_format *string_format=nullptr) const |
Returns the length of the output from to_string. More... | |
size_t | to_string (char *buf, bool need_lock=false, const String_format *string_format=nullptr) const |
Formats this Gtid_set as a string and saves in a given buffer. More... | |
long | to_string (char **buf, bool need_lock=false, const String_format *string_format=nullptr) const |
Formats a Gtid_set as a string and saves in a newly allocated buffer. More... | |
void | print (bool need_lock=false, const Gtid_set::String_format *sf=nullptr) const |
Debug only: Print this Gtid_set to stdout. More... | |
void | dbug_print (const char *text="", bool need_lock=false, const Gtid_set::String_format *sf=nullptr) const |
Print this Gtid_set to the trace file if debug is enabled; no-op otherwise. More... | |
void | get_gtid_intervals (std::list< Gtid_interval > *gtid_intervals) const |
Gets all gtid intervals from this Gtid_set. More... | |
Tsid_map * | get_tsid_map () const |
Return the Tsid_map associated with this Gtid_set. More... | |
void | add_interval_memory (int n_intervals, Interval *intervals_param) |
Provides an array of Intervals that this Gtid_set can use when gtids are subsequently added. More... | |
void | encode (uchar *buf, bool skip_tagged_gtids=false) const |
Encodes this Gtid_set as a binary string. More... | |
size_t | get_encoded_length (bool skip_tagged_gtids=false) const |
Returns the length of this Gtid_set when encoded using the encode() function. More... | |
std::size_t | get_encoded_length (const mysql::gtid::Gtid_format &format, bool skip_tagged_gtids) const |
Returns the length of this Gtid_set when encoded using the encode() function. More... | |
bool | equals (const Gtid_set *other) const |
Returns true if this Gtid_set is equal to the other Gtid_set. More... | |
Static Public Member Functions | |
static bool | is_valid (const char *text) |
Returns true if the given string is a valid specification of a Gtid_set, false otherwise. More... | |
Static Public Attributes | |
static PSI_mutex_key | key_gtid_executed_free_intervals_mutex |
static const String_format | default_string_format |
The default String_format: the format understood by add_gtid_text(const char *). More... | |
static const String_format | sql_string_format |
String_format useful to generate an SQL string: the string is wrapped in single quotes and there is a newline between SIDs. More... | |
static const String_format | commented_string_format |
String_format for printing the Gtid_set commented: the string is not quote-wrapped, and every TSID is on a new line with a leading '# '. More... | |
Private Member Functions | |
void | init () |
Worker for the constructor. More... | |
bool | sidno_equals (rpl_sidno sidno, const Gtid_set *other, rpl_sidno other_sidno) const |
Return true if the given sidno of this Gtid_set contains the same intervals as the given sidno of the other Gtid_set. More... | |
int | get_n_intervals (rpl_sidno sidno) const |
Return the number of intervals for the given sidno. More... | |
int | get_n_intervals () const |
Return the number of intervals in this Gtid_set. More... | |
mysql::gtid::Gtid_format | analyze_encoding_format (bool skip_tagged_gtids) const |
Goes through recorded tsids. More... | |
void | create_new_chunk (int size) |
Allocates a new chunk of Intervals and adds them to the list of unused intervals. More... | |
void | get_free_interval (Interval **out) |
Returns a fresh new Interval object. More... | |
void | put_free_interval (Interval *iv) |
Puts the given interval in the list of free intervals. More... | |
void | add_interval_memory_lock_taken (int n_ivs, Interval *ivs) |
Like add_interval_memory, but does not acquire free_intervals_mutex. More... | |
void | assert_free_intervals_locked () |
void | add_gno_interval (Interval_iterator *ivitp, rpl_gno start, rpl_gno end, Free_intervals_lock *lock) |
Adds the interval (start, end) to the given Interval_iterator. More... | |
void | remove_gno_interval (Interval_iterator *ivitp, rpl_gno start, rpl_gno end, Free_intervals_lock *lock) |
Removes the interval (start, end) from the given Interval_iterator. More... | |
void | add_gno_intervals (rpl_sidno sidno, Const_interval_iterator ivit, Free_intervals_lock *lock) |
Adds a list of intervals to the given SIDNO. More... | |
void | remove_gno_intervals (rpl_sidno sidno, Const_interval_iterator ivit, Free_intervals_lock *lock) |
Removes a list of intervals from the given SIDNO. More... | |
Static Private Member Functions | |
static bool | is_interval_subset (Const_interval_iterator *sub, Const_interval_iterator *super) |
Returns true if every interval of sub is a subset of some interval of super. More... | |
static bool | is_interval_intersection_nonempty (Const_interval_iterator *ivit1, Const_interval_iterator *ivit2) |
Returns true if at least one sidno in ivit1 is also in ivit2. More... | |
Private Attributes | |
Checkable_rwlock * | tsid_lock |
Read-write lock that protects updates to the number of TSIDs. More... | |
mysql_mutex_t | free_intervals_mutex |
Lock protecting the list of free intervals. More... | |
Tsid_map * | tsid_map |
Tsid_map associated with this Gtid_set. More... | |
Prealloced_array< Interval *, 8 > | m_intervals |
Array where the N'th element contains the head pointer to the intervals of SIDNO N+1. More... | |
Interval * | free_intervals |
Linked list of free intervals. More... | |
Interval_chunk * | chunks |
Linked list of chunks. More... | |
bool | has_cached_string_length |
If the string is cached. More... | |
size_t | cached_string_length |
The string length. More... | |
const String_format * | cached_string_format |
The String_format that was used when cached_string_length was computed. More... | |
int | n_chunks |
The number of chunks. More... | |
Static Private Attributes | |
static const int | CHUNK_GROW_SIZE = 8 |
The default number of intervals in an Interval_chunk. More... | |
Friends | |
class | Gtid_set::Free_intervals_lock |
Used by unit tests that need to access private members. More... | |
std::ostream & | operator<< (std::ostream &os, const Gtid_set &in) |
For use with C++ std::ostream More... | |
Represents a set of GTIDs.
This is structured as an array, indexed by SIDNO, where each element contains a linked list of intervals.
This data structure OPTIONALLY knows of a Tsid_map that gives a correspondence between SIDNO and TSID. If the Tsid_map is NULL, then operations that require a Tsid_map - printing and parsing - raise an assertion.
This data structure OPTIONALLY knows of a read-write lock that protects the number of SIDNOs. The lock is provided by the invoker of the constructor and it is generally the caller's responsibility to acquire the read lock. If the lock is not NULL, access methods assert that the caller already holds the read (or write) lock. If the lock is not NULL and a method of this class grows the number of SIDNOs, then the method temporarily upgrades this lock to a write lock and then degrades it to a read lock again; there will be a short period when the lock is not held at all.
Gtid_set::Gtid_set | ( | Tsid_map * | tsid_map, |
Checkable_rwlock * | tsid_lock = nullptr |
||
) |
Constructs a new, empty Gtid_set.
tsid_map | The Tsid_map to use, or NULL if this Gtid_set should not have a Tsid_map. |
tsid_lock | Read-write lock that protects updates to the number of TSIDs. This may be NULL if such changes do not need to be protected. |
Gtid_set::Gtid_set | ( | Tsid_map * | tsid_map, |
const char * | text, | ||
enum_return_status * | status, | ||
Checkable_rwlock * | tsid_lock = nullptr |
||
) |
Constructs a new Gtid_set that contains the gtids in the given string, in the same format as add_gtid_text(char *).
tsid_map | The Tsid_map to use for TSIDs. |
text | The text to parse. |
status | Will be set to RETURN_STATUS_OK on success or RETURN_STATUS_REPORTED_ERROR on error. |
tsid_lock | Read/write lock to protect changes in the number of SIDs with. This may be NULL if such changes do not need to be protected. If tsid_lock != NULL, then the read lock on tsid_lock must be held before calling this function. If the array is grown, tsid_lock is temporarily upgraded to a write lock and then degraded again; there will be a short period when the lock is not held at all. |
Gtid_set::~Gtid_set | ( | ) |
Destroy this Gtid_set.
|
inline |
Adds the given GTID to this Gtid_set.
The SIDNO must exist in the Gtid_set before this function is called.
gtid | Gtid to add. |
Adds the given GTID to this Gtid_set.
The SIDNO must exist in the Gtid_set before this function is called.
sidno | SIDNO of the GTID to add. |
gno | GNO of the GTID to add. |
|
inline |
Removes the given GTID from this Gtid_set.
gtid | Gtid to remove. |
Removes the given GTID from this Gtid_set.
sidno | SIDNO of the GTID to remove. |
gno | GNO of the GTID to remove. |
|
private |
Adds the interval (start, end) to the given Interval_iterator.
This is the lowest-level function that adds gtids; this is where Interval objects are added, grown, or merged.
ivitp | Pointer to iterator. After this function returns, the current_element of the iterator will be the interval that contains start and end. |
start | The first GNO in the interval. |
end | The first GNO after the interval. |
lock | If this function has to add or remove an interval, then this lock will be taken unless it is already taken. This mechanism means that the lock will be taken lazily by e.g. add_gtid_set() the first time that the list of free intervals is accessed, and automatically released when add_gtid_set() returns. |
|
private |
Adds a list of intervals to the given SIDNO.
The SIDNO must exist in the Gtid_set before this function is called.
sidno | The SIDNO to which intervals will be added. |
ivit | Iterator over the intervals to add. This is typically an iterator over some other Gtid_set. |
lock | If this function has to add or remove an interval, then this lock will be taken unless it is already taken. This mechanism means that the lock will be taken lazily by e.g. add_gtid_set() the first time that the list of free intervals is accessed, and automatically released when add_gtid_set() returns. |
enum_return_status Gtid_set::add_gtid | ( | const mysql::gtid::Gtid & | gtid | ) |
Adds specified GTID (TSID+GNO) to this Gtid_set.
gtid | mysql::gtid::Gtid object |
enum_return_status Gtid_set::add_gtid_encoding | ( | const uchar * | encoded, |
size_t | length, | ||
size_t * | actual_length = nullptr |
||
) |
Decodes a Gtid_set from the given string.
encoded | The string to parse. |
length | The number of bytes. |
actual_length | If this is not NULL, it is set to the number of bytes used by the encoding (which may be less than 'length'). If this is NULL, an error is generated if the encoding is shorter than the given 'length'. |
enum_return_status Gtid_set::add_gtid_set | ( | const Gtid_set * | other | ) |
Adds all gtids from the given Gtid_set to this Gtid_set.
If tsid_lock != NULL, then the read lock must be held before calling this function. If a new sidno is added so that the array of lists of intervals is grown, tsid_lock is temporarily upgraded to a write lock and then degraded again; there will be a short period when the lock is not held at all.
other | The Gtid_set to add. |
enum_return_status Gtid_set::add_gtid_text | ( | const char * | text, |
bool * | anonymous = nullptr , |
||
bool * | starts_with_plus = nullptr |
||
) |
Adds the set of GTIDs represented by the given string to this Gtid_set.
The string must have the format of a comma-separated list of zero or more of the following items:
XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX(:NUMBER+(-NUMBER)?)* | ANONYMOUS
Each X is a hexadecimal digit (upper- or lowercase). NUMBER is a decimal, 0xhex, or 0oct number.
The start of an interval must be greater than 0. The end of an interval may be 0, but any interval that has an endpoint that is smaller than the start is discarded.
The string can start with an optional '+' appender qualifier which triggers executed_gtids
and lost_gtids
set examination on the matter of disjointness with the one being added.
If tsid_lock != NULL, then the read lock on tsid_lock must be held before calling this function. If a new sidno is added so that the array of lists of intervals is grown, tsid_lock is temporarily upgraded to a write lock and then degraded again; there will be a short period when the lock is not held at all.
text | The string to parse. | |
[in,out] | anonymous | If this is NULL, ANONYMOUS is not allowed. If this is not NULL, it will be set to true if the anonymous GTID was found; false otherwise. |
[in,out] | starts_with_plus | If this is not NULL, the string may optionally begin with a '+' character, and *starts_with_plus will be set to true if the plus character is present. If this is NULL, no plus is allowed at the begin of the string. |
|
inline |
Provides an array of Intervals that this Gtid_set can use when gtids are subsequently added.
This can be used as an optimization, to reduce allocation for sets that have a known number of intervals.
n_intervals | The number of intervals to add. |
intervals_param | Array of n_intervals intervals. |
|
private |
Like add_interval_memory, but does not acquire free_intervals_mutex.
|
private |
Goes through recorded tsids.
In case any of the TSIDs has a tag, this function will return Gtid_format::tagged. Otherwise, it will return Gtid_format::untagged
skip_tagged_gtids | When true, function will always return Gtid_format::untagged |
|
inlineprivate |
void Gtid_set::claim_memory_ownership | ( | bool | claim | ) |
Claim ownership of memory.
claim | claim ownership of memory. |
void Gtid_set::clear | ( | ) |
Removes all gtids from this Gtid_set.
This does not deallocate anything: if gtids are added later, existing allocated memory will be re-used.
void Gtid_set::clear_set_and_tsid_map | ( | ) |
Removes all gtids from this Gtid_set and clear all the sidnos used by the Gtid_set and it's TSID map.
This does not deallocate anything: if gtids are added later, existing allocated memory will be re-used.
|
inline |
Return true iff the given GTID exists in this set.
Return true iff the given GTID exists in this set.
|
inline |
Returns true if this Gtid_set contains at least one GTID with the given SIDNO.
sidno | The SIDNO to test. |
true | The SIDNO is less than or equal to the max SIDNO, and there is at least one GTID with this SIDNO. |
false | The SIDNO is greater than the max SIDNO, or there is no GTID with this SIDNO. |
bool Gtid_set::contains_tags | ( | ) | const |
Checks if this Gtid set contains any tagged GTIDs.
true | This gtid set contains tagged GTIDs |
false | This gtid set contains only untagged GTIDs |
|
private |
Allocates a new chunk of Intervals and adds them to the list of unused intervals.
size | The number of intervals in this chunk |
|
inline |
Print this Gtid_set to the trace file if debug is enabled; no-op otherwise.
void Gtid_set::encode | ( | uchar * | buf, |
bool | skip_tagged_gtids = false |
||
) | const |
Encodes this Gtid_set as a binary string.
buf | Buffer to write into |
skip_tagged_gtids | When true, tagged GTIDS will be filtered out |
enum_return_status Gtid_set::ensure_sidno | ( | rpl_sidno | sidno | ) |
Allocates space for all sidnos up to the given sidno in the array of intervals.
The sidno must exist in the Tsid_map associated with this Gtid_set.
If tsid_lock != NULL, then the read lock on tsid_lock must be held before calling this function. If the array is grown, tsid_lock is temporarily upgraded to a write lock and then degraded again; there will be a short period when the lock is not held at all.
sidno | The SIDNO. |
bool Gtid_set::equals | ( | const Gtid_set * | other | ) | const |
Returns true if this Gtid_set is equal to the other Gtid_set.
[in] | other | Gtid set to compare against |
|
inline |
Returns the number of GTIDs.
size_t Gtid_set::get_encoded_length | ( | bool | skip_tagged_gtids = false | ) | const |
Returns the length of this Gtid_set when encoded using the encode() function.
Before calculation, analyzes GTID set format
skip_tagged_gtids | When true, tagged GTIDS will be filtered out |
size_t Gtid_set::get_encoded_length | ( | const mysql::gtid::Gtid_format & | format, |
bool | skip_tagged_gtids | ||
) | const |
Returns the length of this Gtid_set when encoded using the encode() function.
Uses already analyzed GTID set format (faster version)
format | Gtid format |
skip_tagged_gtids | When true, tagged GTIDS will be filtered out |
|
private |
Returns a fresh new Interval object.
This usually does not require any real allocation, it only pops the first interval from the list of free intervals. If there are no free intervals, it calls create_new_chunk.
out | The resulting Interval* will be stored here. |
What is the count of all the GTIDs in all intervals for a sidno.
sidno | The sidno that contains the intervals |
void Gtid_set::get_gtid_intervals | ( | std::list< Gtid_interval > * | gtid_intervals | ) | const |
Gets all gtid intervals from this Gtid_set.
[out] | gtid_intervals | Store all gtid intervals from this Gtid_set. |
|
inline |
Returns the maximal sidno that this Gtid_set currently has space for.
|
inlineprivate |
Return the number of intervals in this Gtid_set.
|
inlineprivate |
Return the number of intervals for the given sidno.
size_t Gtid_set::get_string_length | ( | const String_format * | string_format = nullptr | ) | const |
Returns the length of the output from to_string.
string_format | String_format object that specifies separators in the resulting text. |
|
inline |
Return the Tsid_map associated with this Gtid_set.
|
private |
Worker for the constructor.
enum_return_status Gtid_set::intersection | ( | const Gtid_set * | other, |
Gtid_set * | result | ||
) |
Add the intersection of this Gtid_set and the other Gtid_set to result.
other | The Gtid_set to intersect with this Gtid_set |
result | Gtid_set where the result will be stored. |
|
inline |
Returns true if this Gtid_set is empty.
bool Gtid_set::is_intersection_nonempty | ( | const Gtid_set * | other | ) | const |
Returns true if there is a least one element of this Gtid_set in the other Gtid_set.
|
staticprivate |
Returns true if at least one sidno in ivit1 is also in ivit2.
|
staticprivate |
Returns true if every interval of sub is a subset of some interval of super.
bool Gtid_set::is_size_greater_than_or_equal | ( | ulonglong | num | ) | const |
Return true if the size of the set is greater than or equal to the given number.
The size is measure in number of GTIDs, i.e., total length of all intervals.
num | Number to compare with |
true | if the set contains >= num GTIDs. |
false | if the set contains < num GTIDs. |
bool Gtid_set::is_subset | ( | const Gtid_set * | super | ) | const |
Returns true if this Gtid_set is a subset of the other Gtid_set.
Returns true if this Gtid_set is a subset of the given gtid_set with respect to the given sid.
This function will traverse all TSIDs with SID equal to "sid" parameter (all registered tags for a given SID)
super | Gtid_set with which this->gtid_set needs to be compared |
sid | Sid for which we will do the testing |
bool Gtid_set::is_subset_for_sidno | ( | const Gtid_set * | super, |
rpl_sidno | superset_sidno, | ||
rpl_sidno | subset_sidno | ||
) | const |
Returns true if this Gtid_set is a subset of the given gtid_set on the given superset_sidno and subset_sidno.
super | Gtid_set with which this->gtid_set needs to be compared |
superset_sidno | The sidno that will be compared, relative to super->tsid_map. |
subset_sidno | The sidno that will be compared, relative to this->tsid_map. |
|
inline |
Returns true if this Gtid_set is a non equal subset of the other Gtid_set.
|
static |
Returns true if the given string is a valid specification of a Gtid_set, false otherwise.
|
inline |
Debug only: Print this Gtid_set to stdout.
For use with C printf
|
private |
Puts the given interval in the list of free intervals.
Does not unlink it from its place in any other list.
|
private |
Removes the interval (start, end) from the given Interval_iterator.
This is the lowest-level function that removes gtids; this is where Interval objects are removed, truncated, or split.
It is not required that the gtids in the interval exist in this Gtid_set.
ivitp | Pointer to iterator. After this function returns, the current_element of the iterator will be the next interval after end. |
start | The first GNO in the interval. |
end | The first GNO after the interval. |
lock | If this function has to add or remove an interval, then this lock will be taken unless it is already taken. This mechanism means that the lock will be taken lazily by e.g. add_gtid_set() the first time that the list of free intervals is accessed, and automatically released when add_gtid_set() returns. |
|
private |
Removes a list of intervals from the given SIDNO.
It is not required that the intervals exist in this Gtid_set.
sidno | The SIDNO from which intervals will be removed. |
ivit | Iterator over the intervals to remove. This is typically an iterator over some other Gtid_set. |
lock | If this function has to add or remove an interval, then this lock will be taken unless it is already taken. This mechanism means that the lock will be taken lazily by e.g. add_gtid_set() the first time that the list of free intervals is accessed, and automatically released when add_gtid_set() returns. |
void Gtid_set::remove_gtid_set | ( | const Gtid_set * | other | ) |
Removes all gtids in the given Gtid_set from this Gtid_set.
other | The Gtid_set to remove. |
Removes all intervals of 'other' for a given SIDNO, from 'this'.
Example: this = A:1-100, B:1-100 other = A:1-100, B:1-50, C:1-100 this.remove_intervals_for_sidno(other, B) = A:1-100, B:51-100
It is not required that the intervals exist in this Gtid_set.
other | The set to remove. |
sidno | The sidno to remove. |
|
private |
Return true if the given sidno of this Gtid_set contains the same intervals as the given sidno of the other Gtid_set.
sidno | SIDNO to check for this Gtid_set. |
other | Other Gtid_set |
other_sidno | SIDNO to check in other. |
long Gtid_set::to_string | ( | char ** | buf, |
bool | need_lock = false , |
||
const String_format * | string_format = nullptr |
||
) | const |
Formats a Gtid_set as a string and saves in a newly allocated buffer.
[out] | buf | Pointer to pointer to string. The function will set it to point to the newly allocated buffer, or NULL on out of memory. |
need_lock | If this Gtid_set has a tsid_lock, then the write lock must be held while generating the string. If this parameter is true, then this function acquires and releases the lock; otherwise it asserts that the caller holds the lock. | |
string_format | Specifies how to format the string. |
Length | of the generated string, or -1 on out of memory. |
size_t Gtid_set::to_string | ( | char * | buf, |
bool | need_lock = false , |
||
const String_format * | string_format = nullptr |
||
) | const |
Formats this Gtid_set as a string and saves in a given buffer.
[out] | buf | Pointer to the buffer where the string should be stored. This should have size at least get_string_length()+1. |
need_lock | If this Gtid_set has a tsid_lock, then the write lock must be held while generating the string. If this parameter is true, then this function acquires and releases the lock; otherwise it asserts that the caller holds the lock. | |
string_format | String_format object that specifies separators in the resulting text. |
|
friend |
Used by unit tests that need to access private members.
Only Free_intervals_lock is allowed to access free_intervals_mutex.
|
friend |
For use with C++ std::ostream
|
mutableprivate |
The String_format that was used when cached_string_length was computed.
|
mutableprivate |
The string length.
|
staticprivate |
The default number of intervals in an Interval_chunk.
|
private |
Linked list of chunks.
|
static |
String_format for printing the Gtid_set commented: the string is not quote-wrapped, and every TSID is on a new line with a leading '# '.
|
static |
The default String_format: the format understood by add_gtid_text(const char *).
|
private |
Linked list of free intervals.
|
private |
Lock protecting the list of free intervals.
This lock is only used if tsid_lock is not NULL.
|
mutableprivate |
If the string is cached.
|
static |
|
private |
Array where the N'th element contains the head pointer to the intervals of SIDNO N+1.
|
private |
The number of chunks.
Used only to check some invariants when DBUG is on.
|
static |
String_format useful to generate an SQL string: the string is wrapped in single quotes and there is a newline between SIDs.
|
mutableprivate |
Read-write lock that protects updates to the number of TSIDs.
|
private |
Tsid_map associated with this Gtid_set.