fix issue #530
This commit is contained in:
parent
d5097cb7dd
commit
438c3eaa75
|
@ -2428,7 +2428,7 @@ static int setColumnFilterInfoForTimestamp(SSqlCmd* pCmd, tVariant* pVar) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tVariantDestroy(pVar);
|
tVariantDestroy(pVar);
|
||||||
tVariantCreateB(pVar, &time, 0, TSDB_DATA_TYPE_BIGINT);
|
tVariantCreateB(pVar, (char*)&time, 0, TSDB_DATA_TYPE_BIGINT);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,22 +210,25 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
|
||||||
|
|
||||||
if (cfg_locale && cfg_charset && cfg_locale->cfgStatus <= TSDB_CFG_CSTATUS_OPTION) {
|
if (cfg_locale && cfg_charset && cfg_locale->cfgStatus <= TSDB_CFG_CSTATUS_OPTION) {
|
||||||
char sep = '.';
|
char sep = '.';
|
||||||
char oldLocale[64] = {0};
|
|
||||||
strncpy(oldLocale, tsLocale, sizeof(oldLocale) / sizeof(oldLocale[0]));
|
|
||||||
|
|
||||||
|
if (strlen(tsLocale) == 0) { // locale does not set yet
|
||||||
|
char* defaultLocale = setlocale(LC_CTYPE, "");
|
||||||
|
strcpy(tsLocale, defaultLocale);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set the user specified locale
|
||||||
char *locale = setlocale(LC_CTYPE, pStr);
|
char *locale = setlocale(LC_CTYPE, pStr);
|
||||||
|
|
||||||
if (locale != NULL) {
|
if (locale != NULL) {
|
||||||
tscPrint("locale set, prev locale:%s, new locale:%s", oldLocale, locale);
|
tscPrint("locale set, prev locale:%s, new locale:%s", tsLocale, locale);
|
||||||
cfg_locale->cfgStatus = TSDB_CFG_CSTATUS_OPTION;
|
cfg_locale->cfgStatus = TSDB_CFG_CSTATUS_OPTION;
|
||||||
} else {
|
} else {
|
||||||
/* set the user-specified localed failed, use default LC_CTYPE as
|
/* set the user-specified localed failed, use default LC_CTYPE as current locale */
|
||||||
* current locale */
|
locale = setlocale(LC_CTYPE, tsLocale);
|
||||||
locale = setlocale(LC_CTYPE, oldLocale);
|
tscPrint("failed to set locale:%s, current locale:%s", pStr, tsLocale);
|
||||||
tscPrint("failed to set locale:%s, restore locale:%s", pStr, oldLocale);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(tsLocale, locale, sizeof(tsLocale) / sizeof(tsLocale[0]));
|
strncpy(tsLocale, locale, tListLen(tsLocale));
|
||||||
|
|
||||||
char *charset = strrchr(tsLocale, sep);
|
char *charset = strrchr(tsLocale, sep);
|
||||||
if (charset != NULL) {
|
if (charset != NULL) {
|
||||||
|
@ -234,15 +237,21 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
|
||||||
charset = taosCharsetReplace(charset);
|
charset = taosCharsetReplace(charset);
|
||||||
|
|
||||||
if (taosValidateEncodec(charset)) {
|
if (taosValidateEncodec(charset)) {
|
||||||
tscPrint("charset changed from %s to %s", tsCharset, charset);
|
if (strlen(tsCharset) == 0) {
|
||||||
|
tscPrint("charset set:%s", charset);
|
||||||
|
} else {
|
||||||
|
tscPrint("charset changed from %s to %s", tsCharset, charset);
|
||||||
|
}
|
||||||
|
|
||||||
strncpy(tsCharset, charset, tListLen(tsCharset));
|
strncpy(tsCharset, charset, tListLen(tsCharset));
|
||||||
cfg_charset->cfgStatus = TSDB_CFG_CSTATUS_OPTION;
|
cfg_charset->cfgStatus = TSDB_CFG_CSTATUS_OPTION;
|
||||||
;
|
|
||||||
} else {
|
} else {
|
||||||
tscPrint("charset:%s is not valid in locale, charset remains:%s", charset, tsCharset);
|
tscPrint("charset:%s is not valid in locale, charset remains:%s", charset, tsCharset);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(charset);
|
free(charset);
|
||||||
} else {
|
} else { // it may be windows system
|
||||||
tscPrint("charset remains:%s", tsCharset);
|
tscPrint("charset remains:%s", tsCharset);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -256,22 +265,24 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
|
||||||
/* set charset will override the value of charset, assigned during system locale changed */
|
/* set charset will override the value of charset, assigned during system locale changed */
|
||||||
pStr = (char *)arg;
|
pStr = (char *)arg;
|
||||||
|
|
||||||
char oldCharset[64] = {0};
|
|
||||||
strncpy(oldCharset, tsCharset, tListLen(oldCharset));
|
|
||||||
|
|
||||||
size_t len = strlen(pStr);
|
size_t len = strlen(pStr);
|
||||||
if (len == 0 || len > TSDB_LOCALE_LEN) {
|
if (len == 0 || len > TSDB_LOCALE_LEN) {
|
||||||
tscPrint("Invalid charset:%s, failed to set charset, current charset:%s", pStr, oldCharset);
|
tscPrint("failed to set charset:%s", pStr);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cfg_charset && cfg_charset->cfgStatus <= TSDB_CFG_CSTATUS_OPTION) {
|
if (cfg_charset && cfg_charset->cfgStatus <= TSDB_CFG_CSTATUS_OPTION) {
|
||||||
if (taosValidateEncodec(pStr)) {
|
if (taosValidateEncodec(pStr)) {
|
||||||
tscPrint("charset changed from %s to %s", tsCharset, pStr);
|
if (strlen(tsCharset) == 0) {
|
||||||
|
tscPrint("charset is set:%s", pStr);
|
||||||
|
} else {
|
||||||
|
tscPrint("charset changed from %s to %s", tsCharset, pStr);
|
||||||
|
}
|
||||||
|
|
||||||
strncpy(tsCharset, pStr, tListLen(tsCharset));
|
strncpy(tsCharset, pStr, tListLen(tsCharset));
|
||||||
cfg_charset->cfgStatus = TSDB_CFG_CSTATUS_OPTION;
|
cfg_charset->cfgStatus = TSDB_CFG_CSTATUS_OPTION;
|
||||||
} else {
|
} else {
|
||||||
tscPrint("charset:%s is not valid, charset remains:%s", pStr, tsCharset);
|
tscPrint("charset:%s not valid", pStr);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg_charset->option, pStr,
|
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg_charset->option, pStr,
|
||||||
|
|
|
@ -229,30 +229,24 @@ char *taosCharsetReplace(char *charsetstr) {
|
||||||
return strdup(charsetstr);
|
return strdup(charsetstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* POSIX format locale string:
|
||||||
|
* (Language Strings)_(Country/Region Strings).(code_page)
|
||||||
|
*
|
||||||
|
* example: en_US.UTF-8, zh_CN.GB18030, zh_CN.UTF-8,
|
||||||
|
*
|
||||||
|
* if user does not specify the locale in taos.cfg the program use default LC_CTYPE as system locale.
|
||||||
|
*
|
||||||
|
* In case of some CentOS systems, their default locale is "en_US.utf8", which is not valid code_page
|
||||||
|
* for libiconv that is employed to convert string in this system. This program will automatically use
|
||||||
|
* UTF-8 instead as the charset.
|
||||||
|
*
|
||||||
|
* In case of windows client, the locale string is not valid POSIX format, user needs to set the
|
||||||
|
* correct code_page for libiconv. Usually, the code_page of windows system with simple chinese is
|
||||||
|
* CP936, CP437 for English charset.
|
||||||
|
*
|
||||||
|
*/
|
||||||
void taosGetSystemLocale() { // get and set default locale
|
void taosGetSystemLocale() { // get and set default locale
|
||||||
/*
|
|
||||||
* POSIX format locale string:
|
|
||||||
* (Language Strings)_(Country/Region Strings).(code_page)
|
|
||||||
*
|
|
||||||
* example: en_US.UTF-8, zh_CN.GB18030, zh_CN.UTF-8,
|
|
||||||
*
|
|
||||||
* if user does not specify the locale in taos.cfg
|
|
||||||
* the program use default LC_CTYPE as system locale.
|
|
||||||
*
|
|
||||||
* In case of some CentOS systems, their default locale is "en_US.utf8", which
|
|
||||||
* is not
|
|
||||||
* valid code_page for libiconv that is employed to convert string in this
|
|
||||||
* system.
|
|
||||||
* User needs to specify the locale explicitly
|
|
||||||
* in config file in the correct format: en_US.UTF-8
|
|
||||||
*
|
|
||||||
* In case of windows client, the locale string is not legal POSIX format,
|
|
||||||
* user needs to
|
|
||||||
* set the correct code_page for libiconv. Usually, the code_page of windows
|
|
||||||
* system
|
|
||||||
* with simple chinese is CP936, CP437 for English locale.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
char sep = '.';
|
char sep = '.';
|
||||||
char *locale = NULL;
|
char *locale = NULL;
|
||||||
|
|
||||||
|
@ -262,7 +256,7 @@ void taosGetSystemLocale() { // get and set default locale
|
||||||
if (locale == NULL) {
|
if (locale == NULL) {
|
||||||
pError("can't get locale from system");
|
pError("can't get locale from system");
|
||||||
} else {
|
} else {
|
||||||
strncpy(tsLocale, locale, sizeof(tsLocale) / sizeof(tsLocale[0]));
|
strncpy(tsLocale, locale, tListLen(tsLocale));
|
||||||
pPrint("locale not configured, set to system default:%s", tsLocale);
|
pPrint("locale not configured, set to system default:%s", tsLocale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -275,7 +269,7 @@ void taosGetSystemLocale() { // get and set default locale
|
||||||
str++;
|
str++;
|
||||||
|
|
||||||
char *revisedCharset = taosCharsetReplace(str);
|
char *revisedCharset = taosCharsetReplace(str);
|
||||||
strncpy(tsCharset, revisedCharset, sizeof(tsCharset) / sizeof(tsCharset[0]));
|
strncpy(tsCharset, revisedCharset, tListLen(tsCharset));
|
||||||
|
|
||||||
free(revisedCharset);
|
free(revisedCharset);
|
||||||
pPrint("charset not configured, set to system default:%s", tsCharset);
|
pPrint("charset not configured, set to system default:%s", tsCharset);
|
||||||
|
|
Loading…
Reference in New Issue