libsql: avoid redundant threaded locale resets
This commit is contained in:
@@ -46,10 +46,14 @@ bool CAsyncSQL::QueryLocaleSet()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* current_charset = mysql_character_set_name(&m_hDB);
|
||||||
|
if (current_charset && m_stLocale == current_charset)
|
||||||
|
return true;
|
||||||
|
|
||||||
if (mysql_set_character_set(&m_hDB, m_stLocale.c_str()))
|
if (mysql_set_character_set(&m_hDB, m_stLocale.c_str()))
|
||||||
{
|
{
|
||||||
sys_err("cannot set locale %s by 'mysql_set_character_set', errno %u %s",
|
sys_err("cannot set locale %s by 'mysql_set_character_set' (current=%s), errno %u %s",
|
||||||
m_stLocale.c_str(), mysql_errno(&m_hDB), mysql_error(&m_hDB));
|
m_stLocale.c_str(), current_charset ? current_charset : "<unknown>", mysql_errno(&m_hDB), mysql_error(&m_hDB));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -614,5 +618,7 @@ size_t CAsyncSQL::EscapeString(char* dst, size_t dstSize, const char* src, size_
|
|||||||
void CAsyncSQL2::SetLocale(const std::string& stLocale)
|
void CAsyncSQL2::SetLocale(const std::string& stLocale)
|
||||||
{
|
{
|
||||||
m_stLocale = stLocale;
|
m_stLocale = stLocale;
|
||||||
QueryLocaleSet();
|
|
||||||
|
if (!HasWorkerThread())
|
||||||
|
QueryLocaleSet();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user