MySQL 5.6.14 Source Code Document
|
#include <rpl_gtid.h>
Classes | |
class | Const_interval_iterator |
class | Free_intervals_lock |
class | Gtid_iterator |
struct | Interval |
struct | Interval_chunk |
class | Interval_iterator |
class | Interval_iterator_base |
struct | String_format |
Public Member Functions | |
Gtid_set (Sid_map *sid_map, Checkable_rwlock *sid_lock=NULL) | |
Gtid_set (Sid_map *sid_map, const char *text, enum_return_status *status, Checkable_rwlock *sid_lock=NULL) | |
~Gtid_set () | |
Destroy this Gtid_set. | |
void | clear () |
enum_return_status | _add_gtid (rpl_sidno sidno, rpl_gno gno) |
enum_return_status | _remove_gtid (rpl_sidno sidno, rpl_gno gno) |
enum_return_status | _add_gtid (const Gtid >id) |
enum_return_status | add_gtid_set (const Gtid_set *other) |
enum_return_status | remove_gtid_set (const Gtid_set *other) |
enum_return_status | add_gtid_text (const char *text, bool *anonymous=NULL) |
enum_return_status | add_gtid_encoding (const uchar *encoded, size_t length, size_t *actual_length=NULL) |
bool | contains_gtid (rpl_sidno sidno, rpl_gno gno) const |
Return true iff the given GTID exists in this set. | |
bool | contains_gtid (const Gtid >id) const |
Return true iff the given GTID exists in this set. | |
rpl_sidno | get_max_sidno () const |
Returns the maximal sidno that this Gtid_set currently has space for. | |
enum_return_status | ensure_sidno (rpl_sidno sidno) |
bool | is_subset (const Gtid_set *super) const |
Returns true if this Gtid_set is a subset of the other Gtid_set. | |
bool | is_intersection_nonempty (const Gtid_set *other) const |
enum_return_status | intersection (const Gtid_set *other, Gtid_set *result) |
bool | is_empty () const |
Returns true if this Gtid_set is empty. | |
bool | contains_sidno (rpl_sidno sidno) const |
char * | to_string () const |
void | print () const |
Debug only: Print this Gtid_set to stdout. | |
void | dbug_print (const char *text="") const |
int | get_string_length (const String_format *string_format=NULL) const |
int | to_string (char *buf, const String_format *string_format=NULL) const |
int | to_string (char **buf, const String_format *string_format=NULL) const |
Sid_map * | get_sid_map () const |
Return the Sid_map associated with this Gtid_set. | |
void | add_interval_memory (int n_intervals, Interval *intervals_param) |
void | encode (uchar *buf) const |
size_t | get_encoded_length () const |
Static Public Member Functions | |
static bool | is_valid (const char *text) |
Static Public Attributes | |
static const String_format | default_string_format |
static const String_format | sql_string_format |
static const String_format | commented_string_format |
Friends | |
class | Gtid_set::Free_intervals_lock |
Used by unit tests that need to access private members. |
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 Sid_map that gives a correspondence between SIDNO and SID. If the Sid_map is NULL, then operations that require a Sid_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.
Definition at line 842 of file rpl_gtid.h.
Gtid_set::Gtid_set | ( | Sid_map * | sid_map, |
Checkable_rwlock * | sid_lock = NULL |
||
) |
Constructs a new, empty Gtid_set.
sid_map | The Sid_map to use, or NULL if this Gtid_set should not have a Sid_map. |
sid_lock | Read-write lock that protects updates to the number of SIDs. This may be NULL if such changes do not need to be protected. |
Definition at line 50 of file rpl_gtid_set.cc.
Gtid_set::Gtid_set | ( | Sid_map * | sid_map, |
const char * | text, | ||
enum_return_status * | status, | ||
Checkable_rwlock * | sid_lock = NULL |
||
) |
Constructs a new Gtid_set that contains the groups in the given string, in the same format as add_gtid_text(char *).
sid_map | The Sid_map to use for SIDs. |
text | The text to parse. |
status | Will be set GS_SUCCESS or GS_ERROR_PARSE or GS_ERROR_OUT_OF_MEMORY. |
sid_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 sid_lock != NULL, then the read lock on sid_lock must be held before calling this function. If the array is grown, sid_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.
Definition at line 57 of file rpl_gtid_set.cc.
|
inline |
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 group to add. |
gno | GNO of the group to add. |
Definition at line 895 of file rpl_gtid.h.
|
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. |
Definition at line 930 of file rpl_gtid.h.
|
inline |
Removes the given GTID from this Gtid_set.
sidno | SIDNO of the group to remove. |
gno | GNO of the group to remove. |
Definition at line 910 of file rpl_gtid.h.
enum_return_status Gtid_set::add_gtid_encoding | ( | const uchar * | encoded, |
size_t | length, | ||
size_t * | actual_length = NULL |
||
) |
Decodes a Gtid_set from the given string.
string | 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'. |
Definition at line 1315 of file rpl_gtid_set.cc.
enum_return_status Gtid_set::add_gtid_set | ( | const Gtid_set * | other | ) |
Adds all groups from the given Gtid_set to this Gtid_set.
If sid_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, sid_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. |
Definition at line 648 of file rpl_gtid_set.cc.
enum_return_status Gtid_set::add_gtid_text | ( | const char * | text, |
bool * | anonymous = NULL |
||
) |
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:
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.
If sid_lock != NULL, then the read lock on sid_lock must be held before calling this function. If a new sidno is added so that the array of lists of intervals is grown, sid_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. |
anonymous[in,out] | If this is NULL, ANONYMOUS is not allowed. If this is not NULL, it will be set to true if the anonymous group was found; false otherwise. |
Definition at line 408 of file rpl_gtid_set.cc.
|
inline |
Provides an array of Intervals that this Gtid_set can use when groups 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 | Array of n_intervals intervals. |
Definition at line 1202 of file rpl_gtid.h.
void Gtid_set::clear | ( | ) |
Removes all groups from this Gtid_set.
This does not deallocate anything: if groups are added later, existing allocated memory will be re-used.
Definition at line 229 of file rpl_gtid_set.cc.
|
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 group with this SIDNO. |
false | The SIDNO is greater than the max SIDNO, or there is no group with this SIDNO. |
Definition at line 1048 of file rpl_gtid.h.
|
inline |
Print this Gtid_set to the trace file if debug is enabled; no-op otherwise.
Definition at line 1085 of file rpl_gtid.h.
void Gtid_set::encode | ( | uchar * | buf | ) | const |
Encodes this Gtid_set as a binary string.
Definition at line 1259 of file rpl_gtid_set.cc.
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 Sid_map associated with this Gtid_set.
If sid_lock != NULL, then the read lock on sid_lock must be held before calling this function. If the array is grown, sid_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. |
Definition at line 105 of file rpl_gtid_set.cc.
size_t Gtid_set::get_encoded_length | ( | ) | const |
Returns the length of this Gtid_set when encoded using the encode() function.
Definition at line 1411 of file rpl_gtid_set.cc.
int Gtid_set::get_string_length | ( | const String_format * | string_format = NULL | ) | const |
Returns the length of the output from to_string.
string_format | String_format object that specifies separators in the resulting text. |
Definition at line 874 of file rpl_gtid_set.cc.
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. |
Definition at line 1231 of file rpl_gtid_set.cc.
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.
Definition at line 1167 of file rpl_gtid_set.cc.
|
static |
Returns true if the given string is a valid specification of a Gtid_set, false otherwise.
Definition at line 556 of file rpl_gtid_set.cc.
enum_return_status Gtid_set::remove_gtid_set | ( | const Gtid_set * | other | ) |
Removes all groups in the given Gtid_set from this Gtid_set.
other | The Gtid_set to remove. |
Definition at line 692 of file rpl_gtid_set.cc.
|
inline |
Return a newly allocated string containing this Gtid_set, or NULL on out of memory.
Definition at line 1065 of file rpl_gtid.h.
int Gtid_set::to_string | ( | char * | buf, |
const String_format * | string_format = NULL |
||
) | 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. |
string_format | String_format object that specifies separators in the resulting text. |
Definition at line 769 of file rpl_gtid_set.cc.
int Gtid_set::to_string | ( | char ** | buf, |
const String_format * | string_format = NULL |
||
) | 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. |
string_format | Specifies how to format the string. |
Length | of the generated string, or -1 on out of memory. |
Definition at line 758 of file rpl_gtid_set.cc.
|
friend |
Used by unit tests that need to access private members.
Only Free_intervals_lock is allowed to access free_intervals_mutex.
Definition at line 1674 of file rpl_gtid.h.
|
static |
String_format for printing the Gtid_set commented: the string is not quote-wrapped, and every SID is on a new line with a leading '# '.
Definition at line 1168 of file rpl_gtid.h.
|
static |
The default String_format: the format understood by add_gtid_text(const char *).
Definition at line 1158 of file rpl_gtid.h.
|
static |
String_format useful to generate an SQL string: the string is wrapped in single quotes and there is a newline between SIDs.
Definition at line 1163 of file rpl_gtid.h.