Skip to content

Commit d17dff9

Browse files
committed
Switch from DBD::mysql to DBD::MariaDB
DBD::mysql 5 recently dropped support for building from MySQL client libraries prior to v8. This creates challenges for people still using earlier versions, as well as those using MariaDB. DBD::MariaDB forked from DBD::mysql back in 2018, and maintains compatibility with both MySQL and MariaDB. It remains compatible with earlier versions of MySQL as well as the MariaDB client libraries. It also includes bug fixes and more transparent support for Unicode encoding. So switch from DBD::mysql to DBD::MariaDB. It's largely a drop-in replacement, with just a few additional changes: * Add `_dsn()` to DBIEngine and always use it to connect to the database. Override it in mysql.pm to replace `dbi:mysql` with `dbi:MariaDB`. Also override it in some other drivers that mangle the value returned by URI::db. * Remove incompatible config parameters `mysql_enable_utf8` (no longer needed due to the aforementioned Unicode bug fixes), `mysql_auto_reconnect`, and `mysql_use_result`. * Read DBI handle attributes starting with `mariadb_` instead of `mysql_`. * Add a `USE` statement to set the registry as the current database after it has been created. Not sure how this wasn't required when using DBD::mysql, but aligns more closely with the requirements of other engines. Resolves #825.
1 parent 33291bd commit d17dff9

File tree

24 files changed

+94
-69
lines changed

24 files changed

+94
-69
lines changed

.github/ubuntu/mysql.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ set -e
66
if [ -z "$SKIP_DEPENDS" ]; then
77
sudo apt-get update -qq
88
sudo apt-get remove -qq mysql-common # https://github.com/actions/virtual-environments/issues/5067#issuecomment-1038752575
9-
sudo env DEBIAN_FRONTEND=noninteractive apt-get install -qq mysql-client default-libmysqlclient-dev
9+
sudo env DEBIAN_FRONTEND=noninteractive apt-get install -qq mariadb-client libmariadbd-dev
1010
fi

.github/workflows/coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
.github/ubuntu/snowflake.sh
7676
.github/ubuntu/vertica.sh
7777
- run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends --cpanfile dist/cpanfile
78-
- run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends DBI DBD::ODBC DBD::Firebird DBD::Oracle DBD::mysql DBD::Pg Devel::Cover Devel::Cover::Report::Coveralls
78+
- run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends DBI DBD::ODBC DBD::Firebird DBD::Oracle DBD::MariaDB DBD::Pg Devel::Cover Devel::Cover::Report::Coveralls
7979
- name: Run Tests
8080
env:
8181
PERL5LIB: "${{ github.workspace }}/local/lib/perl5"

.github/workflows/mysql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
runs-on: ubuntu-latest
4343
services:
4444
# Run the MySQL service in a container we can connect to. Means that the
45-
# CLI and libraries DBD::mysql use are static to the version on the runner
45+
# CLI and libraries DBD::MariaDB use are static to the version on the runner
4646
# machine.
4747
mysql:
4848
image: "${{ matrix.image }}:${{ matrix.version }}"
@@ -63,7 +63,7 @@ jobs:
6363
path: local
6464
key: perl-${{ steps.perl.outputs.perl-hash }}
6565
- run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends --cpanfile dist/cpanfile
66-
- run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends DBD::mysql
66+
- run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends DBD::MariaDB
6767
- name: prove
6868
env:
6969
PERL5LIB: "${{ github.workspace }}/local/lib/perl5"

