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

COLLATION_CHARACTER_SET_APPLICABILITY.COLLATION_NAME vs MariaDB FULL_COLLATION_NAME #6361

Open
rotdrop opened this issue Apr 17, 2024 · 3 comments · Fixed by #6425
Open

COLLATION_CHARACTER_SET_APPLICABILITY.COLLATION_NAME vs MariaDB FULL_COLLATION_NAME #6361

rotdrop opened this issue Apr 17, 2024 · 3 comments · Fixed by #6425

Comments

@rotdrop
Copy link

rotdrop commented Apr 17, 2024

In recent MariaDB version the following will not succeed (resp. always yields an empty result set):

$sql = <<<'SQL'
SELECT t.TABLE_NAME,
t.ENGINE,
t.AUTO_INCREMENT,
t.TABLE_COMMENT,
t.CREATE_OPTIONS,
t.TABLE_COLLATION,
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
SQL;

The reason is, that CCSA.collation_name in recent MariaDB versions (tested version: 10.11.7) only contains the short collation name without prepended character set, while TABLES.table_collation contains the long table name. For example, in the case of the newly introduced utf8mb4_uca1400_ai_ci the corresponding row from COLLATION_CHARACTER_SET_APPLICABILITY is (CSV export):

"COLLATION_NAME","CHARACTER_SET_NAME","FULL_COLLATION_NAME","ID","IS_DEFAULT"
"uca1400_ai_ci","utf8mb4","utf8mb4_uca1400_ai_ci","2304",

while the TABLES.TABLE_COLLATION holds the full collation name utf8mb4_uca1400_ai_ci.

It also seems that this is a recent change in MariaDB; one Ubuntu "Jammy" system I am using runs MariaDB 10.6.16 which only has the COLLATION_NAME and CHARACTER_SET_NAME in that table, and the collation name is the full name with the character set prepended.

@derrabus
Copy link
Member

Is this a bug report? If yes, please start with answering the usual questions:

  • What did you try to do?
  • What did you expect to happen?
  • What happened instead?

@rotdrop
Copy link
Author

rotdrop commented Apr 17, 2024

This is a bug report related to the most recent versions of MariaDB

What did you try to do?

Running Doctrine/Orm migrations after upgrading to DBAL >= 3 and ORM >=2.20

What did you expect to happen?

That -- after applying the suggested migrations -- the schema validation tools would no longer complain

What happened instead?

Endless loop, applying the suggested migrations did not help.

One comment from my side: yes, you receive frequent bug reports, but please read and understand my explanations from the first post, IMHO they are clear and concise. Thank you.

@greg0ire
Copy link
Member

but please read and understand my explanations from the first post, IMHO they are clear and concise

Another comment from my side: @derrabus 's questions are completely on point, it's not far fetched to ask you in what context you stumbled upon this, and it has nothing to do with the clarity or conciseness of your original message. I don't know why you assume your message hasn't been read.

grooverdan added a commit to grooverdan/dbal that referenced this issue Jun 7, 2024
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 critieria. In new MariaDB versions this won't
result in an extra row match.

Closes: doctrine#6361
grooverdan added a commit to grooverdan/dbal that referenced this issue Jun 7, 2024
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 critieria. In new MariaDB versions this won't
result in an extra row match.

Closes: doctrine#6361
grooverdan added a commit to grooverdan/dbal that referenced this issue Jun 7, 2024
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 critieria. In new MariaDB versions this won't
result in an extra row match.

Closes: doctrine#6361
derrabus pushed a commit that referenced this issue Jun 7, 2024
<!-- 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
derrabus added a commit that referenced this issue Jun 7, 2024
* 3.8.x:
  Fix MariaDB fetching of default table character-set (#6361) (#6425)
  Fix the portability documentation (#6429)
  Update tests/Platforms/AbstractPlatformTestCase.php
  Update tests/Platforms/AbstractPlatformTestCase.php
  add test
  Fix: Skip type comparison if disableTypeComments is true
grooverdan added a commit to grooverdan/dbal that referenced this issue Jun 9, 2024
…ySQL/MariaDB platforms

The diverging MariaDB-10.10.1+ implementation of retrieving table
options split the implementation so that its now in the
AbstractMySQLPlatform and the MariaDB specific implementation in
MariaDBPlatform.

Fixes doctrine#6361.
grooverdan added a commit to grooverdan/dbal that referenced this issue Jun 9, 2024
The diverging MariaDB-10.10.1+ implementation of retrieving table
options split the implementation so that its now in the
AbstractMySQLPlatform and the MariaDB specific implementation in
MariaDBPlatform.

Fixes doctrine#6361.
grooverdan added a commit to grooverdan/dbal that referenced this issue Jun 9, 2024
The diverging MariaDB-10.10.1+ implementation of retrieving table
options split the implementation so that its now in the
AbstractMySQLPlatform and the MariaDB specific implementation in
MariaDBPlatform.

Fixes doctrine#6361.
grooverdan added a commit to grooverdan/dbal that referenced this issue Jun 9, 2024
The diverging MariaDB-10.10.1+ implementation of retrieving table
options split the implementation so that its now in the
AbstractMySQLPlatform and the MariaDB specific implementation in
MariaDBPlatform.

Fixes doctrine#6361.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants