MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / check_locale

Function check_locale

sql/sys_vars.cc:1317–1367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1315
1316
1317static 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}
1368static 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,

Callers

nothing calls this directly

Calls 12

my_locale_by_numberFunction · 0.85
my_errorFunction · 0.85
llstrFunction · 0.85
check_not_nullFunction · 0.85
my_locale_by_nameFunction · 0.85
read_textsFunction · 0.85
push_warning_printfFunction · 0.85
c_ptr_safeMethod · 0.80
result_typeMethod · 0.45
val_intMethod · 0.45
val_strMethod · 0.45
ptrMethod · 0.45

Tested by

no test coverage detected