Commit bd622b7
Mats Kindahl
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.
--BZR--
revision-id: [email protected]
property-branch-nick: conversion-table
property-file-info: ld7:file_id59:sp1f-ignore-20001018235455-q4gxfbritt5f42nwix354ufpsvrf5ebj7:message15:New files added4:path10:.bzrignoreed7:file_id64:sp1f-makefile.am-19700101030959-zpaig4zjwqhmsob3ypilmrcrkq7pu6gf7:message15:New files added4:path18:client/Makefile.amed7:file_id67:sp1f-mysqlbinlog.cc-19700101030959-b3vgyo47ljent5mhbyj6ik33bi4bukad7:message60:Functions in rpl_utility.cc is now needed by mysqlbinlog.cc.4:path21:client/mysqlbinlog.cced7:file_id64:sp1f-makefile.am-20010411110351-26htpk3ynkyh7pkfvnshztqrxx3few4g7:message15:New files added4:path21:libmysqld/Makefile.amed7:file_id48:check_type.inc-20091118114807-nmq0zl0cc8c0d45m-17:message53:Test include file to check a single type conversion.
property-file-info: 4:path41:mysql-test/extra/rpl_tests/check_type.inced7:file_id73:sp1f-rpl_extraslave_col.t-20061103140340-egmkull7owd2wp7d4egg6itzef6p7g237:message84:Switching to use INT instead of TEXT for column that should not have matching types.4:path50:mysql-test/extra/rpl_tests/rpl_extraSlave_Col.tested7:file_id70:sp1f-rpl_row_basic.inc-20051222053451-qbja3f3vz3mf5ikwca7eeqkxutnnzlbi7:message142:Adding code to enable type conversions for BIT tests since InnoDB
property-file-info: cannot handle them properly due to incorrect information stored as
property-file-info: metadata.4:path45:mysql-test/extra/rpl_tests/rpl_row_basic.tested7:file_id54:type_conversions.tes-20091118114807-nmq0zl0cc8c0d45m-27:message94:Test file to check a set of type conversions
property-file-info: with current settings of slave_type_conversions.
property-file-info: 4:path48:mysql-test/extra/rpl_tests/type_conversions.tested7:file_id51:rpl_typeconv.test-20091118114725-p4yrkiwge5c82p0p-17:message185:Test file to test conversions from master to slave with
property-file-info: all possible values for slave_type_conversions.
property-file-info:
property-file-info: The test also checks that the slave_type_conversions
property-file-info: variable works as expected.4:path40:mysql-test/suite/rpl/t/rpl_typeconv.tested7:file_id61:sp1f-field.cc-19700101030959-f4imaofclsea3n4fj4ow5m7havmyxa2r7:message282:Changing definition of compatible_field_size to both check if
property-file-info: two field with identical base types are compatible and give an
property-file-info: order between them if they are compatible.
property-file-info:
property-file-info: This only implement checking on the slave, so it will not affect
property-file-info: replication from an old master to a new slave.
property-file-info: 4:path12:sql/field.cced7:file_id60:sp1f-field.h-19700101030959-3n6smzxcwkjl7bikm3wg4hfkjn66uvvp7:message103:Changing prototypes for functions:
property-file-info: - compatible_field_size()
property-file-info: - init_for_tmp_table()
property-file-info: - row_pack_length()4:path11:sql/field.hed7:file_id65:sp1f-log_event.cc-19700101030959-msmqlflsngxosswid2hpzxly5vfqdddc7:message123:Changing compability checks to build a conversion table if the fields
property-file-info: are compatible, but does not have the same base type.4:path16:sql/log_event.cced7:file_id69:sp1f-log_event_old.cc-20070412135046-uu5xq4cnpwslzif6fbmj3g65x4vdkzxu7:message124:Changing compability checks to build a conversion table if the fields
property-file-info: are compatible, but does not have the same base type.
property-file-info: 4:path20:sql/log_event_old.cced7:file_id65:sp1f-mysql_priv.h-19700101030959-4fl65tqpop5zfgxaxkqotu2fa2ree5ci7:message56:Adding global option variable for SLAVE_TYPE_CONVERSIONS4:path16:sql/mysql_priv.hed7:file_id62:sp1f-mysqld.cc-19700101030959-zpswdvekpvixxzxf7gdtofzel7nywtfj7:message54:Adding SLAVE_TYPE_CONVERSIONS global server variable.
property-file-info: 4:path13:sql/mysqld.cced7:file_id66:sp1f-rpl_record.cc-20070413125523-wuthuk5jk7uxikuioz6esll6xakdngs47:message60:Changing unpack_row to use the conversion table if present.
property-file-info: 4:path17:sql/rpl_record.cced7:file_id62:sp1f-rpl_rli.h-20051222053448-bte4b72jikihtk3zbn5jyj2vbiawtwgc7:message159:Removing function get_tabledef and replacing it with get_table_data().
property-file-info: This function retrieve data for table opened for replication, not just
property-file-info: table definition.4:path13:sql/rpl_rli.hed7:file_id67:sp1f-rpl_utility.cc-20060503130029-owknu72jo3254qe7gjoeh7oilfrz4atk7:message380:Function table_def::compatible_with is changed to compare table on master
property-file-info: and slave for compatibility and generate a conversions table if they are
property-file-info: compatible.
property-file-info:
property-file-info: Computing real type of fields from metadata for ENUM and SET types.
property-file-info: Computing pack_length correctly for ENUM, SET, and BLOB types.
property-file-info:
property-file-info: Adding optimization to not check compatibility if no
property-file-info: slave type conversions are enabled.4:path18:sql/rpl_utility.cced7:file_id66:sp1f-rpl_utility.h-20060503130029-u44nzzcbdenh2gegnnyzro26kbk5quw77:message127:Changing prototypes since implementation has changed.
property-file-info:
property-file-info: Modifying table_def::type() to return real type instead of stored type.
property-file-info: 4:path17:sql/rpl_utility.hed7:file_id63:sp1f-set_var.cc-20020723153119-nwbpg2pwpz55pfw7yfzaxt7hsszzy7y37:message40:Adding SLAVE_TYPE_CONVERSIONS variable.
property-file-info: 4:path14:sql/set_var.cced7:file_id62:sp1f-set_var.h-20020723153119-2yomygq3s4xjbqvuue3cdlpbjtj3kwmk7:message39:Adding SLAVE_TYPE_CONVERSIONS variable.4:path13:sql/set_var.hed7:file_id63:sp1f-errmsg.txt-20041213212820-do5w642w224ja7ctyqhyl6iihdmpkzv57:message49:Adding error messages for slave type conversions.4:path20:sql/share/errmsg.txted7:file_id64:sp1f-sql_class.h-19700101030959-jnqnbrjyqsvgncsibnumsmg3lyi7pa5s7:message39:Adding SLAVE_TYPE_CONVERSIONS variable.4:path15:sql/sql_class.hed7:file_id66:sp1f-sql_select.cc-19700101030959-egb7whpkh76zzvikycs5nsnuviu4fdlb7:message109:Correcting create_virtual_tmp_table() to compute null bit positions
property-file-info: correctly in the presence of bit fields.
property-file-info: 4:path17:sql/sql_select.ccee
testament3-sha1: 249b4fd2c0c76bd8bfeef5b190f5c7a57bd134f61 parent 357e216 commit bd622b7
40 files changed
Lines changed: 2893 additions & 464 deletions
File tree
- client
- libmysqld
- mysql-test
- extra/rpl_tests
- suite/rpl
- r
- t
- sql
Binary file not shown.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
392 | 392 | | |
393 | 393 | | |
394 | 394 | | |
| 395 | + | |
395 | 396 | | |
396 | 397 | | |
397 | 398 | | |
| |||
1142 | 1143 | | |
1143 | 1144 | | |
1144 | 1145 | | |
| 1146 | + | |
1145 | 1147 | | |
1146 | 1148 | | |
1147 | 1149 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
| 107 | + | |
108 | 108 | | |
109 | 109 | | |
| 110 | + | |
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2108 | 2108 | | |
2109 | 2109 | | |
2110 | 2110 | | |
2111 | | - | |
| 2111 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
39 | 42 | | |
40 | 43 | | |
41 | 44 | | |
| |||
62 | 65 | | |
63 | 66 | | |
64 | 67 | | |
| 68 | + | |
| 69 | + | |
65 | 70 | | |
66 | 71 | | |
67 | 72 | | |
| |||
495 | 500 | | |
496 | 501 | | |
497 | 502 | | |
498 | | - | |
| 503 | + | |
499 | 504 | | |
500 | 505 | | |
501 | 506 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
156 | 157 | | |
157 | 158 | | |
158 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
159 | 166 | | |
160 | 167 | | |
161 | 168 | | |
| |||
164 | 171 | | |
165 | 172 | | |
166 | 173 | | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
167 | 178 | | |
168 | 179 | | |
169 | 180 | | |
| |||
350 | 361 | | |
351 | 362 | | |
352 | 363 | | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
353 | 368 | | |
354 | 369 | | |
355 | 370 | | |
| |||
370 | 385 | | |
371 | 386 | | |
372 | 387 | | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | 388 | | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
| 389 | + | |
| 390 | + | |
384 | 391 | | |
385 | 392 | | |
386 | 393 | | |
| |||
600 | 607 | | |
601 | 608 | | |
602 | 609 | | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
603 | 617 | | |
| 618 | + | |
604 | 619 | | |
605 | 620 | | |
606 | 621 | | |
| |||
645 | 660 | | |
646 | 661 | | |
647 | 662 | | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
648 | 667 | | |
649 | 668 | | |
650 | 669 | | |
| |||
0 commit comments