My Project
|
#include <rpl_utility.h>
Public Member Functions | |
table_def (unsigned char *types, ulong size, uchar *field_metadata, int metadata_size, uchar *null_bitmap, uint16 flags) | |
ulong | size () const |
enum_field_types | binlog_type (ulong index) const |
enum_field_types | type (ulong index) const |
uint16 | field_metadata (uint index) const |
my_bool | maybe_null (uint index) const |
uint32 | calc_field_size (uint col, uchar *master_data) const |
bool | compatible_with (THD *thd, Relay_log_info *rli, TABLE *table, TABLE **conv_table_var) const |
TABLE * | create_conversion_table (THD *thd, Relay_log_info *rli, TABLE *target_table) const |
A table definition from the master.
The responsibilities of this class is:
table_def::table_def | ( | unsigned char * | types, |
ulong | size, | ||
uchar * | field_metadata, | ||
int | metadata_size, | ||
uchar * | null_bitmap, | ||
uint16 | flags | ||
) |
Constructor.
types | Array of types, each stored as a byte |
size | Number of elements in array 'types' |
field_metadata | Array of extra information about fields |
metadata_size | Size of the field_metadata array |
null_bitmap | The bitmap of fields that can be null |
bool table_def::compatible_with | ( | THD * | thd, |
Relay_log_info * | rli, | ||
TABLE * | table, | ||
TABLE ** | conv_table_var | ||
) | const |
Decide if the table definition is compatible with a table.
Compare the definition with a table to see if it is compatible with it.
A table definition is compatible with a table if:
SLAVE_TYPE_CONVERSIONS
.thd | ||
rli | Pointer to relay log info | |
table | Pointer to table to compare with. | |
[out] | tmp_table_var | Pointer to temporary table for holding conversion table. |
1 | if the table definition is not compatible with table |
0 | if the table definition is compatible with table |
Is the definition compatible with a table?
This function will compare the master table with an existing table on the slave and see if they are compatible with respect to the current settings of SLAVE_TYPE_CONVERSIONS
.
If the tables are compatible and conversions are required, tmp_table_var
will be set to a virtual temporary table with field pointers for the fields that require conversions. This allow simple checking of whether a conversion are to be applied or not.
If tables are compatible, but no conversions are necessary, tmp_table_var
will be set to NULL.
rli_arg[in] | Relay log info, for error reporting. |
table[in] | Table to compare with |
tmp_table_var[out] | Virtual temporary table for performing conversions, if necessary. |
true | Master table is compatible with slave table. |
false | Master table is not compatible with slave table. |
TABLE * table_def::create_conversion_table | ( | THD * | thd, |
Relay_log_info * | rli, | ||
TABLE * | target_table | ||
) | const |
Create a virtual in-memory temporary table structure.
The table structure has records and field array so that a row can be unpacked into the record for further processing.
In the virtual table, each field that requires conversion will have a non-NULL value, while fields that do not require conversion will have a NULL value.
Some information that is missing in the events, such as the character set for string types, are taken from the table that the field is going to be pushed into, so the target table that the data eventually need to be pushed into need to be supplied.
thd | Thread to allocate memory from. |
rli | Relay log info structure, for error reporting. |
target_table | Target table for fields. |
Create a conversion table.
If the function is unable to create the conversion table, an error will be printed and NULL will be returned.
ulong table_def::size | ( | ) | const [inline] |
Return the number of fields there is type data for.