Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f6597c37
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f6597c37
编写于
4月 19, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: make taos_options work
上级
e867adc4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
35 addition
and
147 deletion
+35
-147
include/common/tglobal.h
include/common/tglobal.h
+0
-1
include/util/tconfig.h
include/util/tconfig.h
+1
-0
source/client/src/clientEnv.c
source/client/src/clientEnv.c
+32
-146
source/util/src/tconfig.c
source/util/src/tconfig.c
+2
-0
未找到文件。
include/common/tglobal.h
浏览文件 @
f6597c37
...
...
@@ -130,7 +130,6 @@ void taosCfgDynamicOptions(const char *option, const char *value);
void
taosAddDataDir
(
int32_t
index
,
char
*
v1
,
int32_t
level
,
int32_t
primary
);
struct
SConfig
*
taosGetCfg
();
int32_t
taosAddClientLogCfg
(
SConfig
*
pCfg
);
#ifdef __cplusplus
}
...
...
include/util/tconfig.h
浏览文件 @
f6597c37
...
...
@@ -32,6 +32,7 @@ typedef enum {
CFG_STYPE_ENV_VAR
,
CFG_STYPE_APOLLO_URL
,
CFG_STYPE_ARG_LIST
,
CFG_STYPE_TAOS_OPTIONS
}
ECfgSrcType
;
typedef
enum
{
...
...
source/client/src/clientEnv.c
浏览文件 @
f6597c37
...
...
@@ -307,164 +307,50 @@ int taos_init() {
}
int
taos_options_imp
(
TSDB_OPTION
option
,
const
char
*
str
)
{
#if 0
SGlobalCfg *cfg = NULL;
if
(
option
!=
TSDB_OPTION_CONFIGDIR
)
{
taos_init
();
// initialize global config
}
else
{
tstrncpy
(
configDir
,
str
,
PATH_MAX
);
tscInfo
(
"set cfg:%s to %s"
,
configDir
,
str
);
return
0
;
}
SConfig
*
pCfg
=
taosGetCfg
();
SConfigItem
*
pItem
=
NULL
;
switch
(
option
)
{
case
TSDB_OPTION_CONFIGDIR
:
cfg = taosGetConfigOption("configDir");
assert(cfg != NULL);
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_OPTION) {
tstrncpy(configDir, str, TSDB_FILENAME_LEN);
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
tscInfo("set config file directory:%s", str);
} else {
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, str,
tsCfgStatusStr[cfg->cfgStatus], (char *)cfg->ptr);
}
pItem
=
cfgGetItem
(
pCfg
,
"configDir"
);
break
;
case
TSDB_OPTION_SHELL_ACTIVITY_TIMER
:
cfg = taosGetConfigOption("shellActivityTimer");
assert(cfg != NULL);
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_OPTION) {
tsShellActivityTimer = atoi(str);
if (tsShellActivityTimer < 1) tsShellActivityTimer = 1;
if (tsShellActivityTimer > 3600) tsShellActivityTimer = 3600;
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
tscInfo("set shellActivityTimer:%d", tsShellActivityTimer);
} else {
tscWarn("config option:%s, input value:%s, is configured by %s, use %d", cfg->option, str,
tsCfgStatusStr[cfg->cfgStatus], *(int32_t *)cfg->ptr);
}
pItem
=
cfgGetItem
(
pCfg
,
"shellActivityTimer"
);
break
;
case TSDB_OPTION_LOCALE: { // set locale
cfg = taosGetConfigOption("locale");
assert(cfg != NULL);
size_t len = strlen(str);
if (len == 0 || len > TD_LOCALE_LEN) {
tscInfo("Invalid locale:%s, use default", str);
return -1;
}
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_OPTION) {
char sep = '.';
if (strlen(tsLocale) == 0) { // locale does not set yet
char *defaultLocale = setlocale(LC_CTYPE, "");
// The locale of the current OS does not be set correctly, so the default locale cannot be acquired.
// The launch of current system will abort soon.
if (defaultLocale == NULL) {
tscError("failed to get default locale, please set the correct locale in current OS");
return -1;
}
tstrncpy(tsLocale, defaultLocale, TD_LOCALE_LEN);
}
// set the user specified locale
char *locale = setlocale(LC_CTYPE, str);
if (locale != NULL) { // failed to set the user specified locale
tscInfo("locale set, prev locale:%s, new locale:%s", tsLocale, locale);
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
} else { // set the user specified locale failed, use default LC_CTYPE as current locale
locale = setlocale(LC_CTYPE, tsLocale);
tscInfo("failed to set locale:%s, current locale:%s", str, tsLocale);
}
tstrncpy(tsLocale, locale, TD_LOCALE_LEN);
char *charset = strrchr(tsLocale, sep);
if (charset != NULL) {
charset += 1;
charset = taosCharsetReplace(charset);
if (taosValidateEncodec(charset)) {
if (strlen(tsCharset) == 0) {
tscInfo("charset set:%s", charset);
} else {
tscInfo("charset changed from %s to %s", tsCharset, charset);
}
tstrncpy(tsCharset, charset, TD_LOCALE_LEN);
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
} else {
tscInfo("charset:%s is not valid in locale, charset remains:%s", charset, tsCharset);
}
taosMemoryFree(charset);
} else { // it may be windows system
tscInfo("charset remains:%s", tsCharset);
}
} else {
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, str,
tsCfgStatusStr[cfg->cfgStatus], (char *)cfg->ptr);
}
case
TSDB_OPTION_LOCALE
:
pItem
=
cfgGetItem
(
pCfg
,
"locale"
);
break
;
}
case TSDB_OPTION_CHARSET: {
/* set charset will override the value of charset, assigned during system locale changed */
cfg = taosGetConfigOption("charset");
assert(cfg != NULL);
size_t len = strlen(str);
if (len == 0 || len > TD_LOCALE_LEN) {
tscInfo("failed to set charset:%s", str);
return -1;
}
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_OPTION) {
if (taosValidateEncodec(str)) {
if (strlen(tsCharset) == 0) {
tscInfo("charset is set:%s", str);
} else {
tscInfo("charset changed from %s to %s", tsCharset, str);
}
tstrncpy(tsCharset, str, TD_LOCALE_LEN);
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
} else {
tscInfo("charset:%s not valid", str);
}
} else {
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, str,
tsCfgStatusStr[cfg->cfgStatus], (char *)cfg->ptr);
}
case
TSDB_OPTION_CHARSET
:
pItem
=
cfgGetItem
(
pCfg
,
"charset"
);
break
;
}
case
TSDB_OPTION_TIMEZONE
:
cfg = taosGetConfigOption("timezone");
assert(cfg != NULL);
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_OPTION) {
tstrncpy(tsTimezoneStr, str, TD_TIMEZONE_LEN);
tsSetTimeZone();
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
tscDebug("timezone set:%s, input:%s by taos_options", tsTimezoneStr, str);
} else {
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, str,
tsCfgStatusStr[cfg->cfgStatus], (char *)cfg->ptr);
}
pItem
=
cfgGetItem
(
pCfg
,
"timezone"
);
break
;
default:
// TODO return the correct error code to client in the format for taos_errstr()
tscError("Invalid option %d", option);
return -1;
break
;
}
#endif
return
0
;
if
(
pItem
==
NULL
)
{
tscError
(
"Invalid option %d"
,
option
);
return
-
1
;
}
int
code
=
cfgSetItem
(
pCfg
,
pItem
->
name
,
str
,
CFG_STYPE_TAOS_OPTIONS
);
if
(
code
!=
0
)
{
tscError
(
"failed to set cfg:%s to %s since %s"
,
pItem
->
name
,
str
,
terrstr
());
}
else
{
tscInfo
(
"set cfg:%s to %s"
,
pItem
->
name
,
str
);
}
return
code
;
}
/**
...
...
source/util/src/tconfig.c
浏览文件 @
f6597c37
...
...
@@ -472,6 +472,8 @@ const char *cfgStypeStr(ECfgSrcType type) {
return
"apollo_url"
;
case
CFG_STYPE_ARG_LIST
:
return
"arg_list"
;
case
CFG_STYPE_TAOS_OPTIONS
:
return
"taos_options"
;
default:
return
"invalid"
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录