mirror of
https://github.com/MariaDB/server.git
synced 2025-07-24 19:42:23 +03:00
WL#5151: Conversion between different types when replicating
Row-based replication requires the types of columns on the master and slave to be approximately the same (some safe conversions between strings are allowed), but does not allow safe conversions between fields of similar types such as TINYINT and INT. This patch implement type conversions between similar fields on the master and slave. The conversions are controlled using a new variable SLAVE_TYPE_CONVERSIONS of type SET('ALL_LOSSY','ALL_NON_LOSSY'). Non-lossy conversions are any conversions that do not run the risk of losing any information, while lossy conversions can potentially truncate the value. The column definitions are checked to decide if the conversion is acceptable. If neither conversion is enabled, it is required that the definitions of the columns are identical on master and slave. Conversion is done by creating an internal conversion table, unpacking the master data into it, and then copy the data to the real table on the slave.
This commit is contained in:
@ -314,13 +314,21 @@ public:
|
||||
uint tables_to_lock_count; /* RBR: Count of tables to lock */
|
||||
table_mapping m_table_map; /* RBR: Mapping table-id to table */
|
||||
|
||||
inline table_def *get_tabledef(TABLE *tbl)
|
||||
bool get_table_data(TABLE *table_arg, table_def **tabledef_var, TABLE **conv_table_var) const
|
||||
{
|
||||
table_def *td= 0;
|
||||
for (TABLE_LIST *ptr= tables_to_lock; ptr && !td; ptr= ptr->next_global)
|
||||
if (ptr->table == tbl)
|
||||
td= &((RPL_TABLE_LIST *)ptr)->m_tabledef;
|
||||
return (td);
|
||||
DBUG_ASSERT(tabledef_var && conv_table_var);
|
||||
for (TABLE_LIST *ptr= tables_to_lock ; ptr != NULL ; ptr= ptr->next_global)
|
||||
if (ptr->table == table_arg)
|
||||
{
|
||||
*tabledef_var= &static_cast<RPL_TABLE_LIST*>(ptr)->m_tabledef;
|
||||
*conv_table_var= static_cast<RPL_TABLE_LIST*>(ptr)->m_conv_table;
|
||||
DBUG_PRINT("debug", ("Fetching table data for table %s.%s:"
|
||||
" tabledef: %p, conv_table: %p",
|
||||
table_arg->s->db.str, table_arg->s->table_name.str,
|
||||
*tabledef_var, *conv_table_var));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user