[Rt-commit] rt branch, 4.6/mysql-utf8mb4, repushed
Michel Rodriguez
michel at bestpractical.com
Mon Jan 27 10:00:24 EST 2020
The branch 4.6/mysql-utf8mb4 was deleted and repushed:
was 8cca778fee787fbcfa884822c6aff5e48fae7dcd
now 72a5c50f916cc75b19c6fbe384c3f7931d8b74a1
1: 09feb791d0 ! 1: b429057a78 Support for utf8mb4 in mysql.
@@ -7,6 +7,28 @@
It requires the database to be converted to utf8mb4 to
support those characters.
+
+ MySQL version should be >= 5.7.7
+ MariaDB version should be >= 10.2.5
+
+ https://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-7.html#mysqld-5-7-7-feature
+ https://mariadb.com/kb/en/changes-improvements-in-mariadb-102/
+ https://mariadb.com/kb/en/mariadb-1025-changelog/ (search for utf8)
+
+ Before this version utf8mb4 tables could not have indexes with type VARCHAR(255):
+ the default size for index entries was 767 bytes, which is enough for 255 chars
+ stored as at most 3 chars (the utf8 format), but not as 4 bytes (utf8mb4).
+ 5.7.7 sets the default index size to 3072, so all of RT indexes are now OK.
+
+ Detection of MariaDB is done on the version string (it must match "mariadb"),
+ which is the case in both Debian and RedHat based distributions, and likely
+ everywhere else.
+
+ To check that fields are set to utf8mb4 we check one column (Tickets.Subject)
+ for practical reasons.
+ Simplify checks on max_allowed_packet since MySQL version is now higher.
+
+ No need to check version > 5.6.20 or 5.6.22 anymore, min version is 5.7.7.
diff --git a/README b/README
--- a/README
@@ -291,18 +313,14 @@
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@
+ );
if ( $db_type eq 'mysql' ) {
- my $version = $self->DatabaseVersion;
+- my $version = $self->DatabaseVersion;
- ($version) = $version =~ /^(\d+\.\d+)/;
- $self->dbh->do("SET NAMES 'utf8'") if $version >= 4.1;
-+
-+ if( cmp_version( $version, '5.5.3') > 0 ) {
-+ $self->dbh->do("SET NAMES 'utf8mb4'");
-+ }
-+ elsif( cmp_version( $version, '4.1') >= 0 ) {
-+ $self->dbh->do("SET NAMES 'utf8'");
-+ }
++ # set the character set
++ $self->dbh->do("SET NAMES 'utf8mb4'");
}
elsif ( $db_type eq 'Pg' ) {
my $version = $self->DatabaseVersion;
@@ -321,18 +339,65 @@
- ($version) = $version =~ /^(\d+\.\d+)/;
- return (0, "RT is unsupported on MySQL versions before 4.1. Your version is $version.")
- if $version < 4.1;
-+ my $min_version = '5.6';
-+ return (0, "RT is unsupported on MySQL versions before $min_version. Your version is $version.")
-+ if cmp_version( $version, $min_version) < 0;
++ # MySQL and MariaDB are both 'mysql' type.
++ # the minimum version supported is MySQL 5.7.7 / MariaDB 10.2.2
++ # the version string for MariaDB includes "MariaDB" in Debian/RedHat
++ my $is_mariadb = $version =~ m{mariadb}i ? 0 : 1;
++ my $mysql_min_version = '5.7.7'; # so index sizes allow for VARCHAR(255) fields
++ my $mariadb_min_version = '10.2.5'; # uses innodb by default
++
++ return ( 0, "RT is unsupported on MySQL versions before $mysql_min_version. Your version is $version.")
++ if !$is_mariadb && cmp_version( $version, $mysql_min_version ) < 0;
++ return ( 0, "RT is unsupported on MariaDB versions before $mariadb_min_version. Your version is $version.")
++ if $is_mariadb && cmp_version( $version, $mariadb_min_version ) < 0;
# MySQL must have InnoDB support
local $dbh->{FetchHashKeyName} = 'NAME_lc';
@@
- }
+ warn "max_allowed_packet is set to $max_packet, which limits the maximum attachment or email size that RT can process. Consider adjusting MySQL's max_allowed_packet setting.\n";
+ }
+
+- my $full_version = $show_var->("version");
+- if ($full_version =~ /^5\.(\d+)\.(\d+)$/ and (($1 == 6 and $2 >= 20) or $1 > 6)) {
+- my $redo_log_size = $show_var->("innodb_log_file_size");
+- $redo_log_size *= $show_var->("innodb_log_files_in_group")
+- if $full_version =~ /^5\.(\d+)\.(\d+)$/ and (($1 == 6 and $2 >= 22) or $1 > 6);
++ my $redo_log_size = $show_var->("innodb_log_file_size");
++ $redo_log_size *= $show_var->("innodb_log_files_in_group");
++ if ( $redo_log_size / 10 < 5 * 1024 * 1024 ) {
++ $redo_log_size = sprintf("%.1fM",$redo_log_size/1024/1024);
++ warn "innodb_log_file_size is set to $redo_log_size; attachments can only be 10% of this value on MySQL 5.6. Consider adjusting MySQL's innodb_log_file_size setting.\n";
++ }
++ }
+
+- if ($redo_log_size / 10 < 5 * 1024 * 1024) {
+- $redo_log_size = sprintf("%.1fM",$redo_log_size/1024/1024);
+- warn "innodb_log_file_size is set to $redo_log_size; attachments can only be 10% of this value on MySQL 5.6. Consider adjusting MySQL's innodb_log_file_size setting.\n";
+- }
++ # check that the DB encoding is utf8mb4
++ # we check one specific column (Tickets.Subject):
++ # - checking the DB default may be misleading (what's relevant is whether RT tables have the proper charset)
++ # - checking all columns would be expensive
++ my $allowed_charset = 'utf8mb4';
++ my $column_info = $dbh->selectrow_hashref( "show full columns from Tickets where Field = 'Subject'" );
++ if( $column_info ) {
++ # $column_info is only defined if the table exists, skip the check it it doesn't (during make initdb)
++ # we get the charset from the collation on the field
++ my $collation = $column_info->{collation};
++ my $collation_info = $dbh->selectrow_hashref( "SHOW COLLATION WHERE Collation = ?", {}, $collation );
++ my $charset = $collation_info->{charset} || '';
++ if( $charset ne $allowed_charset ) {
++ warn "table encoding set to $charset, it should be $allowed_charset\n";
}
}
-- }
- return (1)
- }
-
+ }
+@@
+ delete $item->{'BasedOn'};
+ }
+
+- }
++ }
+
+ my ( $return, $msg ) = $new_entry->Create(%$item);
+ unless( $return ) {
2: 7e61acceae < -: ------- Check that the database charset is utf8mb4.
3: bc347b3f1d = 2: 206cc765ea Explain utf8mb4 character set options.
4: b0837b7ddc = 3: db07145553 Normalize character set/collation declaration for all tables.
5: 052c2b8d93 < -: ------- Test for 4-byte utf-8 character searches.
-: ------- > 4: 2ff0cfd4ac Test for 4-byte utf-8 character searches.
6: 984b3a7889 = 5: cee4a4d508 Change the full text indexer charset to utf8mb4.
7: 8bd009b4cf ! 6: 72a5c50f91 Alter all relevant tables to use the utf8mb4 charset.
@@ -38,4 +38,3 @@
+ ALTER TABLE `Catalogs` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
+ ALTER TABLE `CustomRoles` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
+ ALTER TABLE `ObjectCustomRoles` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-
8: ac4f8b2a03 < -: ------- Improve mysql/mariadb version checks.
9: 8cca778fee < -: ------- Simplify checks on max_allowed_packet since MySQL version is now higher.
More information about the rt-commit
mailing list