mariadb/sql
Mats Kindahl 571843804c 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.

.bzrignore:
  New files added
client/Makefile.am:
  New files added
client/mysqlbinlog.cc:
  Functions in rpl_utility.cc is now needed by mysqlbinlog.cc.
libmysqld/Makefile.am:
  New files added
mysql-test/extra/rpl_tests/check_type.inc:
  Test include file to check a single type conversion.
mysql-test/extra/rpl_tests/rpl_extraSlave_Col.test:
  Switching to use INT instead of TEXT for column that should not have matching types.
mysql-test/extra/rpl_tests/rpl_row_basic.test:
  Adding code to enable type conversions for BIT tests since InnoDB
  cannot handle them properly due to incorrect information stored as
  metadata.
mysql-test/extra/rpl_tests/type_conversions.test:
  Test file to check a set of type conversions
  with current settings of slave_type_conversions.
mysql-test/suite/rpl/t/rpl_typeconv.test:
  Test file to test conversions from master to slave with
  all possible values for slave_type_conversions.
  
  The test also checks that the slave_type_conversions
  variable works as expected.
sql/field.cc:
  Changing definition of compatible_field_size to both check if 
  two field with identical base types are compatible and give an
  order between them if they are compatible.
  
  This only implement checking on the slave, so it will not affect
  replication from an old master to a new slave.
sql/field.h:
  Changing prototypes for functions:
  - compatible_field_size()
  - init_for_tmp_table()
  - row_pack_length()
sql/log_event.cc:
  Changing compability checks to build a conversion table if the fields
  are compatible, but does not have the same base type.
sql/log_event_old.cc:
  Changing compability checks to build a conversion table if the fields
  are compatible, but does not have the same base type.
sql/mysql_priv.h:
  Adding global option variable for SLAVE_TYPE_CONVERSIONS
sql/mysqld.cc:
  Adding SLAVE_TYPE_CONVERSIONS global server variable.
sql/rpl_record.cc:
  Changing unpack_row to use the conversion table if present.
sql/rpl_rli.h:
  Removing function get_tabledef and replacing it with get_table_data().
  This function retrieve data for table opened for replication, not just
  table definition.
sql/rpl_utility.cc:
  Function table_def::compatible_with is changed to compare table on master
  and slave for compatibility and generate a conversions table if they are
  compatible.
  
  Computing real type of fields from metadata for ENUM and SET types.
  Computing pack_length correctly for ENUM, SET, and BLOB types.
  
  Adding optimization to not check compatibility if no
  slave type conversions are enabled.
sql/rpl_utility.h:
  Changing prototypes since implementation has changed.
  
  Modifying table_def::type() to return real type instead of stored type.
sql/set_var.cc:
  Adding SLAVE_TYPE_CONVERSIONS variable.
sql/set_var.h:
  Adding SLAVE_TYPE_CONVERSIONS variable.
sql/share/errmsg.txt:
  Adding error messages for slave type conversions.
sql/sql_class.h:
  Adding SLAVE_TYPE_CONVERSIONS variable.
sql/sql_select.cc:
  Correcting create_virtual_tmp_table() to compute null bit positions
  correctly in the presence of bit fields.
