diff options
author | Mats Kindahl <mats@sun.com> | 2010-01-13 12:58:42 +0100 |
---|---|---|
committer | Mats Kindahl <mats@sun.com> | 2010-01-13 12:58:42 +0100 |
commit | a561e539434ec9b92f39b248329b1c5ac9d5ce94 (patch) | |
tree | 3adf0d589b26449e5aa7092eb6b5a99f199a7f1a /sql/rpl_utility.cc | |
parent | 060e3ae739e758920e24e3166f77e565c0329bee (diff) | |
download | mariadb-git-a561e539434ec9b92f39b248329b1c5ac9d5ce94.tar.gz |
WL#5151: Conversion between different types when
replicating
Replace c_ptr() calls with c_ptr_safe() calls to
avoid valgrind warnings.
Adding code to to handle the case that no metadata
was present in the table map for the column.
Allow first parameter to unpack_row() to be NULL,
in which case no source tables is used and hence
no checks nor conversions are done.
Clarifying some comments and fixing documentation
for unpack_row().
Diffstat (limited to 'sql/rpl_utility.cc')
-rw-r--r-- | sql/rpl_utility.cc | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc index 3a69c71b34c..c1d6ae03679 100644 --- a/sql/rpl_utility.cc +++ b/sql/rpl_utility.cc @@ -582,7 +582,7 @@ can_convert_field_to(Field *field, String field_type(field_type_buf, sizeof(field_type_buf), field->charset()); field->sql_type(field_type); DBUG_PRINT("enter", ("field_type: %s, target_type: %d, source_type: %d, source_metadata: 0x%x", - field_type.c_ptr(), field->real_type(), source_type, metadata)); + field_type.c_ptr_safe(), field->real_type(), source_type, metadata)); #endif /* If the real type is the same, we need to check the metadata to @@ -590,6 +590,19 @@ can_convert_field_to(Field *field, */ if (field->real_type() == source_type) { + if (metadata == 0) // Metadata can only be zero if no metadata was provided + { + /* + If there is no metadata, we either have an old event where no + metadata were supplied, or a type that does not require any + metadata. In either case, conversion can be done but no + conversion table is necessary. + */ + DBUG_PRINT("debug", ("Base types are identical, but there is no metadata")); + *order_var= 0; + DBUG_RETURN(true); + } + DBUG_PRINT("debug", ("Base types are identical, doing field size comparison")); if (field->compatible_field_size(metadata, rli, mflags, order_var)) DBUG_RETURN(is_conversion_ok(*order_var, rli)); @@ -816,7 +829,7 @@ table_def::compatible_with(THD *thd, Relay_log_info *rli, rli->report(ERROR_LEVEL, ER_SLAVE_CONVERSION_FAILED, ER(ER_SLAVE_CONVERSION_FAILED), col, db_name, tbl_name, - source_type.c_ptr(), target_type.c_ptr()); + source_type.c_ptr_safe(), target_type.c_ptr_safe()); return false; } } @@ -836,7 +849,7 @@ table_def::compatible_with(THD *thd, Relay_log_info *rli, DBUG_PRINT("debug", ("Field %s - conversion required." " Source type: '%s', Target type: '%s'", tmp_table->field[col]->field_name, - source_type.c_ptr(), target_type.c_ptr())); + source_type.c_ptr_safe(), target_type.c_ptr_safe())); } } #endif @@ -920,7 +933,7 @@ TABLE *table_def::create_conversion_table(THD *thd, Relay_log_info *rli, TABLE * field_def->init_for_tmp_table(type(col), max_length, decimals, - maybe_null(col), // maybe_null + TRUE, // maybe_null FALSE, // unsigned_flag pack_length); field_def->charset= target_table->field[col]->charset(); |