Skip to content

Commit 4aa9cf9

Browse files
authored
Fix MariaDB fetching of default table character-set (#6361) (#6425)
<!-- Fill in the relevant information below to help triage your pull request. --> | Q | A |------------- | ----------- | Type | bug | Fixed issues | #6361 #### Summary From MariaDB-10.10.1, where uca1400 was added, the information_schema.COLLATION_CHARACTER_SET_APPLICABILITY was extended to have FULL_COLLATION_NAME which corresponds to the information_schema.TABLES.TABLE_COLLATION value. Executable comment syntax is used to limited to the applicable versions. To preserve compatibility with older MariaDB versions, and MySQL versions where the previous COLLATION_NAME was the match is left as a JOIN criteria. In new MariaDB versions this won't result in an extra row match. Closes: #6361 The lack of this fix did case the CI test to fail with a MariaDB-11.0+ container: ``` 1) Doctrine\DBAL\Tests\Functional\Schema\MySQLSchemaManagerTest::testEnsureTableWithoutOptionsAreReflectedInMetadata Undefined array key "engine" /home/runner/work/dbal/dbal/src/Schema/Table.php:927 /home/runner/work/dbal/dbal/tests/Functional/Schema/MySQLSchemaManagerTest.php:550 ``` With this fix all version of MySQL and MariaDB (even those new ones soon to be in a different PR) will pass like: https://github.com/grooverdan/dbal/actions/runs/9412110648/job/25926481038
1 parent 1a0a211 commit 4aa9cf9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Schema/MySQLSchemaManager.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,11 @@ protected function selectForeignKeyColumns(string $databaseName, ?string $tableN
557557
*/
558558
protected function fetchTableOptionsByTable(string $databaseName, ?string $tableName = null): array
559559
{
560+
// MariaDB-10.10.1 added FULL_COLLATION_NAME to the information_schema.COLLATION_CHARACTER_SET_APPLICABILITY.
561+
// A base collation like uca1400_ai_ci can refer to multiple character sets. The value in the
562+
// information_schema.TABLES.TABLE_COLLATION corresponds to the full collation name.
563+
// The MariaDB executable comment syntax with version, /*M!101001, is exclusively executed on
564+
// MariaDB-10.10.1+ servers for backwards compatibility, and compatiblity to MySQL servers.
560565
$sql = <<<'SQL'
561566
SELECT t.TABLE_NAME,
562567
t.ENGINE,
@@ -567,7 +572,8 @@ protected function fetchTableOptionsByTable(string $databaseName, ?string $table
567572
ccsa.CHARACTER_SET_NAME
568573
FROM information_schema.TABLES t
569574
INNER JOIN information_schema.COLLATION_CHARACTER_SET_APPLICABILITY ccsa
570-
ON ccsa.COLLATION_NAME = t.TABLE_COLLATION
575+
ON /*M!101001 ccsa.FULL_COLLATION_NAME = t.TABLE_COLLATION OR */
576+
ccsa.COLLATION_NAME = t.TABLE_COLLATION
571577
SQL;
572578

573579
$conditions = ['t.TABLE_SCHEMA = ?'];

0 commit comments

Comments
 (0)