Skip to content
/ server Public

Conversation

@MooSayed1
Copy link

The JOIN between mysql.user and mysql.role_edges fails when tables
have different collations after upgrade (old tables keep utf8mb4_general_ci,
new default is utf8mb4_uca1400_ai_ci).

Solution

Add explicit COLLATE utf8mb4_general_ci to the JOIN conditions to ensure
consistent collation comparison regardless of upgrade path.

@MooSayed1 MooSayed1 force-pushed the MDEV-37442-collation-fix branch from b4849b5 to 06986fa Compare January 16, 2026 16:06
@github-actions github-actions bot added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Jan 17, 2026
Copy link
Member

@gkodinov gkodinov left a comment

Choose a reason for hiding this comment

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

This is a preliminary review.

First of all, please follow the https://github.com/MariaDB/server/blob/main/CODING_STANDARDS.md#git-commit-messages for the format of the commit message.

Secondly: this needs a test case according to https://mariadb.com/docs/general-resources/community/contributing-participating/contributing-code#testing. A basic rule of thumb is that the test added should fail without the fix and succeed with it.

Also, this definitely can benefit from a better explanation.

The root cause is that, when MySQL role tables are present, these tables are most probably using a collation that is not compatible with the collation after the mariaDB upgrade. And, since these tables are not present in a new database, there's no issue with this.

Note that this is not the only place to fix this. role_edges is used in many other places too. I'd review all of these, make sure they're executed, and try to fix all of them as well.

And, I believe that for this particular fix to make any difference, you also need to be running a MySQL server for this line to actually kick in. I've tried it on the command line as it is against a recent mariadbd and the role_edges didn't get into the explain at all!

I would ask the reporter what is their exact setup: are they getting this while running their "script" that they mention against a MySQL server binary (which I guess they do, since this particular conditional join seems to be kicking in according to the error message). And what tables do they have in their database (SHOW CREATE TABLE would be nice). It's good to confirm this. Especially if you are trying to make a test case for it.

@gkodinov gkodinov self-assigned this Jan 23, 2026
@MooSayed1
Copy link
Author

@gkodinov Thank you for the review feedback.

I’ve asked the reporter on JIRA for clarification about their setup, specifically:

Whether they’re running against MySQL or MariaDB server
The output of SHOW CREATE TABLE for the affected tables
Their migration history
Once I understand the exact scenario, I’ll:

Review all role_edges usages in the codebase
Create a proper test case
Update the commit message to follow the 50/72 format
Will update the PR once I have more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.

Development

Successfully merging this pull request may close these issues.

2 participants