2009-12-14 12:04:55 +01:00
..
examples
share WL#5151: Conversion between different types when replicating 2009-12-14 12:04:55 +01:00
.cvsignore
add_errmsg
authors.h
client_settings.h
CMakeLists.txt
contributors.h
custom_conf.h
debug_sync.cc Fixed a valgrind error in debug_sync 2009-10-04 12:53:02 +03:00
debug_sync.h
derror.cc
des_key_file.cc
discover.cc
event_data_objects.cc
event_data_objects.h
event_db_repository.cc
event_db_repository.h
event_parse_data.cc
event_parse_data.h
event_queue.cc
event_queue.h
event_scheduler.cc
event_scheduler.h
events.cc
events.h
field.cc WL#5151: Conversion between different types when replicating 2009-12-14 12:04:55 +01:00
field.h WL#5151: Conversion between different types when replicating 2009-12-14 12:04:55 +01:00
field_conv.cc
filesort.cc
frm_crypt.cc
gen_lex_hash.cc
gstream.cc
gstream.h
ha_ndbcluster.cc
ha_ndbcluster.h
ha_ndbcluster_binlog.cc
ha_ndbcluster_binlog.h
ha_ndbcluster_cond.cc
ha_ndbcluster_cond.h
ha_ndbcluster_tables.h
ha_partition.cc merge into mysql-5.1-bugteam 2009-10-09 09:56:07 +02:00
ha_partition.h
handler.cc
handler.h
hash_filo.cc
hash_filo.h
hostname.cc
init.cc
item.cc
item.h
item_buff.cc
item_cmpfunc.cc Bug #44139: Table scan when NULL appears in IN clause 2009-10-05 10:27:36 +05:00
item_cmpfunc.h
item_create.cc
item_create.h
item_func.cc
item_func.h
item_geofunc.cc
item_geofunc.h
item_row.cc
item_row.h
item_strfunc.cc
item_strfunc.h
item_subselect.cc
item_subselect.h
item_sum.cc
item_sum.h
item_timefunc.cc
item_timefunc.h
item_xmlfunc.cc
item_xmlfunc.h
key.cc
lex.h
lex_symbol.h
lock.cc
log.cc BUG#47678 Changes to n-tables that happen early in a trans. are only flushed upon commit 2009-10-06 01:54:00 +01:00
log.h
log_event.cc WL#5151: Conversion between different types when replicating 2009-12-14 12:04:55 +01:00
log_event.h
log_event_old.cc WL#5151: Conversion between different types when replicating 2009-12-14 12:04:55 +01:00
log_event_old.h
Makefile.am
message.h
message.mc
message.rc
mf_iocache.cc
MSG00001.bin
my_decimal.cc
my_decimal.h
my_lock.c
mysql_priv.h WL#5151: Conversion between different types when replicating 2009-12-14 12:04:55 +01:00
mysql_priv.h.pp Bug#47857 strip_sp function in mysys/mf_strip.c never used and cause name clash 2009-10-06 13:04:51 +02:00
mysqld.cc WL#5151: Conversion between different types when replicating 2009-12-14 12:04:55 +01:00
mysqld_suffix.h
net_serv.cc
nt_servc.cc
nt_servc.h
opt_range.cc Revert the fix for bug #47123 until test suite failures are resolved. 2009-10-16 11:42:16 +03:00
opt_range.h
opt_sum.cc Bug#47280 - strange results from count(*) with order by multiple 2009-10-14 10:46:50 +02:00
parse_file.cc
parse_file.h
partition_element.h
partition_info.cc
partition_info.h
password.c
procedure.cc
procedure.h
protocol.cc
protocol.h
records.cc
repl_failsafe.cc
repl_failsafe.h
rpl_constants.h
rpl_filter.cc
rpl_filter.h
rpl_injector.cc
rpl_injector.h
rpl_mi.cc
rpl_mi.h
rpl_record.cc WL#5151: Conversion between different types when replicating 2009-12-14 12:04:55 +01:00
rpl_record.h
rpl_record_old.cc
rpl_record_old.h
rpl_reporting.cc
rpl_reporting.h
rpl_rli.cc
rpl_rli.h WL#5151: Conversion between different types when replicating 2009-12-14 12:04:55 +01:00
rpl_tblmap.cc
rpl_tblmap.h
rpl_utility.cc WL#5151: Conversion between different types when replicating 2009-12-14 12:04:55 +01:00
rpl_utility.h WL#5151: Conversion between different types when replicating 2009-12-14 12:04:55 +01:00
scheduler.cc
scheduler.h
set_var.cc WL#5151: Conversion between different types when replicating 2009-12-14 12:04:55 +01:00
set_var.h WL#5151: Conversion between different types when replicating 2009-12-14 12:04:55 +01:00
slave.cc Bug#46640: output from mysqlbinlog command in 5.1 breaks replication 2009-10-14 09:39:05 +08:00
slave.h Bug#46640: output from mysqlbinlog command in 5.1 breaks replication 2009-10-14 09:39:05 +08:00
sp.cc
sp.h
sp_cache.cc
sp_cache.h
sp_head.cc
sp_head.h
sp_pcontext.cc
sp_pcontext.h
sp_rcontext.cc
sp_rcontext.h
spatial.cc
spatial.h
sql_acl.cc
sql_acl.h
sql_analyse.cc
sql_analyse.h
sql_array.h
sql_base.cc Bug #43029: FORCE INDEX FOR ORDER BY is ignored when join 2009-10-07 18:03:42 +03:00
sql_binlog.cc Bug#46640: output from mysqlbinlog command in 5.1 breaks replication 2009-10-14 09:39:05 +08:00
sql_bitmap.h
sql_builtin.cc.in
sql_cache.cc
sql_cache.h
sql_class.cc
sql_class.h WL#5151: Conversion between different types when replicating 2009-12-14 12:04:55 +01:00
sql_client.cc
sql_connect.cc
sql_crypt.cc
sql_crypt.h
sql_cursor.cc
sql_cursor.h
sql_db.cc
sql_delete.cc
sql_derived.cc
sql_do.cc
sql_error.cc
sql_error.h
sql_handler.cc
sql_help.cc
sql_insert.cc
sql_lex.cc
sql_lex.h
sql_list.cc
sql_list.h
sql_load.cc
sql_locale.cc
sql_manager.cc
sql_map.cc
sql_map.h
sql_olap.cc
sql_parse.cc Bug #43029: FORCE INDEX FOR ORDER BY is ignored when join 2009-10-07 18:03:42 +03:00
sql_partition.cc
sql_partition.h
sql_plugin.cc
sql_plugin.h
sql_prepare.cc
sql_profile.cc
sql_profile.h
sql_rename.cc
sql_repl.cc
sql_repl.h
sql_select.cc WL#5151: Conversion between different types when replicating 2009-12-14 12:04:55 +01:00
sql_select.h Bug#47280 - strange results from count(*) with order by multiple 2009-10-14 10:46:50 +02:00
sql_servers.cc
sql_servers.h
sql_show.cc Merge of Bug#35996 2009-09-30 09:31:20 +02:00
sql_show.h
sql_sort.h
sql_state.c
sql_string.cc
sql_string.h
sql_table.cc
sql_tablespace.cc
sql_test.cc
sql_trigger.cc
sql_trigger.h
sql_udf.cc
sql_udf.h
sql_union.cc
sql_update.cc
sql_view.cc
sql_view.h
sql_yacc.yy Bug#34895 'show procedure status' or 'show function status' + 2009-09-30 14:50:25 +02:00
strfunc.cc
structs.h
table.cc Bug #43029: FORCE INDEX FOR ORDER BY is ignored when join 2009-10-07 18:03:42 +03:00
table.h Bug #43029: FORCE INDEX FOR ORDER BY is ignored when join 2009-10-07 18:03:42 +03:00
thr_malloc.cc
time.cc
tzfile.h
tztime.cc
tztime.h
udf_example.c
udf_example.def
uniques.cc
unireg.cc
unireg.h