Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MariaDB fetching of default table character-set #6425

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/Schema/MySQLSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,11 @@ protected function selectForeignKeyColumns(string $databaseName, ?string $tableN
*/
protected function fetchTableOptionsByTable(string $databaseName, ?string $tableName = null): array
{
// MariaDB-10.10.1 added FULL_COLLATION_NAME to the information_schema.COLLATION_CHARACTER_SET_APPLICABILITY.
// A base collation like uca1400_ai_ci can refer to multiple character sets. The value in the
// information_schema.TABLES.TABLE_COLLATION corresponds to the full collation name.
// The MariaDB executable comment syntax with version, /*M!101001, is exclusively executed on
// MariaDB-10.10.1+ servers for backwards compatibility, and compatiblity to MySQL servers.
$sql = <<<'SQL'
SELECT t.TABLE_NAME,
t.ENGINE,
Expand All @@ -567,7 +572,8 @@ protected function fetchTableOptionsByTable(string $databaseName, ?string $table
ccsa.CHARACTER_SET_NAME
FROM information_schema.TABLES t
INNER JOIN information_schema.COLLATION_CHARACTER_SET_APPLICABILITY ccsa
ON ccsa.COLLATION_NAME = t.TABLE_COLLATION
ON /*M!101001 ccsa.FULL_COLLATION_NAME = t.TABLE_COLLATION OR */
ccsa.COLLATION_NAME = t.TABLE_COLLATION
Comment on lines -570 to +576
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to avoid version conditionals in SQL. We have our platform class hierarchy for this purpose.

I'll accept this change as a hotfix for MariaDB 11.4 on the 3.8.x branch. Can you work on a PR for 3.9.x that moves the SQL statement to AbstractMySQLPlatform and that introduces a new platform class for MariaDB 10.10 which overrides the generated SQL?

SQL;

$conditions = ['t.TABLE_SCHEMA = ?'];
Expand Down