Backport for the Shopware 6.6 line. When the server is MariaDB but only MySQL 8's mysqldump is installed (e.g. dockware/web), the dump aborted with "Unknown table 'COLUMN_STATISTICS' in information_schema (1109)". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
41 lines
1.7 KiB
PHP
41 lines
1.7 KiB
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace AeonDumpManager\Tests\Service;
|
|
|
|
use AeonDumpManager\Service\MySqlVariant;
|
|
use PHPUnit\Framework\Attributes\DataProvider;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class MySqlVariantTest extends TestCase
|
|
{
|
|
#[DataProvider('versionProvider')]
|
|
public function testIsMariaDb(string $version, bool $expected): void
|
|
{
|
|
self::assertSame($expected, MySqlVariant::isMariaDb($version));
|
|
}
|
|
|
|
public static function versionProvider(): iterable
|
|
{
|
|
yield 'plain mysql' => ['8.0.36', false];
|
|
yield 'mariadb with legacy prefix' => ['5.5.5-10.11.2-MariaDB', true];
|
|
yield 'mariadb without legacy prefix' => ['10.11.2-MariaDB', true];
|
|
yield 'mariadb lowercase' => ['10.11.2-mariadb', true];
|
|
}
|
|
|
|
#[DataProvider('columnStatisticsProvider')]
|
|
public function testNeedsColumnStatisticsOff(string $clientVersion, bool $serverIsMariaDb, bool $expected): void
|
|
{
|
|
self::assertSame($expected, MySqlVariant::needsColumnStatisticsOff($clientVersion, $serverIsMariaDb));
|
|
}
|
|
|
|
public static function columnStatisticsProvider(): iterable
|
|
{
|
|
$mysql8 = 'mysqldump Ver 8.0.46-0ubuntu0.24.04.4 for Linux on x86_64 ((Ubuntu))';
|
|
yield 'mysql 8 client, mariadb server' => [$mysql8, true, true];
|
|
yield 'mysql 8 client, mysql server' => [$mysql8, false, false];
|
|
yield 'mysql 5.7 client, mariadb server' => ['mysqldump Ver 10.13 Distrib 5.7.44, for Linux (x86_64)', true, false];
|
|
yield 'mariadb client, mariadb server' => ['mariadb-dump from 11.4.2-MariaDB, client 10.19 for debian-linux-gnu (x86_64)', true, false];
|
|
yield 'mariadb legacy mysqldump name' => ['mysqldump Ver 10.19 Distrib 10.11.6-MariaDB, for debian-linux-gnu (x86_64)', true, false];
|
|
}
|
|
}
|