BUG 13596: Prevent utf8mb4 -> utf8 convertion

utf8mb4 is a superset of utf8 and thus is compatible.  We should not
force an entire db change upon people who have proactively set utf8mb4
encoding before now.

This patch also removed the deprecated use of ->tables stanza in favour
of the table_info stanza.

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
This commit is contained in:
Martin Renvoize 2015-01-19 13:48:42 +00:00 committed by Tomas Cohen Arazi
parent 8804598f3d
commit a303cdec48
1 changed files with 10 additions and 4 deletions

View File

@ -9658,10 +9658,16 @@ if(CheckVersion($DBversion)) {
$DBversion = "3.19.00.006";
if ( CheckVersion($DBversion) ) {
$dbh->do(q|SET foreign_key_checks = 0|);;
my @tables = $dbh->tables();
for my $table ( @tables ) {
$dbh->do(qq|ALTER TABLE $table CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci|);
$dbh->do(q|SET foreign_key_checks = 0|);
my $sth = $dbh->table_info( '','','','TABLE' );
my ( $cat, $schema, $name, $type, $remarks );
while ( ( $cat, $schema, $name, $type, $remarks ) = $sth->fetchrow_array ) {
my $table_sth = $dbh->prepare(qq|SHOW CREATE TABLE $name|);
$table_sth->execute;
my @table = $table_sth->fetchrow_array;
unless ( $table[1] =~ /COLLATE=utf8mb4_unicode_ci/ ) { #catches utf8mb4 collated tables
$dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci|);
}
}
$dbh->do(q|SET foreign_key_checks = 1|);;