Skip to content

Commit

Permalink
Bug 1467006: Explicitly support MariaDB (#100)
Browse files Browse the repository at this point in the history
Also fixes the following:
* Bug 868869: Require MariaDB 10.0.5
* Bug 868867: Require DBD::mysql 4.032
  • Loading branch information
justdave authored Apr 28, 2024
1 parent a35739b commit 1bd5d7d
Show file tree
Hide file tree
Showing 20 changed files with 1,878 additions and 25 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ jobs:
- name: Run bmo specific tests
run: docker compose -f docker-compose.test.yml run -e CI=1 bugzilla6.test test_bmo -q -f t/bmo/*.t

test_bugzilla6_mariadb:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install docker-compose
run: sudo apt update && sudo apt install -y docker-compose
- name: Build the Docker images
run: docker compose -f docker-compose.test-mariadb.yml build
- name: Run bmo specific tests
run: docker compose -f docker-compose.test-mariadb.yml run -e CI=1 bugzilla6.test test_bmo -q -f t/bmo/*.t

test_bugzilla6_pg:
runs-on: ubuntu-latest
steps:
Expand Down
19 changes: 17 additions & 2 deletions Bugzilla/Constants.pm
Original file line number Diff line number Diff line change
Expand Up @@ -544,15 +544,30 @@ use constant DB_MODULE => {
module => 'DBD::mysql',

# Disallow development versions
blacklist => ['_'],
blocklist => ['_'],

# For UTF-8 support. 4.001 makes sure that blobs aren't
# marked as UTF-8.
version => '4.001',
version => '4.032',
},
name => 'MySQL'
},

# MariaDB used to be a drop-in replacement for MySQL but now it
# isn't so we have a separate driver
'mariadb' => {
db => 'Bugzilla::DB::MariaDB',
db_version => '10.0.5',
dbd => {
package => 'DBD-MariaDB',
module => 'DBD::MariaDB',

# Disallow development versions
blocklist => ['_'],
},
name => 'MariaDB'
},

# Also see Bugzilla::DB::Pg::bz_check_server_version, which has special
# code to require DBD::Pg 2.17.2 for PostgreSQL 9 and above.
'pg' => {
Expand Down
29 changes: 26 additions & 3 deletions Bugzilla/DB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -276,22 +276,45 @@ sub bz_check_server_version {
my ($self, $db, $output) = @_;

my $sql_vers = $self->bz_server_version;

if (((lc($db->{name}) eq 'mysql') || (lc($db->{name}) eq "mariadb"))
&& ($sql_vers =~ s/^5\.5\.5-//)) {
# Version 5.5.5 of MySQL never existed. MariaDB >= 10 always puts '5.5.5-'
# at the front of its version string to get around a limitation in the
# replication protocol it shares with MySQL. So if the version starts with
# '5.5.5-' then we can assume this is MariaDB and the real version number
# will immediately follow that.
$db = DB_MODULE->{'mariadb'};
}
my $sql_dontwant = exists $db->{db_blocklist} ? $db->{db_blocklist} : [];
my $sql_want = $db->{db_version};
my $version_ok = vers_cmp($sql_vers, $sql_want) > -1 ? 1 : 0;

my $blocklisted;
if ($version_ok) {
$blocklisted = grep($sql_vers =~ /$_/, @$sql_dontwant);
$version_ok = 0 if $blocklisted;
}
my $sql_server = $db->{name};
if ($output) {
Bugzilla::Install::Requirements::_checking_for({
package => $sql_server,
wanted => $sql_want,
found => $sql_vers,
ok => $version_ok
ok => $version_ok,
blocklisted => $blocklisted
});
}

# Check what version of the database server is installed and let
# the user know if the version is too old to be used with Bugzilla.
if ($blocklisted) {
die <<EOT;
Your $sql_server v$sql_vers is blocklisted. Please check the
release notes for details or try a different database engine
or version.
EOT
}
if (!$version_ok) {
die <<EOT;
Expand Down
Loading

0 comments on commit 1bd5d7d

Please sign in to comment.