From d8c19b880407713fd8ae5463d184a42059335a6e Mon Sep 17 00:00:00 2001 From: xiao-77 Date: Sat, 8 Feb 2025 10:42:15 +0800 Subject: [PATCH] Fix timezone case failed. --- include/os/osTimezone.h | 1 + source/os/src/osTimezone.c | 7 +++++++ source/util/src/tconfig.c | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/include/os/osTimezone.h b/include/os/osTimezone.h index f770a9dba0..10aed0a964 100644 --- a/include/os/osTimezone.h +++ b/include/os/osTimezone.h @@ -35,6 +35,7 @@ time_t mktime_z(timezone_t, struct tm *); timezone_t tzalloc(char const *); void tzfree(timezone_t); void getTimezoneStr(char *tz); +void truncateTimezoneString(char *tz); #endif diff --git a/source/os/src/osTimezone.c b/source/os/src/osTimezone.c index cad3f426f2..4b06930118 100644 --- a/source/os/src/osTimezone.c +++ b/source/os/src/osTimezone.c @@ -872,6 +872,13 @@ END: } #endif +void truncateTimezoneString(char *tz) { + char *spacePos = strchr(tz, ' '); + if (spacePos != NULL) { + *spacePos = '\0'; + } +} + int32_t taosGetSystemTimezone(char *outTimezoneStr) { #ifdef WINDOWS char value[100] = {0}; diff --git a/source/util/src/tconfig.c b/source/util/src/tconfig.c index 74d55b979a..a67015e11d 100644 --- a/source/util/src/tconfig.c +++ b/source/util/src/tconfig.c @@ -134,7 +134,14 @@ int32_t cfgUpdateFromArray(SConfig *pCfg, SArray *pArgs) { break; case CFG_DTYPE_LOCALE: case CFG_DTYPE_CHARSET: + code = cfgSetItemVal(pItemOld, pItemNew->name, pItemNew->str, pItemNew->stype); + if (code != TSDB_CODE_SUCCESS) { + (void)taosThreadMutexUnlock(&pCfg->lock); + TAOS_RETURN(code); + } + break; case CFG_DTYPE_TIMEZONE: + truncateTimezoneString(pItemNew->str); code = cfgSetItemVal(pItemOld, pItemNew->name, pItemNew->str, pItemNew->stype); if (code != TSDB_CODE_SUCCESS) { (void)taosThreadMutexUnlock(&pCfg->lock);