Changes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ Revision history for Perl extension App::Sqitch
4444
permission to create a schema and to skip the creation of the registry
4545
schema. Useful for cases when the registry schema was created in
4646
advance. Thanks to Peter Wimsey for the suggestion (#826).
47+
- Switched the MySQL engine from DBD::mysql to DBD::MariaDB for better
48+
compatibility with older versions of the MySQL client library and for
49+
its Unicode improvements. Thanks to Mark Tyrrell for the report and
50+
@tiberiusferreira and Perl Monks `1nickt` and`InfiniteSilence` for the
51+
feedback (#825).
4752

4853
1.4.1 2024-02-04T16:35:32Z
4954
- Removed the quoting of the role and warehouse identifiers that was

dist.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Test::Spelling = 0
7676
Test::MockObject::Extends = 1.20180705
7777
DBD::SQLite = 1.37
7878
DBD::Pg = 2.0
79-
DBD::mysql = 4.018
79+
DBD::MariaDB = 1.0
8080
MySQL::Config = 0
8181
DBD::Firebird = 1.11
8282
DBD::ODBC = 1.59
@@ -107,7 +107,7 @@ DBD::SQLite = 1.37
107107
[OptionalFeature / mysql]
108108
-description = Support for managing MySQL databases
109109
-prompt = 0
110-
DBD::mysql = 4.018
110+
DBD::MariaDB = 1.0
111111
MySQL::Config = 0
112112

113113
[OptionalFeature / firebird]

dist/cpanfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ suggests "DBD::ODBC" => "1.59";
7171
suggests "DBD::Oracle" => "1.23";
7272
suggests "DBD::Pg" => "2.0";
7373
suggests "DBD::SQLite" => "1.37";
74-
suggests "DBD::mysql" => "4.018";
74+
suggests "DBD::MariaDB" => "1.0";
7575
suggests "MySQL::Config" => "0";
7676
suggests "Time::HiRes" => "0";
7777
suggests "Time::Local" => "0";
@@ -120,7 +120,7 @@ on 'develop' => sub {
120120
requires "DBD::Oracle" => "1.23";
121121
requires "DBD::Pg" => "2.0";
122122
requires "DBD::SQLite" => "1.37";
123-
requires "DBD::mysql" => "4.018";
123+
requires "DBD::MariaDB" => "1.0";
124124
requires "MySQL::Config" => "0";
125125
requires "Time::HiRes" => "0";
126126
requires "Time::Local" => "0";
@@ -131,7 +131,7 @@ on 'develop' => sub {
131131
recommends "DBD::ODBC" => "1.59";
132132
recommends "DBD::Pg" => "2.0";
133133
recommends "DBD::SQLite" => "1.37";
134-
recommends "DBD::mysql" => "4.018";
134+
recommends "DBD::MariaDB" => "1.0";
135135
recommends "Dist::Zilla" => "5";
136136
recommends "Dist::Zilla::Plugin::AutoPrereqs" => "0";
137137
recommends "Dist::Zilla::Plugin::CPANFile" => "0";

dist/sqitch.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ Group: Development/Libraries
240240
Requires: sqitch >= %{version}
241241
Requires: mysql >= 5.1.0
242242
Requires: perl(DBI) >= 1.631
243-
Requires: perl(DBD::mysql) >= 4.018
243+
Requires: perl(DBD::MariaDB) >= 1.0
244244
Requires: perl(MySQL::Config)
245245
Provides: sqitch-mysql
246246

inc/Menlo/Sqitch.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ Runtime-only dependencies
219219
DBD-ODBC
220220
DBD-Oracle
221221
DBD-Pg
222-
DBD-mysql
222+
DBD-MariaDB
223223
Data-OptList
224224
DateTime
225225
DateTime-Locale

lib/App/Sqitch/Engine/exasol.pm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ has dbh => (
124124
my $self = shift;
125125
$self->use_driver;
126126

127-
my $uri = $self->uri;
128-
DBI->connect($uri->dbi_dsn, $self->username, $self->password, {
127+
DBI->connect($self->_dsn, $self->username, $self->password, {
129128
PrintError => 0,
130129
RaiseError => 0,
131130
AutoCommit => 1,

lib/App/Sqitch/Engine/firebird.pm

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ sub registry_destination {
6161

6262
sub _def_user { $ENV{ISC_USER} }
6363
sub _def_pass { $ENV{ISC_PASSWORD} }
64+
sub _dsn {
65+
my $uri = shift->registry_uri;
66+
return $uri->dbi_dsn . ';ib_dialect=3;ib_charset=UTF8';
67+
}
6468

6569
has dbh => (
6670
is => 'rw',
@@ -69,11 +73,9 @@ has dbh => (
6973
clearer => '_clear_dbh',
7074
default => sub {
7175
my $self = shift;
72-
my $uri = $self->registry_uri;
7376
$self->use_driver;
7477

75-
my $dsn = $uri->dbi_dsn . ';ib_dialect=3;ib_charset=UTF8';
76-
return DBI->connect($dsn, scalar $self->username, scalar $self->password, {
78+
return DBI->connect($self->_dsn, scalar $self->username, scalar $self->password, {
7779
PrintError => 0,
7880
RaiseError => 0,
7981
AutoCommit => 1,

0 commit comments

Comments
 (0)