My Project
|
#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 | _remove_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_subset_for_sid (const Gtid_set *super, rpl_sidno superset_sidno, rpl_sidno subset_sidno) const |
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.
Gtid_set::Gtid_set | ( | Sid_map * | sid_map, |
Checkable_rwlock * | sid_lock = NULL |
||
) |
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.
enum_return_status Gtid_set::_add_gtid | ( | rpl_sidno | sidno, |
rpl_gno | gno | ||
) | [inline] |
enum_return_status Gtid_set::_add_gtid | ( | const Gtid & | gtid | ) | [inline] |
enum_return_status Gtid_set::_remove_gtid | ( | rpl_sidno | sidno, |
rpl_gno | gno | ||
) | [inline] |
Removes the given GTID from this Gtid_set.
sidno | SIDNO of the group to remove. |
gno | GNO of the group to remove. |
enum_return_status Gtid_set::_remove_gtid | ( | const Gtid & | gtid | ) | [inline] |
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'. |
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. |
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. |
void Gtid_set::add_interval_memory | ( | int | n_intervals, |
Interval * | intervals_param | ||
) | [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. |
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.
bool Gtid_set::contains_sidno | ( | rpl_sidno | sidno | ) | const [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. |
void Gtid_set::dbug_print | ( | const char * | text = "" | ) | const [inline] |
Print this Gtid_set to the trace file if debug is enabled; no-op otherwise.
void Gtid_set::encode | ( | uchar * | buf | ) | const |
Encodes this Gtid_set as a binary string.
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. |
size_t Gtid_set::get_encoded_length | ( | ) | const |
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. |
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. |
bool Gtid_set::is_intersection_nonempty | ( | const Gtid_set * | other | ) | const |
bool Gtid_set::is_subset_for_sid | ( | 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->sid_map. |
subset_sidno | The sidno that will be compared, relative to this->sid_map. |
bool Gtid_set::is_valid | ( | const char * | text | ) | [static] |
Returns true if the given string is a valid specification of a Gtid_set, false otherwise.
enum_return_status Gtid_set::remove_gtid_set | ( | const Gtid_set * | other | ) |
char* Gtid_set::to_string | ( | ) | const [inline] |
Return a newly allocated string containing this Gtid_set, or NULL on out of memory.
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. |
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. |
friend class Gtid_set::Free_intervals_lock [friend] |
Used by unit tests that need to access private members.
Only Free_intervals_lock is allowed to access free_intervals_mutex.
const Gtid_set::String_format Gtid_set::commented_string_format [static] |
{ "# ", "", ":", "-", ":", ",\n# ", "# [empty]", 2, 0, 1, 1, 1, 4, 9 }
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 '# '.
const Gtid_set::String_format Gtid_set::default_string_format [static] |
{ "", "", ":", "-", ":", ",\n", "", 0, 0, 1, 1, 1, 2, 0 }
The default String_format: the format understood by add_gtid_text(const char *).
const Gtid_set::String_format Gtid_set::sql_string_format [static] |
{ "'", "'", ":", "-", ":", "',\n'", "''", 1, 1, 1, 1, 1, 4, 2 }
String_format useful to generate an SQL string: the string is wrapped in single quotes and there is a newline between SIDs.