Skip to content

Commit 1d6ef0b

Browse files
committed
Be more helpful on unknown parameter messages
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.
1 parent 002330e commit 1d6ef0b

File tree

8 files changed

+792
-27
lines changed

8 files changed

+792
-27
lines changed

mysql-test/main/deprecated_features.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
set global log_bin_trust_routine_creators=1;
2-
ERROR HY000: Unknown system variable 'log_bin_trust_routine_creators'
2+
ERROR HY000: Unknown system variable 'log_bin_trust_routine_creators', did you mean 'log_bin_trust_function_creators'?
33
set table_type='MyISAM';
44
ERROR HY000: Unknown system variable 'table_type'
55
select @@table_type='MyISAM';

mysql-test/suite/sys_vars/r/delayed_insert_timeout_basic.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ SELECT @@global.delayed_insert_timeout;
5959
SET @@session.delayed_insert_timeout = 0;
6060
ERROR HY000: Variable 'delayed_insert_timeout' is a GLOBAL variable and should be set with SET GLOBAL
6161
SELECT @@session.dalayed_insert_timeout;
62-
ERROR HY000: Unknown system variable 'dalayed_insert_timeout'
62+
ERROR HY000: Unknown system variable 'dalayed_insert_timeout', did you mean 'delayed_insert_timeout'?
6363
'#----------------------FN_DYNVARS_025_06------------------------#'
6464
SELECT @@global.delayed_insert_timeout = VARIABLE_VALUE
6565
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
set global default_storage_engine= innodb;
2+
set default_storage_engine= innodb;
3+
SET NAMES utf8;
4+
#
5+
# MDEV-34646 Be more helpful on unknown parameter messages
6+
#
7+
set innobdb_lock_wait_timeout=1000;
8+
ERROR HY000: Unknown system variable 'innobdb_lock_wait_timeout', did you mean 'innodb_lock_wait_timeout'?
9+
#
10+
# Verify the change in other languages
11+
#
12+
# Czech
13+
SET lc_messages='cs_CZ';
14+
SET innobdb_lock_wait_timeout=1000;
15+
ERROR HY000: Neznámá systémová proměnná 'innobdb_lock_wait_timeout', mysleli jste 'innodb_lock_wait_timeout'?
16+
# Danish
17+
SET lc_messages='da_DK';
18+
SET innobdb_lock_wait_timeout=1000;
19+
ERROR HY000: Ukendt systemvariabel 'innobdb_lock_wait_timeout', mente du 'innodb_lock_wait_timeout'?
20+
# Estonian
21+
SET lc_messages='et_EE';
22+
SET innobdb_lock_wait_timeout=1000;
23+
ERROR HY000: Tundmatu süsteemne muutuja 'innobdb_lock_wait_timeout', kas mõtlesite 'innodb_lock_wait_timeout'?
24+
# French
25+
SET lc_messages='fr_FR';
26+
SET innobdb_lock_wait_timeout=1000;
27+
ERROR HY000: Variable système 'innobdb_lock_wait_timeout' inconnue, vouliez-vous dire 'innodb_lock_wait_timeout' ?
28+
# German
29+
SET lc_messages='de_DE';
30+
SET innobdb_lock_wait_timeout=1000;
31+
ERROR HY000: Unbekannte Systemvariable 'innobdb_lock_wait_timeout', meinten Sie 'innodb_lock_wait_timeout'?
32+
# Georgian
33+
SET lc_messages='ka_GE';
34+
SET innobdb_lock_wait_timeout=1000;
35+
ERROR HY000: უცნობი სისტემური ცვლადი 'innobdb_lock_wait_timeout', ხომ არ იგულისხმეთ 'innodb_lock_wait_timeout'?
36+
# Hindi
37+
SET lc_messages='hi_IN';
38+
SET innobdb_lock_wait_timeout=1000;
39+
ERROR HY000: अज्ञात सिस्टम वेरिएबल 'innobdb_lock_wait_timeout', क्या आपका मतलब 'innodb_lock_wait_timeout' था?
40+
# Italian
41+
SET lc_messages='it_IT';
42+
SET innobdb_lock_wait_timeout=1000;
43+
ERROR HY000: Variabile di sistema 'innobdb_lock_wait_timeout' sconosciuta, intendevi dire 'innodb_lock_wait_timeout'?
44+
# Japanese
45+
SET lc_messages='ja_JP';
46+
SET innobdb_lock_wait_timeout=1000;
47+
ERROR HY000: 'innobdb_lock_wait_timeout' は不明なシステム変数です。もしかして 'innodb_lock_wait_timeout' ですか?
48+
# Dutch
49+
SET lc_messages='nl_NL';
50+
SET innobdb_lock_wait_timeout=1000;
51+
ERROR HY000: Onbekende systeem variabele 'innobdb_lock_wait_timeout', bedoelde u 'innodb_lock_wait_timeout'?
52+
# Portuguese
53+
SET lc_messages='pt_PT';
54+
SET innobdb_lock_wait_timeout=1000;
55+
ERROR HY000: Variável de sistema 'innobdb_lock_wait_timeout' desconhecida, você quis dizer 'innodb_lock_wait_timeout'?
56+
# Russian
57+
SET lc_messages='ru_RU';
58+
SET innobdb_lock_wait_timeout=1000;
59+
ERROR HY000: Неизвестная системная переменная 'innobdb_lock_wait_timeout', вы имели в виду 'innodb_lock_wait_timeout'?
60+
# Serbian
61+
SET lc_messages='sr_RS';
62+
SET innobdb_lock_wait_timeout=1000;
63+
ERROR HY000: Nepoznata sistemska promenljiva 'innobdb_lock_wait_timeout', da li ste mislili na 'innodb_lock_wait_timeout'?
64+
# Spanish
65+
SET lc_messages='es_ES';
66+
SET innobdb_lock_wait_timeout=1000;
67+
ERROR HY000: Variable de sistema 'innobdb_lock_wait_timeout' desconocida, ¿quiso decir 'innodb_lock_wait_timeout'?
68+
# Swahili
69+
SET lc_messages='sw_KE';
70+
SET innobdb_lock_wait_timeout=1000;
71+
ERROR HY000: Tofauti ya mfumo isiyojulikana 'innobdb_lock_wait_timeout', je, ulikusudia 'innodb_lock_wait_timeout'?
72+
# Swedish
73+
SET lc_messages='sv_SE';
74+
SET innobdb_lock_wait_timeout=1000;
75+
ERROR HY000: Okänd systemvariabel: 'innobdb_lock_wait_timeout', menade du 'innodb_lock_wait_timeout'?
76+
# Ukrainian
77+
SET lc_messages='uk_UA';
78+
SET innobdb_lock_wait_timeout=1000;
79+
ERROR HY000: Невідома системна змінна 'innobdb_lock_wait_timeout', ви мали на увазі 'innodb_lock_wait_timeout'?
80+
# Chinese
81+
SET lc_messages='zh_CN';
82+
SET innobdb_lock_wait_timeout=1000;
83+
ERROR HY000: 未知系统变量 'innobdb_lock_wait_timeout',你是想输入 'innodb_lock_wait_timeout' 吗?
84+
#
85+
# Verify the change in other variables
86+
#
87+
SET lc_messages='en_US';
88+
SET sll_ca=0;
89+
ERROR HY000: Unknown system variable 'sll_ca', did you mean 'ssl_ca'?
90+
SET GLOBAL mx_conncetoins = 500;
91+
ERROR HY000: Unknown system variable 'mx_conncetoins'
92+
SET GLOBAL qurey_cach_size = 134217728;
93+
ERROR HY000: Unknown system variable 'qurey_cach_size', did you mean 'query_cache_size'?
94+
SET SESSION join_bufer_size = 2097152;
95+
ERROR HY000: Unknown system variable 'join_bufer_size', did you mean 'join_buffer_size'?
96+
SET SESSION sort_bufer_size = 2097152;
97+
ERROR HY000: Unknown system variable 'sort_bufer_size', did you mean 'sort_buffer_size'?
98+
SET GLOBAL max_conections = 500;
99+
ERROR HY000: Unknown system variable 'max_conections', did you mean 'max_connections'?
100+
SET SESSION tmp_table_sze = 67108864;
101+
ERROR HY000: Unknown system variable 'tmp_table_sze', did you mean 'tmp_table_size'?
102+
SET GLOBAL innodb_lok_wait_timeout = 120;
103+
ERROR HY000: Unknown system variable 'innodb_lok_wait_timeout', did you mean 'innodb_lock_wait_timeout'?
104+
SET SESSION lock_wiat_timeout = 60;
105+
ERROR HY000: Unknown system variable 'lock_wiat_timeout', did you mean 'lock_wait_timeout'?
106+
SET GLOBAL wait_tiemout = 600;
107+
ERROR HY000: Unknown system variable 'wait_tiemout', did you mean 'wait_timeout'?
108+
SET SESSION sql_mde = 'STRICT_TRANS_TABLES';
109+
ERROR HY000: Unknown system variable 'sql_mde', did you mean 'sql_mode'?
110+
SET SESSION character_set_clinet = 'utf8mb4';
111+
ERROR HY000: Unknown system variable 'character_set_clinet', did you mean 'character_set_client'?
112+
SET SESSION character_set_resuts = 'utf8mb4';
113+
ERROR HY000: Unknown system variable 'character_set_resuts', did you mean 'character_set_results'?
114+
SET GLOBAL innodb_buffer_pol_size = 134217728;
115+
ERROR HY000: Unknown system variable 'innodb_buffer_pol_size', did you mean 'innodb_buffer_pool_size'?
116+
SET GLOBAL thred_cache_size = 50;
117+
ERROR HY000: Unknown system variable 'thred_cache_size', did you mean 'thread_cache_size'?
118+
SET GLOBAL table_open_cach = 2000;
119+
ERROR HY000: Unknown system variable 'table_open_cach', did you mean 'table_open_cache'?
120+
SET GLOBAL query_cache_szie = 134217728;
121+
ERROR HY000: Unknown system variable 'query_cache_szie', did you mean 'query_cache_size'?
122+
SET SESSION max_hep_table_size = 67108864;
123+
ERROR HY000: Unknown system variable 'max_hep_table_size', did you mean 'max_heap_table_size'?
124+
#
125+
# Test long variables
126+
#
127+
set innobdb_lock_wait_timeout_a_very_very_very_long_variable_a_very_very_very_long_variable_a_very_very_very_long_variable_a_very_very_very_long_variable_a_very_very_very_long_variable=1000;
128+
ERROR HY000: Unknown system variable 'innobdb_lock_wait_timeout_a_very_very_very_long_variable_a_very_very_very_long_variable_a_very_very_very_long_variable_a_very_very_very_long_variable_a_very_very_very_long_variable', did you mean 'innodb_lock_wait_timeout'?
129+
#
130+
# Verify not to print suggestion when the input is far from the closest variable
131+
#
132+
# Czech
133+
SET lc_messages='cs_CZ';
134+
SET xxxxxxxxxxxxxxxxxxx=1000;
135+
ERROR HY000: Neznámá systémová proměnná 'xxxxxxxxxxxxxxxxxxx'
136+
# Danish
137+
SET lc_messages='da_DK';
138+
SET xxxxxxxxxxxxxxxxxxx=1000;
139+
ERROR HY000: Ukendt systemvariabel 'xxxxxxxxxxxxxxxxxxx'
140+
# Estonian
141+
SET lc_messages='et_EE';
142+
SET xxxxxxxxxxxxxxxxxxx=1000;
143+
ERROR HY000: Tundmatu süsteemne muutuja 'xxxxxxxxxxxxxxxxxxx'
144+
# French
145+
SET lc_messages='fr_FR';
146+
SET xxxxxxxxxxxxxxxxxxx=1000;
147+
ERROR HY000: Variable système 'xxxxxxxxxxxxxxxxxxx' inconnue
148+
# German
149+
SET lc_messages='de_DE';
150+
SET xxxxxxxxxxxxxxxxxxx=1000;
151+
ERROR HY000: Unbekannte Systemvariable 'xxxxxxxxxxxxxxxxxxx'
152+
# Georgian
153+
SET lc_messages='ka_GE';
154+
SET xxxxxxxxxxxxxxxxxxx=1000;
155+
ERROR HY000: უცნობი სისტემური ცვლადი 'xxxxxxxxxxxxxxxxxxx'
156+
# Hindi
157+
SET lc_messages='hi_IN';
158+
SET xxxxxxxxxxxxxxxxxxx=1000;
159+
ERROR HY000: अज्ञात सिस्टम वेरिएबल 'xxxxxxxxxxxxxxxxxxx'
160+
# Italian
161+
SET lc_messages='it_IT';
162+
SET xxxxxxxxxxxxxxxxxxx=1000;
163+
ERROR HY000: Variabile di sistema 'xxxxxxxxxxxxxxxxxxx' sconosciuta
164+
# Japanese
165+
SET lc_messages='ja_JP';
166+
SET xxxxxxxxxxxxxxxxxxx=1000;
167+
ERROR HY000: 'xxxxxxxxxxxxxxxxxxx' は不明なシステム変数です
168+
# Dutch
169+
SET lc_messages='nl_NL';
170+
SET xxxxxxxxxxxxxxxxxxx=1000;
171+
ERROR HY000: Onbekende systeem variabele 'xxxxxxxxxxxxxxxxxxx'
172+
# Portuguese
173+
SET lc_messages='pt_PT';
174+
SET xxxxxxxxxxxxxxxxxxx=1000;
175+
ERROR HY000: Variável de sistema 'xxxxxxxxxxxxxxxxxxx' desconhecida
176+
# Russian
177+
SET lc_messages='ru_RU';
178+
SET xxxxxxxxxxxxxxxxxxx=1000;
179+
ERROR HY000: Неизвестная системная переменная 'xxxxxxxxxxxxxxxxxxx'
180+
# Serbian
181+
SET lc_messages='sr_RS';
182+
SET xxxxxxxxxxxxxxxxxxx=1000;
183+
ERROR HY000: Nepoznata sistemska promenljiva 'xxxxxxxxxxxxxxxxxxx'
184+
# Spanish
185+
SET lc_messages='es_ES';
186+
SET xxxxxxxxxxxxxxxxxxx=1000;
187+
ERROR HY000: Variable de sistema 'xxxxxxxxxxxxxxxxxxx' desconocida
188+
# Swahili
189+
SET lc_messages='sw_KE';
190+
SET xxxxxxxxxxxxxxxxxxx=1000;
191+
ERROR HY000: Tofauti ya mfumo isiyojulikana 'xxxxxxxxxxxxxxxxxxx'
192+
# Swedish
193+
SET lc_messages='sv_SE';
194+
SET xxxxxxxxxxxxxxxxxxx=1000;
195+
ERROR HY000: Okänd systemvariabel: 'xxxxxxxxxxxxxxxxxxx'
196+
# Ukrainian
197+
SET lc_messages='uk_UA';
198+
SET xxxxxxxxxxxxxxxxxxx=1000;
199+
ERROR HY000: Невідома системна змінна 'xxxxxxxxxxxxxxxxxxx'
200+
# Chinese
201+
SET lc_messages='zh_CN';
202+
SET xxxxxxxxxxxxxxxxxxx=1000;
203+
ERROR HY000: 未知系统变量 'xxxxxxxxxxxxxxxxxxx'
204+
set global default_storage_engine= MyISAM;

0 commit comments

Comments
 (0)