| 1315 | |
| 1316 | |
| 1317 | static bool check_locale(sys_var *self, THD *thd, set_var *var) |
| 1318 | { |
| 1319 | if (!var->value) |
| 1320 | return false; |
| 1321 | |
| 1322 | MY_LOCALE *locale; |
| 1323 | char buff[STRING_BUFFER_USUAL_SIZE]; |
| 1324 | if (var->value->result_type() == INT_RESULT) |
| 1325 | { |
| 1326 | int lcno= (int)var->value->val_int(); |
| 1327 | if (!(locale= my_locale_by_number(lcno))) |
| 1328 | { |
| 1329 | my_error(ER_UNKNOWN_LOCALE, MYF(0), llstr(lcno, buff)); |
| 1330 | return true; |
| 1331 | } |
| 1332 | if (check_not_null(self, thd, var)) |
| 1333 | return true; |
| 1334 | } |
| 1335 | else // STRING_RESULT |
| 1336 | { |
| 1337 | String str(buff, sizeof(buff), system_charset_info), *res; |
| 1338 | if (!(res=var->value->val_str(&str))) |
| 1339 | return true; |
| 1340 | else if (!(locale= my_locale_by_name(res->c_ptr_safe()))) |
| 1341 | { |
| 1342 | ErrConvString err(res); |
| 1343 | my_error(ER_UNKNOWN_LOCALE, MYF(0), err.ptr()); |
| 1344 | return true; |
| 1345 | } |
| 1346 | } |
| 1347 | |
| 1348 | var->save_result.ptr= locale; |
| 1349 | |
| 1350 | if (!locale->errmsgs->errmsgs) |
| 1351 | { |
| 1352 | mysql_mutex_lock(&LOCK_error_messages); |
| 1353 | if (!locale->errmsgs->errmsgs && |
| 1354 | read_texts(ERRMSG_FILE, locale->errmsgs->language, |
| 1355 | &locale->errmsgs->errmsgs, |
| 1356 | ER_ERROR_LAST - ER_ERROR_FIRST + 1)) |
| 1357 | { |
| 1358 | push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, |
| 1359 | "Can't process error message file for locale '%s'", |
| 1360 | locale->name); |
| 1361 | mysql_mutex_unlock(&LOCK_error_messages); |
| 1362 | return true; |
| 1363 | } |
| 1364 | mysql_mutex_unlock(&LOCK_error_messages); |
| 1365 | } |
| 1366 | return false; |
| 1367 | } |
| 1368 | static Sys_var_struct Sys_lc_messages( |
| 1369 | "lc_messages", "Set the language used for the error messages", |
| 1370 | SESSION_VAR(lc_messages), NO_CMD_LINE, |
nothing calls this directly
no test coverage detected