1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

A joint patch for MDEV-19284 and MDEV-19285 (INSTANT ALTER)

This patch fixes:

- MDEV-19284 INSTANT ALTER with ucs2-to-utf16 conversion produces bad data
- MDEV-19285 INSTANT ALTER from ascii_general_ci to latin1_general_ci produces corrupt data

These regressions were introduced in 10.4.3 by:
- MDEV-15564 Avoid table rebuild in ALTER TABLE on collation or charset changes

Changes:

1. Cleanup: Adding a helper method
   Field_longstr::csinfo_change_allows_instant_alter(),
   to remove some duplicate code in field.cc.

2. Cleanup: removing Type_handler::Charsets_are_compatible() and static
   function charsets_are_compatible() and
   introducing new methods in the recently added class Charset instead:
   - encoding_allows_reinterpret_as()
   - encoding_and_order_allow_reinterpret_as()

3. Bug fix: Removing the code that allowed instant conversion for
   ascii-to->8bit and ucs2-to->utf16.
   This actually fixes MDEV-19284 and MDEV-19285.

4. Bug fix: Adding a helper method Charset::collation_specific_name().
   The old corresponding code in Type_handler::Charsets_are_compatible()
   was not safe against (badly named) user-defined collations whose
   character set name can be longer than collation name.
This commit is contained in:
Alexander Barkov
2019-04-19 15:18:38 +04:00
parent 9aa80fcf46
commit c59d6395a6
8 changed files with 925 additions and 847 deletions

View File

@@ -1,10 +1,10 @@
--- instant_alter_charset.result
+++ instant_alter_charset,redundant.result
@@ -254,7 +254,6 @@
--- instant_alter_charset.result 2019-04-23 17:42:23.324326518 +0400
+++ instant_alter_charset,redundant.result 2019-04-23 17:42:46.047531591 +0400
@@ -279,7 +279,6 @@
alter table boundary_255
modify b varchar(200) charset utf8mb3,
modify a varchar(70) charset utf8mb4,
algorithm=instant;
-ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: Cannot change column type. Try ALGORITHM=COPY
alter table boundary_255
modify c varchar(300) charset utf8mb3,
algorithm=instant;
drop table boundary_255;
create table fully_compatible (
id int auto_increment unique key,