Skip to content

Conversation

gengtianuiowa
Copy link
Contributor

Description

The previous "unknown variable" error message did not provide details about why the input variable was invalid. For example, entering an incorrect variable name such as innobdb_lock_wait_timeout would produce the following error:

ERROR HY000: Unknown system variable 'innobdb_lock_wait_timeout=1000'

This commits uses Levenshtein algorithm to calculate the closest matching system variable when an invalid name is provided. Levenshtein distance represents the minimum number of single-character edits (insertions, deletions, or replacements) required to transform one string into another, effectively measuring their similarity. More details can be found here:
https://www.geeksforgeeks.org/dsa/introduction-to-levenshtein-distance/

With the improvement, the error message becomes more user-friendly. For example:

ERROR HY000: Unknown system variable 'innobdb_lock_wait_timeout', did you mean 'innodb_lock_wait_timeout'?

This improvement has been applied to all 19 supported languages for system variables.

Since Levenshtein algorithm use O(n^2) space to create matrix. Input variable was truncated to the longest length of options to reduce overusing of space.

Similar changes have also been applied to options when user starts the database with mariadbd.

How can this PR be tested?

Execute the main suite in mysql-test-run.

Basing the PR against the correct MariaDB version

  • This is a new feature and the PR is based against the latest MariaDB development branch

Backward compatibility

This is a new feature introducing more friendly error message without changing existing behaviors. It is compatible with previous versions.

Copyright

All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@gengtianuiowa gengtianuiowa force-pushed the feat_variable_prompt branch 3 times, most recently from 1d6ef0b to dea3e6f Compare September 17, 2025 00:36
@ParadoxV5
Copy link
Contributor

did you mean 😄

@svoj svoj added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Sep 17, 2025
The previous "unknown variable" error message did not provide details
about why the input variable was invalid. For example, entering an
incorrect variable name such as innobdb_lock_wait_timeout would
produce the following error:

`ERROR HY000: Unknown system variable 'innobdb_lock_wait_timeout=1000'`

This commits uses Levenshtein algorithm to calculate the closest
matching system variable when an invalid name is provided. Levenshtein
distance represents the minimum number of single-character edits
(insertions, deletions, or replacements) required to transform one
string into another, effectively measuring their similarity. More details
can be found here:
https://www.geeksforgeeks.org/dsa/introduction-to-levenshtein-distance/

With the improvement, the error message becomes more user-friendly. For
example:

`ERROR HY000: Unknown system variable 'innobdb_lock_wait_timeout', did
you mean 'lock_wait_timeout'?`

This improvement has been applied to all 19 supported languages for
system variables.

Since Levenshtein algorithm use O(n^2) space to create matrix. Input
variable was truncated to the longest length of options to reduce
overusing of space.

Similar changes have also been applied to options when user starts the
database with mariadbd.

All new code of the whole pull request, including one or several files
that are either new files or modified ones, are contributed under the
BSD-new license. I am contributing on behalf of my employer Amazon Web
Services, Inc.
@gengtianuiowa
Copy link
Contributor Author

The latest commit in main branch already broke the plugins.server_audit test. This test failure may not come from my changes.
link of last commit's failure: https://buildbot.mariadb.org/#/builders/867/builds/3810

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.

4 participants