84e55ff904
addresses #290 Note: there is currently no issue backfilling the ghost table when the characterset changes, likely because it's a insert-into-select-from and it all occurs within mysql. However, when applying DML events (UPDATE, DELETE, etc) the values are sprintf'd into a prepared statement and due to the possibility of migrating text column data containing invalid characters in the destination charset, a conversion step is often necessary. For example, when migrating a table/column from latin1 to utf8mb4, the latin1 column may contain characters that are invalid single-byte utf8 characters. Characters in the \x80-\xFF range are most common. When written to utf8mb4 column without conversion, they fail as they do not exist in the utf8 codepage. Converting these texts/characters to the destination charset using convert(? using {charset}) will convert appropriately and the update/replace will succeed. I only point out the "Note:" above because there are two tests added for this: latin1text-to-utf8mb4 and latin1text-to-ut8mb4-insert The former is a test that fails prior to this commit. The latter is a test that succeeds prior to this comment. Both are affected by the code in this commit. convert text to original charset, then destination converting text first to the original charset and then to the destination charset produces the most consistent results, as inserting the binary into a utf8-charset column may encounter an error if there is no prior context of latin1 encoding. mysql> select hex(convert(char(189) using utf8mb4)); +---------------------------------------+ | hex(convert(char(189) using utf8mb4)) | +---------------------------------------+ | | +---------------------------------------+ 1 row in set, 1 warning (0.00 sec) mysql> select hex(convert(convert(char(189) using latin1) using utf8mb4)); +-------------------------------------------------------------+ | hex(convert(convert(char(189) using latin1) using utf8mb4)) | +-------------------------------------------------------------+ | C2BD | +-------------------------------------------------------------+ 1 row in set (0.00 sec) as seen in this failure on 5.5.62 Error 1300: Invalid utf8mb4 character string: 'BD'; query= replace /* gh-ost `test`.`_gh_ost_test_gho` */ into `test`.`_gh_ost_test_gho` (`id`, `t`) values (?, convert(? using utf8mb4)) |
||
---|---|---|
.. | ||
alter-charset | ||
alter-charset-all-dml | ||
autoinc-copy-deletes | ||
autoinc-copy-deletes-user-defined | ||
autoinc-copy-simple | ||
autoinc-zero-value | ||
bigint-change-nullable | ||
bit-add | ||
bit-dml | ||
convert-utf8mb4 | ||
datetime | ||
datetime-1970 | ||
datetime-submillis | ||
datetime-submillis-zeroleading | ||
datetime-to-timestamp | ||
datetime-to-timestamp-pk-fail | ||
decimal | ||
discard-fk | ||
drop-null-add-not-null | ||
enum | ||
enum-pk | ||
enum-to-varchar | ||
fail-drop-pk | ||
fail-fk | ||
fail-fk-parent | ||
fail-float-unique-key | ||
fail-no-shared-uk | ||
fail-no-unique-key | ||
fail-password-length | ||
fail-rename-table | ||
fail-update-pk-column | ||
gbk-charset | ||
generated-columns57 | ||
generated-columns57-unique | ||
generated-columns-add57 | ||
generated-columns-rename57 | ||
geometry57 | ||
json57 | ||
json57dml | ||
keyword-column | ||
latin1 | ||
latin1text | ||
latin1text-to-utf8mb4 | ||
mixed-charset | ||
modify-change-case | ||
modify-change-case-pk | ||
rename | ||
rename-inserts-only | ||
rename-none-column | ||
rename-none-comment | ||
rename-reorder-column | ||
rename-reorder-columns | ||
reorder-columns | ||
spatial57 | ||
swap-pk-uk | ||
swap-uk | ||
swap-uk-uk | ||
timestamp | ||
timestamp-datetime | ||
timestamp-to-datetime | ||
trivial | ||
tz | ||
tz-datetime | ||
tz-datetime-ts | ||
unsigned | ||
unsigned-modify | ||
unsigned-rename | ||
unsigned-reorder | ||
utf8 | ||
utf8mb4 | ||
varbinary | ||
test.sh |