Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f8b19dea
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看板
提交
f8b19dea
编写于
9月 02, 2021
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-5992] modify return msg
上级
04a0fb05
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
61 addition
and
12 deletion
+61
-12
src/client/src/tscSystem.c
src/client/src/tscSystem.c
+28
-9
src/client/tests/setConfigTest.cpp
src/client/tests/setConfigTest.cpp
+27
-2
src/inc/taos.h
src/inc/taos.h
+6
-1
未找到文件。
src/client/src/tscSystem.c
浏览文件 @
f8b19dea
...
...
@@ -439,30 +439,49 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
}
#include "cJSON.h"
static
int
taos_set_config_imp
(
const
char
*
config
){
static
setConfRet
taos_set_config_imp
(
const
char
*
config
){
setConfRet
ret
=
{
0
};
static
bool
setConfFlag
=
false
;
if
(
setConfFlag
)
{
return
0
;
ret
.
retCode
=
-
5
;
strcpy
(
ret
.
retMsg
,
"configuration can only set once"
);
return
ret
;
}
taosInitGlobalCfg
();
cJSON
*
root
=
cJSON_Parse
(
config
);
if
(
root
==
NULL
||
!
cJSON_IsObject
(
root
)
||
cJSON_GetArraySize
(
root
)
==
0
)
{
return
-
1
;
if
(
root
==
NULL
){
ret
.
retCode
=
-
4
;
strcpy
(
ret
.
retMsg
,
"parse json error"
);
return
ret
;
}
if
(
!
cJSON_IsObject
(
root
)
||
cJSON_GetArraySize
(
root
)
==
0
)
{
ret
.
retCode
=
-
3
;
strcpy
(
ret
.
retMsg
,
"json content is invalid, must be not empty object"
);
return
ret
;
}
int
ret
=
0
;
int
size
=
cJSON_GetArraySize
(
root
);
for
(
int
i
=
0
;
i
<
size
;
i
++
){
cJSON
*
item
=
cJSON_GetArrayItem
(
root
,
i
);
if
(
item
&&
!
taosReadConfigOption
(
item
->
string
,
item
->
valuestring
,
NULL
,
NULL
,
TAOS_CFG_CSTATUS_OPTION
,
TSDB_CFG_CTYPE_B_CLIENT
)){
ret
=
-
2
;
if
(
!
item
)
{
ret
.
retCode
=
-
2
;
strcpy
(
ret
.
retMsg
,
"inner error"
);
return
ret
;
}
if
(
!
taosReadConfigOption
(
item
->
string
,
item
->
valuestring
,
NULL
,
NULL
,
TAOS_CFG_CSTATUS_OPTION
,
TSDB_CFG_CTYPE_B_CLIENT
)){
ret
.
retCode
=
-
1
;
if
(
strlen
(
ret
.
retMsg
)
==
0
){
sprintf
(
ret
.
retMsg
,
"part error|%s"
,
item
->
string
);
}
else
{
sprintf
(
ret
.
retMsg
,
"%s|%s"
,
ret
.
retMsg
,
item
->
string
);
}
}
}
setConfFlag
=
true
;
return
ret
;
}
in
t
taos_set_config
(
const
char
*
config
){
setConfRe
t
taos_set_config
(
const
char
*
config
){
static
int32_t
lock
=
0
;
for
(
int
i
=
1
;
atomic_val_compare_exchange_32
(
&
lock
,
0
,
1
)
!=
0
;
++
i
)
{
...
...
@@ -471,7 +490,7 @@ int taos_set_config(const char *config){
sched_yield
();
}
}
in
t
ret
=
taos_set_config_imp
(
config
);
setConfRe
t
ret
=
taos_set_config_imp
(
config
);
atomic_store_32
(
&
lock
,
0
);
return
ret
;
}
src/client/tests/setConfigTest.cpp
浏览文件 @
f8b19dea
...
...
@@ -8,10 +8,14 @@
/* test set config function */
TEST
(
testCase
,
set_config_test1
)
{
const
char
*
config
=
"{
\"
debugFlag
\"
:
\"
131
\"
}"
;
taos_set_config
(
config
);
setConfRet
ret
=
taos_set_config
(
config
);
ASSERT_EQ
(
ret
.
retCode
,
0
);
printf
(
"msg:%d->%s"
,
ret
.
retCode
,
ret
.
retMsg
);
const
char
*
config2
=
"{
\"
debugFlag
\"
:
\"
199
\"
}"
;
taos_set_config
(
config2
);
// not take effect
ret
=
taos_set_config
(
config2
);
// not take effect
ASSERT_EQ
(
ret
.
retCode
,
-
5
)
printf
(
"msg:%d->%s"
,
ret
.
retCode
,
ret
.
retMsg
);
bool
readResult
=
taosReadGlobalCfg
();
// load file config, debugFlag not take effect
ASSERT_TRUE
(
readResult
);
...
...
@@ -37,3 +41,24 @@ TEST(testCase, set_config_test2) {
int32_t
result
=
*
(
int32_t
*
)
cfg
->
ptr
;
ASSERT_NE
(
result
,
10
);
// numOfCommitThreads not type of TSDB_CFG_CTYPE_B_CLIENT
}
TEST
(
testCase
,
set_config_test3
)
{
const
char
*
config
=
"{
\"
numOfCoitThreads
\"
:
\"
10
\"
,
\"
esdfa
\"
:
\"
10
\"
}"
;
setConfRet
ret
=
taos_set_config
(
config
);
ASSERT_EQ
(
ret
.
retCode
,
-
1
);
printf
(
"msg:%d->%s"
,
ret
.
retCode
,
ret
.
retMsg
);
}
TEST
(
testCase
,
set_config_test4
)
{
const
char
*
config
=
"{null}"
;
setConfRet
ret
=
taos_set_config
(
config
);
ASSERT_EQ
(
ret
.
retCode
,
-
4
);
printf
(
"msg:%d->%s"
,
ret
.
retCode
,
ret
.
retMsg
);
}
TEST
(
testCase
,
set_config_test5
)
{
const
char
*
config
=
"ddd"
;
setConfRet
ret
=
taos_set_config
(
config
);
ASSERT_EQ
(
ret
.
retCode
,
-
3
);
printf
(
"msg:%d->%s"
,
ret
.
retCode
,
ret
.
retMsg
);
}
src/inc/taos.h
浏览文件 @
f8b19dea
...
...
@@ -62,6 +62,11 @@ typedef struct taosField {
int16_t
bytes
;
}
TAOS_FIELD
;
typedef
struct
setConfRet
{
char
retMsg
[
1024
];
int8_t
retCode
;
}
setConfRet
;
#ifdef _TD_GO_DLL_
#define DLL_EXPORT __declspec(dllexport)
#else
...
...
@@ -71,7 +76,7 @@ typedef struct taosField {
DLL_EXPORT
int
taos_init
();
DLL_EXPORT
void
taos_cleanup
(
void
);
DLL_EXPORT
int
taos_options
(
TSDB_OPTION
option
,
const
void
*
arg
,
...);
DLL_EXPORT
in
t
taos_set_config
(
const
char
*
config
);
DLL_EXPORT
setConfRe
t
taos_set_config
(
const
char
*
config
);
DLL_EXPORT
TAOS
*
taos_connect
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
db
,
uint16_t
port
);
DLL_EXPORT
TAOS
*
taos_connect_auth
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
);
DLL_EXPORT
void
taos_close
(
TAOS
*
taos
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录