Skip to content

Commit

Permalink
Fix MySQL 8 warning related to utf8 charset
Browse files Browse the repository at this point in the history
Warning 3719: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778: 'utf8mb3_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
  • Loading branch information
pali committed Oct 12, 2023
1 parent 5abbd2a commit 13425d2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
10 changes: 6 additions & 4 deletions t/55utf8.t
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ $dbh= DBI->connect("$test_dsn;mariadb_server_prepare=$mariadb_server_prepare;mar

ok $dbh->do("DROP TABLE IF EXISTS dbd_mysql_t55utf8");

my $charset = $dbh->selectrow_array("SHOW CHARSET LIKE 'utf8mb4'") ? 'utf8mb4' : 'utf8';

my $create =<<EOT;
CREATE TABLE dbd_mysql_t55utf8 (
name VARCHAR(64) CHARACTER SET utf8,
name VARCHAR(64) CHARACTER SET $charset,
bincol BLOB,
shape GEOMETRY,
binutf VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_bin,
profile TEXT CHARACTER SET utf8,
str2 VARCHAR(64) CHARACTER SET utf8,
binutf VARCHAR(64) CHARACTER SET $charset COLLATE ${charset}_bin,
profile TEXT CHARACTER SET $charset,
str2 VARCHAR(64) CHARACTER SET $charset,
ascii VARCHAR(64) CHARACTER SET latin1,
latin VARCHAR(64) CHARACTER SET latin1
)
Expand Down
4 changes: 3 additions & 1 deletion t/55utf8_jp.t
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ my $jpnErr = qr/\x{4ed8}\x{8fd1}.*\x{884c}\x{76ee}/; # Use \x{...} instead \N{U+
my $sth;
my $row;

my $charset = $dbh->selectrow_array("SHOW CHARSET LIKE 'utf8mb4'") ? 'utf8mb4' : 'utf8';

ok($dbh->do("
CREATE TEMPORARY TABLE $jpnTable (
name VARCHAR(20),
$jpnGender CHAR(1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
) ENGINE=InnoDB DEFAULT CHARSET=$charset COLLATE=${charset}_bin
"));

ok($sth = $dbh->prepare("INSERT INTO $jpnTable (name, $jpnGender) VALUES (?, ?)"));
Expand Down
6 changes: 5 additions & 1 deletion t/90utf8_params.t
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,18 @@ is($nasty_bytes1, $nasty_bytes2, "Perl's internal form does not matter");
is($nasty_unicode1, $nasty_bytes1, "Perl does not distinguish between bytes and Unicode string");
is($nasty_unicode2, $nasty_bytes2, "Perl does not distinguish between bytes and Unicode string");

my @charsets;
push @charsets, 'latin1';
push @charsets, ($dbh->selectrow_array("SHOW CHARSET LIKE 'utf8mb4'") ? 'utf8mb4' : 'utf8');

foreach my $server_prepare (0, 1) {

my $enable_str = "mariadb_server_prepare=$server_prepare";
my $enable_hash = { RaiseError => 1, PrintError => 0, mariadb_server_prepare => $server_prepare, mariadb_server_prepare_disable_fallback => 1 };

$dbh = DBI->connect($test_dsn, $test_user, $test_password, $enable_hash);

foreach my $charset ("latin1", "utf8") {
foreach my $charset (@charsets) {

$dbh->do(qq{
CREATE TEMPORARY TABLE unicode_test (
Expand Down
6 changes: 5 additions & 1 deletion t/rt25389-bin-case.t
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ plan tests => 8;
my ( $sth, $i );
my @test = qw(AA Aa aa aA);

for my $charset (qw(latin1 utf8)) {
my @charsets;
push @charsets, 'latin1';
push @charsets, ($dbh->selectrow_array("SHOW CHARSET LIKE 'utf8mb4'") ? 'utf8mb4' : 'utf8');

for my $charset (@charsets) {
for my $unique ( "", "unique" ) {

my $table = "dbd-mysql-$charset-$unique";
Expand Down

0 comments on commit 13425d2

Please sign in to comment.