Repository navigation
fix(admin): make Create User work on MariaDB - #564
Merged
Merged
Conversation
Closes #561. The dialog emitted the same statement whichever server was connected: CREATE USER 'name'@'%' IDENTIFIED WITH caching_sha2_password BY 'password' MariaDB rejects that outright, and not only for that plugin. Verified against MariaDB 11 and MySQL 8: MariaDB IDENTIFIED WITH caching_sha2_password BY 'pw' ERROR 1064 MariaDB IDENTIFIED WITH mysql_native_password BY 'pw' ERROR 1064 MariaDB IDENTIFIED VIA mysql_native_password USING PASSWORD('pw') ok MariaDB IDENTIFIED BY 'pw' ok MySQL 8 IDENTIFIED WITH caching_sha2_password BY 'pw' ok So creating a user against MariaDB failed every time, whichever plugin was chosen. caching_sha2_password — the dialog's default — is not merely spelled differently there; MariaDB does not implement it. Its active authentication plugins are mysql_native_password, mysql_old_password and unix_socket. The statement now depends on the server. serverFlavour reads the version string the connection already carries, the same question the backend asks for EXPLAIN ANALYZE. MariaDB gets IDENTIFIED VIA ... USING PASSWORD(...), MySQL keeps IDENTIFIED WITH ... BY, and both get plain IDENTIFIED BY when the plugin is left as Server default — which is now the default, because it is the only form that is right on both. The plugin list is per server too. Offering caching_sha2_password on MariaDB would only move the failure from parse time to execution time. WITH MAX_USER_CONNECTIONS and ACCOUNT LOCK were never the problem; both servers take them, which is worth recording since they sit in the same statement. Building the statement moves out of the component into src/lib/admin/create-user.ts, where it can be tested without rendering a dialog. Thirteen unit tests. Four integration tests do the half unit tests cannot: each server accepting the form built for it, both accepting the portable one, and — pinning the defect rather than trusting the fix — MariaDB still rejecting the form that was being sent. If that last one ever passes, the branch can go. The unit tests are new code testing new code, so they do not fail against the previous version in the way a regression test would. The integration tests are what actually demonstrate the bug and the fix. Co-Authored-By: Claude Opus 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #561.
The bug
The dialog emitted the same statement whichever server was connected:
MariaDB rejects that outright, and not only for that plugin. Verified against MariaDB 11 and MySQL 8:
IDENTIFIED WITH caching_sha2_password BY 'pw'IDENTIFIED WITH mysql_native_password BY 'pw'IDENTIFIED VIA mysql_native_password USING PASSWORD('pw')IDENTIFIED BY 'pw'IDENTIFIED WITH caching_sha2_password BY 'pw'So creating a user against MariaDB failed every time, whichever plugin was chosen. And
caching_sha2_password— the dialog's default — isn't merely spelled differently there; MariaDB doesn't implement it. Its active authentication plugins aremysql_native_password,mysql_old_passwordandunix_socket.The fix
The statement now depends on the server.
serverFlavourreads the version string the connection already carries — the same question the backend asks forEXPLAIN ANALYZE.IDENTIFIED VIA <plugin> USING PASSWORD(...)IDENTIFIED WITH <plugin> BY ...IDENTIFIED BY ..."Server default" is now the default, because it's the only form that's right on both.
The plugin list is per-server too. Offering
caching_sha2_passwordon MariaDB would only move the failure from parse time to execution time.WITH MAX_USER_CONNECTIONSandACCOUNT LOCKwere never the problem — both servers take them. Worth recording, since they sit in the same statement and could easily have been assumed guilty by association.Statement building moves out of the component into
src/lib/admin/create-user.ts, where it can be tested without rendering a dialog.Tests
13 unit tests on the builder and flavour detection.
4 integration tests doing the half unit tests can't — each server accepting the form built for it, both accepting the portable one, and one that pins the defect rather than trusting the fix: MariaDB still rejecting the form that was being sent. If that ever passes, the branch can go.
One honest note: the unit tests are new code testing new code, so they don't "fail against the previous version" the way a regression test does. The integration tests are what actually demonstrate the bug and the fix.
16 admin integration tests green against live MySQL 8 and MariaDB 11; 1819 unit + 303 browser; clippy/tsc/dprint/eslint clean.
🤖 Generated with Claude Code