Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cbe03ef2
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看板
未验证
提交
cbe03ef2
编写于
7月 19, 2023
作者:
D
dapan1121
提交者:
GitHub
7月 19, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #22069 from taosdata/enh/TS-2288
enh: add scope for show xx variables
上级
fc905aea
36be0918
变更
16
展开全部
隐藏空白更改
内联
并排
Showing
16 changed file
with
260 addition
and
193 deletion
+260
-193
docs/en/14-reference/12-config/index.md
docs/en/14-reference/12-config/index.md
+2
-2
docs/zh/14-reference/12-config/index.md
docs/zh/14-reference/12-config/index.md
+2
-2
include/common/tmsg.h
include/common/tmsg.h
+1
-0
include/libs/nodes/cmdnodes.h
include/libs/nodes/cmdnodes.h
+2
-1
include/util/tconfig.h
include/util/tconfig.h
+18
-11
include/util/tdef.h
include/util/tdef.h
+1
-0
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+2
-1
source/client/src/clientMsgHandler.c
source/client/src/clientMsgHandler.c
+9
-1
source/common/src/systable.c
source/common/src/systable.c
+1
-0
source/common/src/tglobal.c
source/common/src/tglobal.c
+153
-154
source/common/src/tmsg.c
source/common/src/tmsg.c
+2
-0
source/dnode/mgmt/mgmt_dnode/src/dmHandle.c
source/dnode/mgmt/mgmt_dnode/src/dmHandle.c
+6
-0
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+4
-0
source/libs/command/src/command.c
source/libs/command/src/command.c
+12
-1
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+5
-1
source/util/src/tconfig.c
source/util/src/tconfig.c
+40
-19
未找到文件。
docs/en/14-reference/12-config/index.md
浏览文件 @
cbe03ef2
...
...
@@ -166,7 +166,7 @@ Please note the `taoskeeper` needs to be installed and running to create the `lo
| Attribute | Description |
| ------------- | ---------------------------------------------------------------------------- |
| Applicable | Server
Only
|
| Applicable | Server
and Client
|
| Meaning | Switch for allowing TDengine to collect and report service usage information |
| Value Range | 0: Not allowed; 1: Allowed |
| Default Value | 1 |
...
...
@@ -174,7 +174,7 @@ Please note the `taoskeeper` needs to be installed and running to create the `lo
| Attribute | Description |
| ------------- | ---------------------------------------------------------------------------- |
| Applicable | Server
Only
|
| Applicable | Server
and Client
|
| Meaning | Switch for allowing TDengine to collect and report crash related information |
| Value Range | 0,1 0: Not allowed; 1: allowed |
| Default Value | 1 |
...
...
docs/zh/14-reference/12-config/index.md
浏览文件 @
cbe03ef2
...
...
@@ -184,7 +184,7 @@ taos -C
| 属性 | 说明 |
| -------- | ------------------------ |
| 适用范围 |
仅服务端适用
|
| 适用范围 |
客户端和服务端都适用
|
| 含义 | 是否上传 telemetry |
| 取值范围 | 0,1 0: 不上传;1:上传 |
| 缺省值 | 1 |
...
...
@@ -193,7 +193,7 @@ taos -C
| 属性 | 说明 |
| -------- | ------------------------ |
| 适用范围 |
仅服务端适用
|
| 适用范围 |
客户端和服务端都适用
|
| 含义 | 是否上传 crash 信息 |
| 取值范围 | 0,1 0: 不上传;1:上传 |
| 缺省值 | 1 |
...
...
include/common/tmsg.h
浏览文件 @
cbe03ef2
...
...
@@ -1495,6 +1495,7 @@ int32_t tDeserializeSShowVariablesReq(void* buf, int32_t bufLen, SShowVariablesR
typedef
struct
{
char
name
[
TSDB_CONFIG_OPTION_LEN
+
1
];
char
value
[
TSDB_CONFIG_VALUE_LEN
+
1
];
char
scope
[
TSDB_CONFIG_SCOPE_LEN
+
1
];
}
SVariablesInfo
;
typedef
struct
{
...
...
include/libs/nodes/cmdnodes.h
浏览文件 @
cbe03ef2
...
...
@@ -36,9 +36,10 @@ extern "C" {
#define SHOW_CREATE_TB_RESULT_FIELD1_LEN (TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE)
#define SHOW_CREATE_TB_RESULT_FIELD2_LEN (TSDB_MAX_ALLOWED_SQL_LEN * 3)
#define SHOW_LOCAL_VARIABLES_RESULT_COLS
2
#define SHOW_LOCAL_VARIABLES_RESULT_COLS
3
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD1_LEN (TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE)
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD2_LEN (TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE)
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD3_LEN (TSDB_CONFIG_SCOPE_LEN + VARSTR_HEADER_SIZE)
#define SHOW_ALIVE_RESULT_COLS 1
...
...
include/util/tconfig.h
浏览文件 @
cbe03ef2
...
...
@@ -50,11 +50,17 @@ typedef enum {
CFG_DTYPE_TIMEZONE
}
ECfgDataType
;
typedef
enum
{
CFG_SCOPE_SERVER
,
CFG_SCOPE_CLIENT
,
CFG_SCOPE_BOTH
}
ECfgScopeType
;
typedef
struct
SConfigItem
{
ECfgSrcType
stype
;
ECfgDataType
dtype
;
bool
tsc
;
char
*
name
;
int8_t
scope
;
char
*
name
;
union
{
bool
bval
;
float
fval
;
...
...
@@ -92,20 +98,21 @@ int32_t cfgGetSize(SConfig *pCfg);
SConfigItem
*
cfgGetItem
(
SConfig
*
pCfg
,
const
char
*
name
);
int32_t
cfgSetItem
(
SConfig
*
pCfg
,
const
char
*
name
,
const
char
*
value
,
ECfgSrcType
stype
);
int32_t
cfgAddBool
(
SConfig
*
pCfg
,
const
char
*
name
,
bool
defaultVal
,
bool
tsc
);
int32_t
cfgAddInt32
(
SConfig
*
pCfg
,
const
char
*
name
,
int32_t
defaultVal
,
int64_t
minval
,
int64_t
maxval
,
bool
tsc
);
int32_t
cfgAddInt64
(
SConfig
*
pCfg
,
const
char
*
name
,
int64_t
defaultVal
,
int64_t
minval
,
int64_t
maxval
,
bool
tsc
);
int32_t
cfgAddFloat
(
SConfig
*
pCfg
,
const
char
*
name
,
float
defaultVal
,
double
minval
,
double
maxval
,
bool
tsc
);
int32_t
cfgAddString
(
SConfig
*
pCfg
,
const
char
*
name
,
const
char
*
defaultVal
,
bool
tsc
);
int32_t
cfgAddDir
(
SConfig
*
pCfg
,
const
char
*
name
,
const
char
*
defaultVal
,
bool
tsc
);
int32_t
cfgAddLocale
(
SConfig
*
pCfg
,
const
char
*
name
,
const
char
*
defaultVal
);
int32_t
cfgAddCharset
(
SConfig
*
pCfg
,
const
char
*
name
,
const
char
*
defaultVal
);
int32_t
cfgAddTimezone
(
SConfig
*
pCfg
,
const
char
*
name
,
const
char
*
defaultVal
);
int32_t
cfgAddBool
(
SConfig
*
pCfg
,
const
char
*
name
,
bool
defaultVal
,
int8_t
scope
);
int32_t
cfgAddInt32
(
SConfig
*
pCfg
,
const
char
*
name
,
int32_t
defaultVal
,
int64_t
minval
,
int64_t
maxval
,
int8_t
scope
);
int32_t
cfgAddInt64
(
SConfig
*
pCfg
,
const
char
*
name
,
int64_t
defaultVal
,
int64_t
minval
,
int64_t
maxval
,
int8_t
scope
);
int32_t
cfgAddFloat
(
SConfig
*
pCfg
,
const
char
*
name
,
float
defaultVal
,
double
minval
,
double
maxval
,
int8_t
scope
);
int32_t
cfgAddString
(
SConfig
*
pCfg
,
const
char
*
name
,
const
char
*
defaultVal
,
int8_t
scope
);
int32_t
cfgAddDir
(
SConfig
*
pCfg
,
const
char
*
name
,
const
char
*
defaultVal
,
int8_t
scope
);
int32_t
cfgAddLocale
(
SConfig
*
pCfg
,
const
char
*
name
,
const
char
*
defaultVal
,
int8_t
scope
);
int32_t
cfgAddCharset
(
SConfig
*
pCfg
,
const
char
*
name
,
const
char
*
defaultVal
,
int8_t
scope
);
int32_t
cfgAddTimezone
(
SConfig
*
pCfg
,
const
char
*
name
,
const
char
*
defaultVal
,
int8_t
scope
);
const
char
*
cfgStypeStr
(
ECfgSrcType
type
);
const
char
*
cfgDtypeStr
(
ECfgDataType
type
);
void
cfgDumpItemValue
(
SConfigItem
*
pItem
,
char
*
buf
,
int32_t
bufSize
,
int32_t
*
pLen
);
void
cfgDumpItemScope
(
SConfigItem
*
pItem
,
char
*
buf
,
int32_t
bufSize
,
int32_t
*
pLen
);
void
cfgDumpCfg
(
SConfig
*
pCfg
,
bool
tsc
,
bool
dump
);
...
...
include/util/tdef.h
浏览文件 @
cbe03ef2
...
...
@@ -492,6 +492,7 @@ enum {
#define TSDB_CONFIG_OPTION_LEN 32
#define TSDB_CONFIG_VALUE_LEN 64
#define TSDB_CONFIG_SCOPE_LEN 8
#define TSDB_CONFIG_NUMBER 8
#define QUERY_ID_SIZE 20
...
...
source/client/inc/clientInt.h
浏览文件 @
cbe03ef2
...
...
@@ -46,9 +46,10 @@ enum {
RES_TYPE__TMQ_METADATA
,
};
#define SHOW_VARIABLES_RESULT_COLS
2
#define SHOW_VARIABLES_RESULT_COLS
3
#define SHOW_VARIABLES_RESULT_FIELD1_LEN (TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE)
#define SHOW_VARIABLES_RESULT_FIELD2_LEN (TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE)
#define SHOW_VARIABLES_RESULT_FIELD3_LEN (TSDB_CONFIG_SCOPE_LEN + VARSTR_HEADER_SIZE)
#define TD_RES_QUERY(res) (*(int8_t*)res == RES_TYPE__QUERY)
#define TD_RES_TMQ(res) (*(int8_t*)res == RES_TYPE__TMQ)
...
...
source/client/src/clientMsgHandler.c
浏览文件 @
cbe03ef2
...
...
@@ -428,13 +428,16 @@ static int32_t buildShowVariablesBlock(SArray* pVars, SSDataBlock** block) {
SColumnInfoData
infoData
=
{
0
};
infoData
.
info
.
type
=
TSDB_DATA_TYPE_VARCHAR
;
infoData
.
info
.
bytes
=
SHOW_VARIABLES_RESULT_FIELD1_LEN
;
taosArrayPush
(
pBlock
->
pDataBlock
,
&
infoData
);
infoData
.
info
.
type
=
TSDB_DATA_TYPE_VARCHAR
;
infoData
.
info
.
bytes
=
SHOW_VARIABLES_RESULT_FIELD2_LEN
;
taosArrayPush
(
pBlock
->
pDataBlock
,
&
infoData
);
infoData
.
info
.
type
=
TSDB_DATA_TYPE_VARCHAR
;
infoData
.
info
.
bytes
=
SHOW_VARIABLES_RESULT_FIELD3_LEN
;
taosArrayPush
(
pBlock
->
pDataBlock
,
&
infoData
);
int32_t
numOfCfg
=
taosArrayGetSize
(
pVars
);
blockDataEnsureCapacity
(
pBlock
,
numOfCfg
);
...
...
@@ -450,6 +453,11 @@ static int32_t buildShowVariablesBlock(SArray* pVars, SSDataBlock** block) {
STR_WITH_MAXSIZE_TO_VARSTR
(
value
,
pInfo
->
value
,
TSDB_CONFIG_VALUE_LEN
+
VARSTR_HEADER_SIZE
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
c
++
);
colDataSetVal
(
pColInfo
,
i
,
value
,
false
);
char
scope
[
TSDB_CONFIG_SCOPE_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
scope
,
pInfo
->
scope
,
TSDB_CONFIG_SCOPE_LEN
+
VARSTR_HEADER_SIZE
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
c
++
);
colDataSetVal
(
pColInfo
,
i
,
scope
,
false
);
}
pBlock
->
info
.
rows
=
numOfCfg
;
...
...
source/common/src/systable.c
浏览文件 @
cbe03ef2
...
...
@@ -271,6 +271,7 @@ static const SSysDbTableSchema variablesSchema[] = {
{.
name
=
"dnode_id"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"name"
,
.
bytes
=
TSDB_CONFIG_OPTION_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
true
},
{.
name
=
"value"
,
.
bytes
=
TSDB_CONFIG_VALUE_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
true
},
{.
name
=
"scope"
,
.
bytes
=
TSDB_CONFIG_SCOPE_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
true
},
};
static
const
SSysDbTableSchema
topicSchema
[]
=
{
...
...
source/common/src/tglobal.c
浏览文件 @
cbe03ef2
此差异已折叠。
点击以展开。
source/common/src/tmsg.c
浏览文件 @
cbe03ef2
...
...
@@ -3484,12 +3484,14 @@ int32_t tDeserializeSShowVariablesReq(void *buf, int32_t bufLen, SShowVariablesR
int32_t
tEncodeSVariablesInfo
(
SEncoder
*
pEncoder
,
SVariablesInfo
*
pInfo
)
{
if
(
tEncodeCStr
(
pEncoder
,
pInfo
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pInfo
->
value
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pInfo
->
scope
)
<
0
)
return
-
1
;
return
0
;
}
int32_t
tDecodeSVariablesInfo
(
SDecoder
*
pDecoder
,
SVariablesInfo
*
pInfo
)
{
if
(
tDecodeCStrTo
(
pDecoder
,
pInfo
->
name
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
pDecoder
,
pInfo
->
value
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
pDecoder
,
pInfo
->
scope
)
<
0
)
return
-
1
;
return
0
;
}
...
...
source/dnode/mgmt/mgmt_dnode/src/dmHandle.c
浏览文件 @
cbe03ef2
...
...
@@ -265,6 +265,12 @@ int32_t dmAppendVariablesToBlock(SSDataBlock *pBlock, int32_t dnodeId) {
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
c
++
);
colDataSetVal
(
pColInfo
,
i
,
value
,
false
);
char
scope
[
TSDB_CONFIG_SCOPE_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
cfgDumpItemScope
(
pItem
,
&
scope
[
VARSTR_HEADER_SIZE
],
TSDB_CONFIG_SCOPE_LEN
,
&
valueLen
);
varDataSetLen
(
scope
,
valueLen
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
c
++
);
colDataSetVal
(
pColInfo
,
i
,
scope
,
false
);
numOfRows
++
;
}
...
...
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
cbe03ef2
...
...
@@ -785,18 +785,22 @@ static int32_t mndProcessShowVariablesReq(SRpcMsg *pReq) {
strcpy
(
info
.
name
,
"statusInterval"
);
snprintf
(
info
.
value
,
TSDB_CONFIG_VALUE_LEN
,
"%d"
,
tsStatusInterval
);
strcpy
(
info
.
scope
,
"server"
);
taosArrayPush
(
rsp
.
variables
,
&
info
);
strcpy
(
info
.
name
,
"timezone"
);
snprintf
(
info
.
value
,
TSDB_CONFIG_VALUE_LEN
,
"%s"
,
tsTimezoneStr
);
strcpy
(
info
.
scope
,
"both"
);
taosArrayPush
(
rsp
.
variables
,
&
info
);
strcpy
(
info
.
name
,
"locale"
);
snprintf
(
info
.
value
,
TSDB_CONFIG_VALUE_LEN
,
"%s"
,
tsLocale
);
strcpy
(
info
.
scope
,
"both"
);
taosArrayPush
(
rsp
.
variables
,
&
info
);
strcpy
(
info
.
name
,
"charset"
);
snprintf
(
info
.
value
,
TSDB_CONFIG_VALUE_LEN
,
"%s"
,
tsCharset
);
strcpy
(
info
.
scope
,
"both"
);
taosArrayPush
(
rsp
.
variables
,
&
info
);
int32_t
rspLen
=
tSerializeSShowVariablesRsp
(
NULL
,
0
,
&
rsp
);
...
...
source/libs/command/src/command.c
浏览文件 @
cbe03ef2
...
...
@@ -802,15 +802,19 @@ static int32_t buildLocalVariablesResultDataBlock(SSDataBlock** pOutput) {
pBlock
->
pDataBlock
=
taosArrayInit
(
SHOW_LOCAL_VARIABLES_RESULT_COLS
,
sizeof
(
SColumnInfoData
));
SColumnInfoData
infoData
=
{
0
};
infoData
.
info
.
type
=
TSDB_DATA_TYPE_VARCHAR
;
infoData
.
info
.
bytes
=
SHOW_LOCAL_VARIABLES_RESULT_FIELD1_LEN
;
taosArrayPush
(
pBlock
->
pDataBlock
,
&
infoData
);
infoData
.
info
.
type
=
TSDB_DATA_TYPE_VARCHAR
;
infoData
.
info
.
bytes
=
SHOW_LOCAL_VARIABLES_RESULT_FIELD2_LEN
;
taosArrayPush
(
pBlock
->
pDataBlock
,
&
infoData
);
infoData
.
info
.
type
=
TSDB_DATA_TYPE_VARCHAR
;
infoData
.
info
.
bytes
=
SHOW_LOCAL_VARIABLES_RESULT_FIELD3_LEN
;
taosArrayPush
(
pBlock
->
pDataBlock
,
&
infoData
);
*
pOutput
=
pBlock
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -823,6 +827,7 @@ int32_t setLocalVariablesResultIntoDataBlock(SSDataBlock* pBlock) {
for
(
int32_t
i
=
0
,
c
=
0
;
i
<
numOfCfg
;
++
i
,
c
=
0
)
{
SConfigItem
*
pItem
=
taosArrayGet
(
tsCfg
->
array
,
i
);
GRANT_CFG_SKIP
;
char
name
[
TSDB_CONFIG_OPTION_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
name
,
pItem
->
name
,
TSDB_CONFIG_OPTION_LEN
+
VARSTR_HEADER_SIZE
);
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
c
++
);
...
...
@@ -835,6 +840,12 @@ int32_t setLocalVariablesResultIntoDataBlock(SSDataBlock* pBlock) {
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
c
++
);
colDataSetVal
(
pColInfo
,
i
,
value
,
false
);
char
scope
[
TSDB_CONFIG_SCOPE_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
cfgDumpItemScope
(
pItem
,
&
scope
[
VARSTR_HEADER_SIZE
],
TSDB_CONFIG_SCOPE_LEN
,
&
valueLen
);
varDataSetLen
(
scope
,
valueLen
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
c
++
);
colDataSetVal
(
pColInfo
,
i
,
scope
,
false
);
numOfRows
++
;
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
cbe03ef2
...
...
@@ -7719,7 +7719,7 @@ static int32_t extractShowCreateTableResultSchema(int32_t* numOfCols, SSchema**
}
static
int32_t
extractShowVariablesResultSchema
(
int32_t
*
numOfCols
,
SSchema
**
pSchema
)
{
*
numOfCols
=
2
;
*
numOfCols
=
3
;
*
pSchema
=
taosMemoryCalloc
((
*
numOfCols
),
sizeof
(
SSchema
));
if
(
NULL
==
(
*
pSchema
))
{
return
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -7733,6 +7733,10 @@ static int32_t extractShowVariablesResultSchema(int32_t* numOfCols, SSchema** pS
(
*
pSchema
)[
1
].
bytes
=
TSDB_CONFIG_VALUE_LEN
;
strcpy
((
*
pSchema
)[
1
].
name
,
"value"
);
(
*
pSchema
)[
2
].
type
=
TSDB_DATA_TYPE_BINARY
;
(
*
pSchema
)[
2
].
bytes
=
TSDB_CONFIG_SCOPE_LEN
;
strcpy
((
*
pSchema
)[
2
].
name
,
"scope"
);
return
TSDB_CODE_SUCCESS
;
}
...
...
source/util/src/tconfig.c
浏览文件 @
cbe03ef2
...
...
@@ -380,43 +380,43 @@ static int32_t cfgAddItem(SConfig *pCfg, SConfigItem *pItem, const char *name) {
return
0
;
}
int32_t
cfgAddBool
(
SConfig
*
pCfg
,
const
char
*
name
,
bool
defaultVal
,
bool
tsc
)
{
SConfigItem
item
=
{.
dtype
=
CFG_DTYPE_BOOL
,
.
bval
=
defaultVal
,
.
tsc
=
tsc
};
int32_t
cfgAddBool
(
SConfig
*
pCfg
,
const
char
*
name
,
bool
defaultVal
,
int8_t
scope
)
{
SConfigItem
item
=
{.
dtype
=
CFG_DTYPE_BOOL
,
.
bval
=
defaultVal
,
.
scope
=
scope
};
return
cfgAddItem
(
pCfg
,
&
item
,
name
);
}
int32_t
cfgAddInt32
(
SConfig
*
pCfg
,
const
char
*
name
,
int32_t
defaultVal
,
int64_t
minval
,
int64_t
maxval
,
bool
tsc
)
{
int32_t
cfgAddInt32
(
SConfig
*
pCfg
,
const
char
*
name
,
int32_t
defaultVal
,
int64_t
minval
,
int64_t
maxval
,
int8_t
scope
)
{
if
(
defaultVal
<
minval
||
defaultVal
>
maxval
)
{
terrno
=
TSDB_CODE_OUT_OF_RANGE
;
return
-
1
;
}
SConfigItem
item
=
{.
dtype
=
CFG_DTYPE_INT32
,
.
i32
=
defaultVal
,
.
imin
=
minval
,
.
imax
=
maxval
,
.
tsc
=
tsc
};
SConfigItem
item
=
{.
dtype
=
CFG_DTYPE_INT32
,
.
i32
=
defaultVal
,
.
imin
=
minval
,
.
imax
=
maxval
,
.
scope
=
scope
};
return
cfgAddItem
(
pCfg
,
&
item
,
name
);
}
int32_t
cfgAddInt64
(
SConfig
*
pCfg
,
const
char
*
name
,
int64_t
defaultVal
,
int64_t
minval
,
int64_t
maxval
,
bool
tsc
)
{
int32_t
cfgAddInt64
(
SConfig
*
pCfg
,
const
char
*
name
,
int64_t
defaultVal
,
int64_t
minval
,
int64_t
maxval
,
int8_t
scope
)
{
if
(
defaultVal
<
minval
||
defaultVal
>
maxval
)
{
terrno
=
TSDB_CODE_OUT_OF_RANGE
;
return
-
1
;
}
SConfigItem
item
=
{.
dtype
=
CFG_DTYPE_INT64
,
.
i64
=
defaultVal
,
.
imin
=
minval
,
.
imax
=
maxval
,
.
tsc
=
tsc
};
SConfigItem
item
=
{.
dtype
=
CFG_DTYPE_INT64
,
.
i64
=
defaultVal
,
.
imin
=
minval
,
.
imax
=
maxval
,
.
scope
=
scope
};
return
cfgAddItem
(
pCfg
,
&
item
,
name
);
}
int32_t
cfgAddFloat
(
SConfig
*
pCfg
,
const
char
*
name
,
float
defaultVal
,
double
minval
,
double
maxval
,
bool
tsc
)
{
int32_t
cfgAddFloat
(
SConfig
*
pCfg
,
const
char
*
name
,
float
defaultVal
,
double
minval
,
double
maxval
,
int8_t
scope
)
{
if
(
defaultVal
<
minval
||
defaultVal
>
maxval
)
{
terrno
=
TSDB_CODE_OUT_OF_RANGE
;
return
-
1
;
}
SConfigItem
item
=
{.
dtype
=
CFG_DTYPE_FLOAT
,
.
fval
=
defaultVal
,
.
fmin
=
minval
,
.
fmax
=
maxval
,
.
tsc
=
tsc
};
SConfigItem
item
=
{.
dtype
=
CFG_DTYPE_FLOAT
,
.
fval
=
defaultVal
,
.
fmin
=
minval
,
.
fmax
=
maxval
,
.
scope
=
scope
};
return
cfgAddItem
(
pCfg
,
&
item
,
name
);
}
int32_t
cfgAddString
(
SConfig
*
pCfg
,
const
char
*
name
,
const
char
*
defaultVal
,
bool
tsc
)
{
SConfigItem
item
=
{.
dtype
=
CFG_DTYPE_STRING
,
.
tsc
=
tsc
};
int32_t
cfgAddString
(
SConfig
*
pCfg
,
const
char
*
name
,
const
char
*
defaultVal
,
int8_t
scope
)
{
SConfigItem
item
=
{.
dtype
=
CFG_DTYPE_STRING
,
.
scope
=
scope
};
item
.
str
=
taosStrdup
(
defaultVal
);
if
(
item
.
str
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -425,8 +425,8 @@ int32_t cfgAddString(SConfig *pCfg, const char *name, const char *defaultVal, bo
return
cfgAddItem
(
pCfg
,
&
item
,
name
);
}
int32_t
cfgAddDir
(
SConfig
*
pCfg
,
const
char
*
name
,
const
char
*
defaultVal
,
bool
tsc
)
{
SConfigItem
item
=
{.
dtype
=
CFG_DTYPE_DIR
,
.
tsc
=
tsc
};
int32_t
cfgAddDir
(
SConfig
*
pCfg
,
const
char
*
name
,
const
char
*
defaultVal
,
int8_t
scope
)
{
SConfigItem
item
=
{.
dtype
=
CFG_DTYPE_DIR
,
.
scope
=
scope
};
if
(
cfgCheckAndSetDir
(
&
item
,
defaultVal
)
!=
0
)
{
return
-
1
;
}
...
...
@@ -434,8 +434,8 @@ int32_t cfgAddDir(SConfig *pCfg, const char *name, const char *defaultVal, bool
return
cfgAddItem
(
pCfg
,
&
item
,
name
);
}
int32_t
cfgAddLocale
(
SConfig
*
pCfg
,
const
char
*
name
,
const
char
*
defaultVal
)
{
SConfigItem
item
=
{.
dtype
=
CFG_DTYPE_LOCALE
,
.
tsc
=
1
};
int32_t
cfgAddLocale
(
SConfig
*
pCfg
,
const
char
*
name
,
const
char
*
defaultVal
,
int8_t
scope
)
{
SConfigItem
item
=
{.
dtype
=
CFG_DTYPE_LOCALE
,
.
scope
=
scope
};
if
(
cfgCheckAndSetLocale
(
&
item
,
defaultVal
)
!=
0
)
{
return
-
1
;
}
...
...
@@ -443,8 +443,8 @@ int32_t cfgAddLocale(SConfig *pCfg, const char *name, const char *defaultVal) {
return
cfgAddItem
(
pCfg
,
&
item
,
name
);
}
int32_t
cfgAddCharset
(
SConfig
*
pCfg
,
const
char
*
name
,
const
char
*
defaultVal
)
{
SConfigItem
item
=
{.
dtype
=
CFG_DTYPE_CHARSET
,
.
tsc
=
1
};
int32_t
cfgAddCharset
(
SConfig
*
pCfg
,
const
char
*
name
,
const
char
*
defaultVal
,
int8_t
scope
)
{
SConfigItem
item
=
{.
dtype
=
CFG_DTYPE_CHARSET
,
.
scope
=
scope
};
if
(
cfgCheckAndSetCharset
(
&
item
,
defaultVal
)
!=
0
)
{
return
-
1
;
}
...
...
@@ -452,8 +452,8 @@ int32_t cfgAddCharset(SConfig *pCfg, const char *name, const char *defaultVal) {
return
cfgAddItem
(
pCfg
,
&
item
,
name
);
}
int32_t
cfgAddTimezone
(
SConfig
*
pCfg
,
const
char
*
name
,
const
char
*
defaultVal
)
{
SConfigItem
item
=
{.
dtype
=
CFG_DTYPE_TIMEZONE
,
.
tsc
=
1
};
int32_t
cfgAddTimezone
(
SConfig
*
pCfg
,
const
char
*
name
,
const
char
*
defaultVal
,
int8_t
scope
)
{
SConfigItem
item
=
{.
dtype
=
CFG_DTYPE_TIMEZONE
,
.
scope
=
scope
};
if
(
cfgCheckAndSetTimezone
(
&
item
,
defaultVal
)
!=
0
)
{
return
-
1
;
}
...
...
@@ -543,6 +543,27 @@ void cfgDumpItemValue(SConfigItem *pItem, char *buf, int32_t bufSize, int32_t *p
*
pLen
=
len
;
}
void
cfgDumpItemScope
(
SConfigItem
*
pItem
,
char
*
buf
,
int32_t
bufSize
,
int32_t
*
pLen
)
{
int32_t
len
=
0
;
switch
(
pItem
->
scope
)
{
case
CFG_SCOPE_SERVER
:
len
=
snprintf
(
buf
,
bufSize
,
"server"
);
break
;
case
CFG_SCOPE_CLIENT
:
len
=
snprintf
(
buf
,
bufSize
,
"client"
);
break
;
case
CFG_SCOPE_BOTH
:
len
=
snprintf
(
buf
,
bufSize
,
"both"
);
break
;
}
if
(
len
>
bufSize
)
{
len
=
bufSize
;
}
*
pLen
=
len
;
}
void
cfgDumpCfg
(
SConfig
*
pCfg
,
bool
tsc
,
bool
dump
)
{
if
(
dump
)
{
printf
(
" global config"
);
...
...
@@ -560,7 +581,7 @@ void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) {
int32_t
size
=
taosArrayGetSize
(
pCfg
->
array
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SConfigItem
*
pItem
=
taosArrayGet
(
pCfg
->
array
,
i
);
if
(
tsc
&&
!
pItem
->
tsc
)
continue
;
if
(
tsc
&&
pItem
->
scope
==
CFG_SCOPE_SERVER
)
continue
;
if
(
dump
&&
strcmp
(
pItem
->
name
,
"scriptDir"
)
==
0
)
continue
;
if
(
dump
&&
strcmp
(
pItem
->
name
,
"simDebugFlag"
)
==
0
)
continue
;
tstrncpy
(
src
,
cfgStypeStr
(
pItem
->
stype
),
CFG_SRC_PRINT_LEN
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录