Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
55f100e2
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看板
提交
55f100e2
编写于
12月 10, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
差异文件
[td-10564] merge 3.0
上级
8c416a5e
044388b3
变更
76
展开全部
隐藏空白更改
内联
并排
Showing
76 changed file
with
5425 addition
and
1196 deletion
+5425
-1196
include/common/taosmsg.h
include/common/taosmsg.h
+111
-68
include/dnode/mnode/sdb/sdb.h
include/dnode/mnode/sdb/sdb.h
+30
-1
include/libs/wal/wal.h
include/libs/wal/wal.h
+22
-15
include/util/taoserror.h
include/util/taoserror.h
+31
-21
include/util/tarray.h
include/util/tarray.h
+7
-0
include/util/tdef.h
include/util/tdef.h
+30
-30
include/util/tfile.h
include/util/tfile.h
+2
-0
include/util/tmd5.h
include/util/tmd5.h
+4
-4
include/util/tutil.h
include/util/tutil.h
+18
-18
source/common/src/tglobal.c
source/common/src/tglobal.c
+0
-45
source/dnode/mgmt/impl/src/dndMnode.c
source/dnode/mgmt/impl/src/dndMnode.c
+7
-6
source/dnode/mgmt/impl/src/dndTransport.c
source/dnode/mgmt/impl/src/dndTransport.c
+2
-6
source/dnode/mgmt/impl/test/CMakeLists.txt
source/dnode/mgmt/impl/test/CMakeLists.txt
+5
-4
source/dnode/mgmt/impl/test/cluster/cluster.cpp
source/dnode/mgmt/impl/test/cluster/cluster.cpp
+3
-3
source/dnode/mgmt/impl/test/profile/profile.cpp
source/dnode/mgmt/impl/test/profile/profile.cpp
+14
-14
source/dnode/mgmt/impl/test/show/show.cpp
source/dnode/mgmt/impl/test/show/show.cpp
+7
-7
source/dnode/mgmt/impl/test/sut/deploy.cpp
source/dnode/mgmt/impl/test/sut/deploy.cpp
+0
-1
source/dnode/mgmt/impl/test/user/CMakeLists.txt
source/dnode/mgmt/impl/test/user/CMakeLists.txt
+29
-0
source/dnode/mgmt/impl/test/user/user.cpp
source/dnode/mgmt/impl/test/user/user.cpp
+407
-0
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+56
-64
source/dnode/mnode/impl/inc/mndDnode.h
source/dnode/mnode/impl/inc/mndDnode.h
+2
-0
source/dnode/mnode/impl/inc/mndInt.h
source/dnode/mnode/impl/inc/mndInt.h
+1
-0
source/dnode/mnode/impl/inc/mndMnode.h
source/dnode/mnode/impl/inc/mndMnode.h
+1
-0
source/dnode/mnode/impl/inc/mndOper.h
source/dnode/mnode/impl/inc/mndOper.h
+0
-30
source/dnode/mnode/impl/inc/mndShow.h
source/dnode/mnode/impl/inc/mndShow.h
+1
-0
source/dnode/mnode/impl/inc/mndSync.h
source/dnode/mnode/impl/inc/mndSync.h
+1
-1
source/dnode/mnode/impl/inc/mndTrans.h
source/dnode/mnode/impl/inc/mndTrans.h
+2
-5
source/dnode/mnode/impl/inc/mndVgroup.h
source/dnode/mnode/impl/inc/mndVgroup.h
+2
-0
source/dnode/mnode/impl/src/mndAcct.c
source/dnode/mnode/impl/src/mndAcct.c
+10
-10
source/dnode/mnode/impl/src/mndCluster.c
source/dnode/mnode/impl/src/mndCluster.c
+5
-5
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+853
-6
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+466
-48
source/dnode/mnode/impl/src/mndFunc.c
source/dnode/mnode/impl/src/mndFunc.c
+494
-4
source/dnode/mnode/impl/src/mndMnode.c
source/dnode/mnode/impl/src/mndMnode.c
+351
-42
source/dnode/mnode/impl/src/mndOper.c
source/dnode/mnode/impl/src/mndOper.c
+0
-21
source/dnode/mnode/impl/src/mndProfile.c
source/dnode/mnode/impl/src/mndProfile.c
+3
-3
source/dnode/mnode/impl/src/mndShow.c
source/dnode/mnode/impl/src/mndShow.c
+2
-7
source/dnode/mnode/impl/src/mndStable.c
source/dnode/mnode/impl/src/mndStable.c
+410
-4
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+9
-3
source/dnode/mnode/impl/src/mndTelem.c
source/dnode/mnode/impl/src/mndTelem.c
+4
-4
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+141
-85
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+284
-23
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+368
-4
source/dnode/mnode/impl/src/mnode.c
source/dnode/mnode/impl/src/mnode.c
+9
-7
source/dnode/mnode/sdb/inc/sdbInt.h
source/dnode/mnode/sdb/inc/sdbInt.h
+0
-1
source/dnode/mnode/sdb/src/sdb.c
source/dnode/mnode/sdb/src/sdb.c
+2
-2
source/dnode/mnode/sdb/src/sdbFile.c
source/dnode/mnode/sdb/src/sdbFile.c
+1
-1
source/dnode/mnode/sdb/src/sdbHash.c
source/dnode/mnode/sdb/src/sdbHash.c
+30
-26
source/dnode/mnode/sdb/src/sdbRaw.c
source/dnode/mnode/sdb/src/sdbRaw.c
+6
-1
source/dnode/vnode/impl/CMakeLists.txt
source/dnode/vnode/impl/CMakeLists.txt
+3
-3
source/dnode/vnode/impl/test/vnodeApiTests.cpp
source/dnode/vnode/impl/test/vnodeApiTests.cpp
+2
-2
source/dnode/vnode/meta/src/metaBDBImpl.c
source/dnode/vnode/meta/src/metaBDBImpl.c
+169
-141
source/libs/function/src/tfunction.c
source/libs/function/src/tfunction.c
+1
-1
source/libs/function/src/tudf.c
source/libs/function/src/tudf.c
+1
-1
source/libs/index/src/index_fst.c
source/libs/index/src/index_fst.c
+59
-26
source/libs/index/test/indexTests.cpp
source/libs/index/test/indexTests.cpp
+155
-53
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+2
-2
source/libs/parser/src/astGenerator.c
source/libs/parser/src/astGenerator.c
+0
-7
source/libs/parser/src/parserUtil.c
source/libs/parser/src/parserUtil.c
+1
-1
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+2
-2
source/libs/transport/src/rpcMain.c
source/libs/transport/src/rpcMain.c
+12
-12
source/libs/wal/CMakeLists.txt
source/libs/wal/CMakeLists.txt
+5
-0
source/libs/wal/inc/walInt.h
source/libs/wal/inc/walInt.h
+65
-1
source/libs/wal/src/walIndex.c
source/libs/wal/src/walIndex.c
+33
-28
source/libs/wal/src/walMeta.c
source/libs/wal/src/walMeta.c
+219
-0
source/libs/wal/src/walMgmt.c
source/libs/wal/src/walMgmt.c
+31
-38
source/libs/wal/src/walRead.c
source/libs/wal/src/walRead.c
+44
-4
source/libs/wal/src/walWrite.c
source/libs/wal/src/walWrite.c
+147
-63
source/libs/wal/test/CMakeLists.txt
source/libs/wal/test/CMakeLists.txt
+20
-0
source/libs/wal/test/walMetaTest.cpp
source/libs/wal/test/walMetaTest.cpp
+149
-0
source/libs/wal/test/walTests.cpp
source/libs/wal/test/walTests.cpp
+0
-137
source/util/src/tarray.c
source/util/src/tarray.c
+10
-0
source/util/src/terror.c
source/util/src/terror.c
+24
-15
source/util/src/tfile.c
source/util/src/tfile.c
+6
-0
source/util/src/tmd5.c
source/util/src/tmd5.c
+5
-5
source/util/src/tutil.c
source/util/src/tutil.c
+17
-4
未找到文件。
include/common/taosmsg.h
浏览文件 @
55f100e2
...
...
@@ -70,11 +70,9 @@ TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DROP_DB, "drop-db" )
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_USE_DB
,
"use-db"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_ALTER_DB
,
"alter-db"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_SYNC_DB
,
"sync-db"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_CREATE_TOPIC
,
"create-topic"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_DROP_TOPIC
,
"drop-topic"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_ALTER_TOPIC
,
"alter-topic"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_COMPACT_DB
,
"compact-db"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_CREATE_FUNCTION
,
"create-function"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_
ALTER_FUNCTION
,
"alter
-function"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_
RETRIEVE_FUNCTION
,
"retrieve
-function"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_DROP_FUNCTION
,
"drop-function"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_CREATE_STABLE
,
"create-stable"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_ALTER_STABLE
,
"alter-stable"
)
...
...
@@ -86,8 +84,6 @@ TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_KILL_CONN, "kill-conn" )
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_HEARTBEAT
,
"heartbeat"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_SHOW
,
"show"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_SHOW_RETRIEVE
,
"retrieve"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_SHOW_RETRIEVE_FUNC
,
"retrieve-func"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_COMPACT_VNODE
,
"compact-vnode"
)
// message from client to qnode
// message from client to dnode
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_NETWORK_TEST
,
"nettest"
)
...
...
@@ -163,7 +159,7 @@ typedef enum _mgmt_table {
TSDB_MGMT_TABLE_DNODE
,
TSDB_MGMT_TABLE_MNODE
,
TSDB_MGMT_TABLE_VGROUP
,
TSDB_MGMT_TABLE_
METRIC
,
TSDB_MGMT_TABLE_
STABLE
,
TSDB_MGMT_TABLE_MODULE
,
TSDB_MGMT_TABLE_QUERIES
,
TSDB_MGMT_TABLE_STREAMS
,
...
...
@@ -276,14 +272,12 @@ typedef struct {
SShellSubmitRspBlock
failedBlocks
[];
}
SShellSubmitRspMsg
;
//#if 0
typedef
struct
SSchema
{
uint8_t
type
;
char
name
[
TSDB_COL_NAME_LEN
];
int16_t
colId
;
int8_t
type
;
int32_t
colId
;
int32_t
bytes
;
char
name
[
TSDB_COL_NAME_LEN
];
}
SSchema
;
//#endif
typedef
struct
{
int32_t
contLen
;
...
...
@@ -571,7 +565,6 @@ typedef struct {
char
db
[
TSDB_FULL_DB_NAME_LEN
];
int32_t
cacheBlockSize
;
// MB
int32_t
totalBlocks
;
int32_t
maxTables
;
int32_t
daysPerFile
;
int32_t
daysToKeep0
;
int32_t
daysToKeep1
;
...
...
@@ -580,58 +573,93 @@ typedef struct {
int32_t
maxRowsPerFileBlock
;
int32_t
commitTime
;
int32_t
fsyncPeriod
;
int8_t
walLevel
;
int8_t
precision
;
// time resolution
int8_t
compression
;
int8_t
walLevel
;
int8_t
replications
;
int8_t
quorum
;
int8_t
ignoreExist
;
int8_t
update
;
int8_t
cacheLastRow
;
int8_t
dbType
;
int16_t
partitions
;
int8_t
reserve
[
5
];
}
SCreateDbMsg
,
SAlterDbMsg
;
int8_t
ignoreExist
;
int32_t
reserve
[
8
];
}
SCreateDbMsg
;
typedef
struct
{
char
db
[
TSDB_FULL_DB_NAME_LEN
];
int32_t
totalBlocks
;
int32_t
daysToKeep0
;
int32_t
daysToKeep1
;
int32_t
daysToKeep2
;
int32_t
fsyncPeriod
;
int8_t
walLevel
;
int8_t
quorum
;
int8_t
cacheLastRow
;
int32_t
reserve
[
8
];
}
SAlterDbMsg
;
typedef
struct
{
char
db
[
TSDB_TABLE_FNAME_LEN
];
int8_t
ignoreNotExists
;
int32_t
reserve
[
8
];
}
SDropDbMsg
;
typedef
struct
{
char
db
[
TSDB_TABLE_FNAME_LEN
];
int8_t
ignoreNotExists
;
int32_t
reserve
[
8
];
}
SUseDbMsg
;
typedef
struct
{
char
db
[
TSDB_TABLE_FNAME_LEN
];
int32_t
reserve
[
8
];
}
SSyncDbMsg
;
typedef
struct
{
char
db
[
TSDB_TABLE_FNAME_LEN
];
int32_t
reserve
[
8
];
}
SCompactDbMsg
;
typedef
struct
{
char
name
[
TSDB_FUNC_NAME_LEN
];
char
path
[
PATH_MAX
];
int32_t
funcType
;
int8_t
funcType
;
int8_t
scriptType
;
int8_t
align
;
int8_t
outputType
;
int
16
_t
outputLen
;
int
32
_t
outputLen
;
int32_t
bufSize
;
int32_t
codeLen
;
char
code
[];
int64_t
sigature
;
int32_t
commentSize
;
int32_t
codeSize
;
char
pCont
[];
}
SCreateFuncMsg
;
typedef
struct
{
int32_t
num
;
char
name
[];
char
name
[
TSDB_FUNC_NAME_LEN
];
}
SDropFuncMsg
;
typedef
struct
{
int32_t
numOfFuncs
;
char
pFuncNames
[];
}
SRetrieveFuncMsg
;
typedef
struct
{
char
name
[
TSDB_FUNC_NAME_LEN
];
int32_t
funcType
;
int8_t
resType
;
int16_t
resBytes
;
int8_t
funcType
;
int8_t
scriptType
;
int8_t
align
;
int8_t
outputType
;
int32_t
outputLen
;
int32_t
bufSize
;
int32_t
len
;
char
content
[];
}
SFunctionInfoMsg
;
typedef
struct
{
int32_t
num
;
char
content
[];
}
SUdfFuncMsg
;
int64_t
sigature
;
int32_t
commentSize
;
int32_t
codeSize
;
char
pCont
[];
}
SFuncInfo
;
typedef
struct
{
char
name
[
TSDB_FUNC_NAME_LEN
];
}
SDropFuncMsg
;
typedef
struct
{
char
db
[
TSDB_TABLE_FNAME_LEN
];
int8_t
ignoreNotExists
;
}
SDropDbMsg
,
SUseDbMsg
,
SSyncDbMsg
;
int32_t
numOfFuncs
;
char
pFuncInfos
[];
}
SRetrieveFuncRsp
;
typedef
struct
{
int32_t
statusInterval
;
...
...
@@ -736,13 +764,17 @@ typedef struct {
}
SAuthVnodeMsg
;
typedef
struct
{
char
tableFname
[
TSDB_TABLE_FNAME_LEN
];
int16_t
createFlag
;
char
tags
[];
char
name
[
TSDB_TABLE_FNAME_LEN
];
}
SStableInfoMsg
;
typedef
struct
{
char
tableFname
[
TSDB_TABLE_FNAME_LEN
];
int8_t
createFlag
;
char
tags
[];
}
STableInfoMsg
;
typedef
struct
{
uint8_t
metaClone
;
// create local clone of the cached table meta
int8_t
metaClone
;
// create local clone of the cached table meta
int32_t
numOfVgroups
;
int32_t
numOfTables
;
int32_t
numOfUdfs
;
...
...
@@ -760,25 +792,24 @@ typedef struct {
}
SVgroupMsg
;
typedef
struct
{
int32_t
numOfVgroups
;
int32_t
numOfVgroups
;
SVgroupMsg
vgroups
[];
}
SVgroupsMsg
,
SVgroupsInfo
;
typedef
struct
STableMetaMsg
{
int32_t
contLen
;
typedef
struct
{
char
tableFname
[
TSDB_TABLE_FNAME_LEN
];
// table id
int8_t
numOfTags
;
char
stableFname
[
TSDB_TABLE_FNAME_LEN
];
int32_t
numOfTags
;
int32_t
numOfColumns
;
int8_t
precision
;
int8_t
tableType
;
int
16_t
numOfColumns
;
int
16
_t
sversion
;
int
16
_t
tversion
;
int32_t
t
id
;
int64_t
uid
;
int
8_t
update
;
int
32
_t
sversion
;
int
32
_t
tversion
;
uint64_t
tu
id
;
uint64_t
s
uid
;
SVgroupMsg
vgroup
;
char
sTableName
[
TSDB_TABLE_FNAME_LEN
];
int64_t
suid
;
SSchema
schema
[];
SSchema
pSchema
[];
}
STableMetaMsg
;
typedef
struct
SMultiTableMeta
{
...
...
@@ -823,14 +854,31 @@ typedef struct SShowRsp {
typedef
struct
{
char
ep
[
TSDB_EP_LEN
];
// end point, hostname:port
}
SCreateDnodeMsg
,
SDropDnodeMsg
;
}
SCreateDnodeMsg
;
typedef
struct
{
int32_t
dnodeId
;
}
SDropDnodeMsg
;
typedef
struct
{
int32_t
dnodeId
;
char
config
[
128
];
}
SCfgDnodeMsg
;
typedef
struct
{
int32_t
dnodeId
;
}
SCreateMnodeMsg
,
SDropMnodeMsg
;
typedef
struct
{
int32_t
dnodeId
;
int8_t
align
[
3
];
int8_t
replica
;
int8_t
reserved
[
3
];
SReplica
replicas
[
TSDB_MAX_REPLICA
];
}
SCreateMnodeMsg
,
SAlterMnodeMsg
,
SDropMnodeMsg
;
}
SCreateMnodeInMsg
,
SAlterMnodeInMsg
;
typedef
struct
{
int32_t
dnodeId
;
}
SDropMnodeInMsg
;
typedef
struct
{
int32_t
dnodeId
;
...
...
@@ -843,11 +891,6 @@ typedef struct {
int32_t
vgId
;
}
SConfigVnodeMsg
;
typedef
struct
{
char
ep
[
TSDB_EP_LEN
];
// end point, hostname:port
char
config
[
64
];
}
SCfgDnodeMsg
;
typedef
struct
{
char
sql
[
TSDB_SHOW_SQL_LEN
];
int32_t
queryId
;
...
...
include/dnode/mnode/sdb/sdb.h
浏览文件 @
55f100e2
...
...
@@ -65,6 +65,16 @@ extern "C" {
dataPos += valLen; \
}
#define SDB_GET_RESERVE(pRaw, pRow, dataPos, valLen) \
{ \
char val[valLen] = {0}; \
if (sdbGetRawBinary(pRaw, dataPos, val, valLen) != 0) { \
sdbFreeRow(pRow); \
return NULL; \
} \
dataPos += valLen; \
}
#define SDB_SET_INT64(pRaw, dataPos, val) \
{ \
if (sdbSetRawInt64(pRaw, dataPos, val) != 0) { \
...
...
@@ -110,6 +120,16 @@ extern "C" {
dataPos += valLen; \
}
#define SDB_SET_RESERVE(pRaw, dataPos, valLen) \
{ \
char val[valLen] = {0}; \
if (sdbSetRawBinary(pRaw, dataPos, val, valLen) != 0) { \
sdbFreeRaw(pRaw); \
return NULL; \
} \
dataPos += valLen; \
}
#define SDB_SET_DATALEN(pRaw, dataLen) \
{ \
if (sdbSetRawDataLen(pRaw, dataLen) != 0) { \
...
...
@@ -258,7 +278,7 @@ int32_t sdbDeploy(SSdb *pSdb);
int32_t
sdbReadFile
(
SSdb
*
pSdb
);
/**
* @brief Parse and write raw data to sdb
.
* @brief Parse and write raw data to sdb
, then free the pRaw object
*
* @param pSdb The sdb object.
* @param pRaw The raw data.
...
...
@@ -266,6 +286,15 @@ int32_t sdbReadFile(SSdb *pSdb);
*/
int32_t
sdbWrite
(
SSdb
*
pSdb
,
SSdbRaw
*
pRaw
);
/**
* @brief Parse and write raw data to sdb.
*
* @param pSdb The sdb object.
* @param pRaw The raw data.
* @return int32_t 0 for success, -1 for failure.
*/
int32_t
sdbWriteNotFree
(
SSdb
*
pSdb
,
SSdbRaw
*
pRaw
);
/**
* @brief Acquire a row from sdb
*
...
...
include/libs/wal/wal.h
浏览文件 @
55f100e2
...
...
@@ -55,12 +55,14 @@ typedef struct {
uint32_t
signature
;
uint32_t
cksumHead
;
uint32_t
cksumBody
;
//
char cont[];
char
cont
[];
}
SWalHead
;
typedef
struct
{
int32_t
vgId
;
int32_t
fsyncPeriod
;
// millisecond
int32_t
rollPeriod
;
int64_t
segSize
;
EWalType
walLevel
;
// wal level
}
SWalCfg
;
...
...
@@ -87,36 +89,41 @@ typedef struct SWal {
// cfg
int32_t
vgId
;
int32_t
fsyncPeriod
;
// millisecond
int32_t
fsyncSeq
;
int32_t
rollPeriod
;
// second
int64_t
segSize
;
int64_t
retentionSize
;
int32_t
retentionPeriod
;
EWalType
level
;
//total size
int64_t
totSize
;
//fsync seq
int32_t
fsyncSeq
;
//reference
int64_t
refId
;
//current tfd
int64_t
curLogTfd
;
int64_t
curIdxTfd
;
//write tfd
int64_t
writeLogTfd
;
int64_t
writeIdxTfd
;
//read tfd
int64_t
readLogTfd
;
int64_t
readIdxTfd
;
//current version
int64_t
curVersion
;
int64_t
curLogOffset
;
//current file version
int64_t
curFileFirstVersion
;
int64_t
curFileLastVersion
;
//wal fileset version
//wal lifecycle
int64_t
firstVersion
;
int64_t
snapshotVersion
;
int64_t
commitVersion
;
int64_t
lastVersion
;
int64_t
lastFileName
;
//roll status
int64_t
lastRollSeq
;
int64_t
lastFileWriteSize
;
//file set
int32_t
writeCur
;
int32_t
readCur
;
SArray
*
fileInfoSet
;
//ctl
int32_t
curStatus
;
pthread_mutex_t
mutex
;
//path
char
path
[
WAL_PATH_LEN
];
//file set
SArray
*
fileSet
;
//reusable write head
SWalHead
head
;
}
SWal
;
// WAL HANDLE
...
...
@@ -133,7 +140,7 @@ int32_t walAlter(SWal *, SWalCfg *pCfg);
void
walClose
(
SWal
*
);
// write
int64_t
walWrite
(
SWal
*
,
int64_t
index
,
uint8_t
msgType
,
void
*
body
,
int32_t
bodyLen
);
int64_t
walWrite
(
SWal
*
,
int64_t
index
,
uint8_t
msgType
,
const
void
*
body
,
int32_t
bodyLen
);
void
walFsync
(
SWal
*
,
bool
force
);
// apis for lifecycle management
...
...
include/util/taoserror.h
浏览文件 @
55f100e2
...
...
@@ -183,6 +183,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_MND_MNODE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0348) //"Mnode already exists")
#define TSDB_CODE_MND_MNODE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0349) //"Mnode not there")
// mnode-table
#define TSDB_CODE_MND_TABLE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0360) //"Table already exists")
#define TSDB_CODE_MND_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0361) //"Table name too long")
#define TSDB_CODE_MND_INVALID_TABLE_NAME TAOS_DEF_ERROR_CODE(0, 0x0362) //"Table does not exist")
...
...
@@ -200,32 +201,41 @@ int32_t* taosGetErrno();
#define TSDB_CODE_MND_INVALID_CREATE_TABLE_MSG TAOS_DEF_ERROR_CODE(0, 0x036E) //"Invalid create table message")
#define TSDB_CODE_MND_EXCEED_MAX_ROW_BYTES TAOS_DEF_ERROR_CODE(0, 0x036F) //"Exceed max row bytes")
#define TSDB_CODE_MND_INVALID_FUNC_NAME TAOS_DEF_ERROR_CODE(0, 0x0370) //"Invalid func name")
#define TSDB_CODE_MND_INVALID_FUNC_LEN TAOS_DEF_ERROR_CODE(0, 0x0371) //"Invalid func length")
#define TSDB_CODE_MND_INVALID_FUNC_CODE TAOS_DEF_ERROR_CODE(0, 0x0372) //"Invalid func code")
#define TSDB_CODE_MND_FUNC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0373) //"Func already exists")
#define TSDB_CODE_MND_INVALID_FUNC TAOS_DEF_ERROR_CODE(0, 0x0374) //"Invalid func")
#define TSDB_CODE_MND_INVALID_FUNC_BUFSIZE TAOS_DEF_ERROR_CODE(0, 0x0375) //"Invalid func bufSize")
#define TSDB_CODE_MND_FUNC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0370)
#define TSDB_CODE_MND_FUNC_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0371)
#define TSDB_CODE_MND_INVALID_FUNC TAOS_DEF_ERROR_CODE(0, 0x0372)
#define TSDB_CODE_MND_INVALID_FUNC_NAME TAOS_DEF_ERROR_CODE(0, 0x0373)
#define TSDB_CODE_MND_INVALID_FUNC_COMMENT TAOS_DEF_ERROR_CODE(0, 0x0374)
#define TSDB_CODE_MND_INVALID_FUNC_CODE TAOS_DEF_ERROR_CODE(0, 0x0375)
#define TSDB_CODE_MND_INVALID_FUNC_BUFSIZE TAOS_DEF_ERROR_CODE(0, 0x0376)
#define TSDB_CODE_MND_INVALID_TAG_LENGTH TAOS_DEF_ERROR_CODE(0, 0x0376) //"invalid tag length")
#define TSDB_CODE_MND_INVALID_COLUMN_LENGTH TAOS_DEF_ERROR_CODE(0, 0x0377) //"invalid column length")
#define TSDB_CODE_MND_DB_NOT_SELECTED TAOS_DEF_ERROR_CODE(0, 0x0380) //"Database not specified or available")
#define TSDB_CODE_MND_DB_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0381) //"Database already exists")
#define TSDB_CODE_MND_INVALID_DB_OPTION TAOS_DEF_ERROR_CODE(0, 0x0382) //"Invalid database options")
#define TSDB_CODE_MND_INVALID_DB TAOS_DEF_ERROR_CODE(0, 0x0383) //"Invalid database name")
#define TSDB_CODE_MND_MONITOR_DB_FORBIDDEN TAOS_DEF_ERROR_CODE(0, 0x0384) //"Cannot delete monitor database")
#define TSDB_CODE_MND_DB_NOT_SELECTED TAOS_DEF_ERROR_CODE(0, 0x0380)
#define TSDB_CODE_MND_DB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0381)
#define TSDB_CODE_MND_DB_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0381)
#define TSDB_CODE_MND_INVALID_DB TAOS_DEF_ERROR_CODE(0, 0x0383)
#define TSDB_CODE_MND_INVALID_DB_OPTION TAOS_DEF_ERROR_CODE(0, 0x0382)
#define TSDB_CODE_MND_INVALID_DB_CACHE_SIZE TAOS_DEF_ERROR_CODE(0, 0x0383)
#define TSDB_CODE_MND_INVALID_DB_TOTAL_BLOCKS TAOS_DEF_ERROR_CODE(0, 0x0383)
#define TSDB_CODE_MND_INVALID_DB_DAYS TAOS_DEF_ERROR_CODE(0, 0x0383)
#define TSDB_CODE_MND_INVALID_DB_KEEP0 TAOS_DEF_ERROR_CODE(0, 0x0383)
#define TSDB_CODE_MND_INVALID_DB_KEEP1 TAOS_DEF_ERROR_CODE(0, 0x0383)
#define TSDB_CODE_MND_INVALID_DB_KEEP2 TAOS_DEF_ERROR_CODE(0, 0x0383)
#define TSDB_CODE_MND_INVALID_DB_MIN_ROWS TAOS_DEF_ERROR_CODE(0, 0x0383)
#define TSDB_CODE_MND_INVALID_DB_MAX_ROWS TAOS_DEF_ERROR_CODE(0, 0x0383)
#define TSDB_CODE_MND_INVALID_DB_COMMIT_TIME TAOS_DEF_ERROR_CODE(0, 0x0383)
#define TSDB_CODE_MND_INVALID_DB_FSYNC_PERIOD TAOS_DEF_ERROR_CODE(0, 0x0383)
#define TSDB_CODE_MND_INVALID_DB_WAL_LEVEL TAOS_DEF_ERROR_CODE(0, 0x0383)
#define TSDB_CODE_MND_INVALID_DB_PRECISION TAOS_DEF_ERROR_CODE(0, 0x0383)
#define TSDB_CODE_MND_INVALID_DB_COMP TAOS_DEF_ERROR_CODE(0, 0x0383)
#define TSDB_CODE_MND_INVALID_DB_REPLICA TAOS_DEF_ERROR_CODE(0, 0x0383)
#define TSDB_CODE_MND_INVALID_DB_QUORUM TAOS_DEF_ERROR_CODE(0, 0x0383)
#define TSDB_CODE_MND_INVALID_DB_UPDATE TAOS_DEF_ERROR_CODE(0, 0x0383)
#define TSDB_CODE_MND_INVALID_DB_CACHE_LAST TAOS_DEF_ERROR_CODE(0, 0x0383)
#define TSDB_CODE_MND_DB_OPTION_UNCHANGED TAOS_DEF_ERROR_CODE(0, 0x0383)
#define TSDB_CODE_MND_TOO_MANY_DATABASES TAOS_DEF_ERROR_CODE(0, 0x0385) //"Too many databases for account")
#define TSDB_CODE_MND_DB_IN_DROPPING TAOS_DEF_ERROR_CODE(0, 0x0386) //"Database not available")
#define TSDB_CODE_MND_VGROUP_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0387) //"Database unsynced")
#define TSDB_CODE_MND_INVALID_DB_OPTION_DAYS TAOS_DEF_ERROR_CODE(0, 0x0390) //"Invalid database option: days out of range")
#define TSDB_CODE_MND_INVALID_DB_OPTION_KEEP TAOS_DEF_ERROR_CODE(0, 0x0391) //"Invalid database option: keep >= keep1 >= keep0 >= days")
#define TSDB_CODE_MND_INVALID_TOPIC TAOS_DEF_ERROR_CODE(0, 0x0392) //"Invalid topic name)
#define TSDB_CODE_MND_INVALID_TOPIC_OPTION TAOS_DEF_ERROR_CODE(0, 0x0393) //"Invalid topic option)
#define TSDB_CODE_MND_INVALID_TOPIC_PARTITONS TAOS_DEF_ERROR_CODE(0, 0x0394) //"Invalid topic partitons num, valid range: [1, 1000])
#define TSDB_CODE_MND_TOPIC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0395) //"Topic already exists)
// dnode
#define TSDB_CODE_DND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0400)
...
...
include/util/tarray.h
浏览文件 @
55f100e2
...
...
@@ -146,6 +146,13 @@ void* taosArrayInsert(SArray* pArray, size_t index, void* pData);
*/
void
taosArraySet
(
SArray
*
pArray
,
size_t
index
,
void
*
pData
);
/**
* remove some data entry from front
* @param pArray
* @param cnt
*/
void
taosArrayPopFrontBatch
(
SArray
*
pArray
,
size_t
cnt
);
/**
* remove data entry of the given index
* @param pArray
...
...
include/util/tdef.h
浏览文件 @
55f100e2
...
...
@@ -163,9 +163,14 @@ do { \
#define TSDB_TABLE_NAME_LEN 193 // it is a null-terminated string
#define TSDB_DB_NAME_LEN 65
#define TSDB_FULL_DB_NAME_LEN (TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN)
#define TSDB_FUNC_NAME_LEN 65
#define TSDB_FUNC_CODE_LEN (65535 - 512)
#define TSDB_FUNC_BUF_SIZE 512
#define TSDB_FUNC_NAME_LEN 65
#define TSDB_FUNC_COMMENT_LEN 4096
#define TSDB_FUNC_CODE_LEN (65535 - 512)
#define TSDB_FUNC_BUF_SIZE 512
#define TSDB_FUNC_TYPE_SCALAR 1
#define TSDB_FUNC_TYPE_AGGREGATE 2
#define TSDB_TYPE_STR_MAX_LEN 32
#define TSDB_TABLE_FNAME_LEN (TSDB_FULL_DB_NAME_LEN + TSDB_TABLE_NAME_LEN)
#define TSDB_COL_NAME_LEN 65
...
...
@@ -245,12 +250,6 @@ do { \
#define TSDB_MAX_TOTAL_BLOCKS 10000
#define TSDB_DEFAULT_TOTAL_BLOCKS 6
#define TSDB_MIN_TABLES 4
#define TSDB_MAX_TABLES 10000000
#define TSDB_DEFAULT_TABLES 1000000
#define TSDB_TABLES_STEP 1000
#define TSDB_META_COMPACT_RATIO 0 // disable tsdb meta compact by default
#define TSDB_MIN_DAYS_PER_FILE 1
#define TSDB_MAX_DAYS_PER_FILE 3650
#define TSDB_DEFAULT_DAYS_PER_FILE 10
...
...
@@ -259,18 +258,26 @@ do { \
#define TSDB_MAX_KEEP 365000 // data in db to be reserved.
#define TSDB_DEFAULT_KEEP 3650 // ten years
#define TSDB_DEFAULT_MIN_ROW_FBLOCK 100
#define TSDB_MIN_MIN_ROW_FBLOCK 10
#define TSDB_MAX_MIN_ROW_FBLOCK 1000
#define TSDB_DEFAULT_MIN_ROW_FBLOCK 100
#define TSDB_DEFAULT_MAX_ROW_FBLOCK 4096
#define TSDB_MIN_MAX_ROW_FBLOCK 200
#define TSDB_MAX_MAX_ROW_FBLOCK 10000
#define TSDB_DEFAULT_MAX_ROW_FBLOCK 4096
#define TSDB_MIN_COMMIT_TIME 30
#define TSDB_MAX_COMMIT_TIME 40960
#define TSDB_DEFAULT_COMMIT_TIME 3600
#define TSDB_MIN_FSYNC_PERIOD 0
#define TSDB_MAX_FSYNC_PERIOD 180000 // millisecond
#define TSDB_DEFAULT_FSYNC_PERIOD 3000 // three second
#define TSDB_MIN_WAL_LEVEL 0
#define TSDB_MAX_WAL_LEVEL 2
#define TSDB_DEFAULT_WAL_LEVEL 1
#define TSDB_MIN_PRECISION TSDB_TIME_PRECISION_MILLI
#define TSDB_MAX_PRECISION TSDB_TIME_PRECISION_NANO
#define TSDB_DEFAULT_PRECISION TSDB_TIME_PRECISION_MILLI
...
...
@@ -279,9 +286,13 @@ do { \
#define TSDB_MAX_COMP_LEVEL 2
#define TSDB_DEFAULT_COMP_LEVEL 2
#define TSDB_MIN_WAL_LEVEL 0
#define TSDB_MAX_WAL_LEVEL 2
#define TSDB_DEFAULT_WAL_LEVEL 1
#define TSDB_MIN_DB_REPLICA_OPTION 1
#define TSDB_MAX_DB_REPLICA_OPTION 3
#define TSDB_DEFAULT_DB_REPLICA_OPTION 1
#define TSDB_MIN_DB_QUORUM_OPTION 1
#define TSDB_MAX_DB_QUORUM_OPTION 2
#define TSDB_DEFAULT_DB_QUORUM_OPTION 1
#define TSDB_MIN_DB_UPDATE 0
#define TSDB_MAX_DB_UPDATE 2
...
...
@@ -291,22 +302,6 @@ do { \
#define TSDB_MAX_DB_CACHE_LAST_ROW 3
#define TSDB_DEFAULT_CACHE_LAST_ROW 0
#define TSDB_MIN_FSYNC_PERIOD 0
#define TSDB_MAX_FSYNC_PERIOD 180000 // millisecond
#define TSDB_DEFAULT_FSYNC_PERIOD 3000 // three second
#define TSDB_MIN_DB_REPLICA_OPTION 1
#define TSDB_MAX_DB_REPLICA_OPTION 3
#define TSDB_DEFAULT_DB_REPLICA_OPTION 1
#define TSDB_MIN_DB_PARTITON_OPTION 0
#define TSDB_MAX_DB_PARTITON_OPTION 1000
#define TSDB_DEFAULT_DB_PARTITON_OPTION 4
#define TSDB_MIN_DB_QUORUM_OPTION 1
#define TSDB_MAX_DB_QUORUM_OPTION 2
#define TSDB_DEFAULT_DB_QUORUM_OPTION 1
#define TSDB_MAX_JOIN_TABLE_NUM 10
#define TSDB_MAX_UNION_CLAUSE 5
...
...
@@ -320,6 +315,11 @@ do { \
#define TSDB_QUERY_TYPE_NON_TYPE 0x00u // none type
#define TSDB_QUERY_TYPE_FREE_RESOURCE 0x01u // free qhandle at vnode
#define TSDB_META_COMPACT_RATIO 0 // disable tsdb meta compact by default
/*
* 1. ordinary sub query for select * from super_table
* 2. all sqlobj generated by createSubqueryObj with this flag
...
...
include/util/tfile.h
浏览文件 @
55f100e2
...
...
@@ -16,6 +16,8 @@
#ifndef _TD_UTIL_FILE_H
#define _TD_UTIL_FILE_H
#include "os.h"
#ifdef __cplusplus
extern
"C"
{
#endif
...
...
include/util/tmd5.h
浏览文件 @
55f100e2
...
...
@@ -30,10 +30,10 @@ typedef struct {
uint32_t
buf
[
4
];
/* scratch buffer */
uint8_t
in
[
64
];
/* input buffer */
uint8_t
digest
[
16
];
/* actual digest after MD5Final call */
}
MD5_CTX
;
}
T_
MD5_CTX
;
void
MD5Init
(
MD5_CTX
*
mdContext
);
void
MD5Update
(
MD5_CTX
*
mdContext
,
uint8_t
*
inBuf
,
unsigned
int
inLen
);
void
MD5Final
(
MD5_CTX
*
mdContext
);
void
tMD5Init
(
T_
MD5_CTX
*
mdContext
);
void
tMD5Update
(
T_
MD5_CTX
*
mdContext
,
uint8_t
*
inBuf
,
unsigned
int
inLen
);
void
tMD5Final
(
T_
MD5_CTX
*
mdContext
);
#endif
/*_TD_UTIL_MD5_H*/
include/util/tutil.h
浏览文件 @
55f100e2
...
...
@@ -21,22 +21,22 @@ extern "C" {
#endif
#include "os.h"
#include "tmd5.h"
#include "tcrc32c.h"
#include "tdef.h"
#include "tmd5.h"
int32_t
strdequote
(
char
*
src
);
int32_t
strndequote
(
char
*
dst
,
const
char
*
z
,
int32_t
len
);
int32_t
strndequote
(
char
*
dst
,
const
char
*
z
,
int32_t
len
);
int32_t
strRmquote
(
char
*
z
,
int32_t
len
);
size_t
strtrim
(
char
*
src
);
char
*
strnchr
(
char
*
haystack
,
char
needle
,
int32_t
len
,
bool
skipquote
);
char
**
strsplit
(
char
*
src
,
const
char
*
delim
,
int32_t
*
num
);
char
*
strtolower
(
char
*
dst
,
const
char
*
src
);
char
*
strntolower
(
char
*
dst
,
const
char
*
src
,
int32_t
n
);
char
*
strntolower_s
(
char
*
dst
,
const
char
*
src
,
int32_t
n
);
char
*
strnchr
(
char
*
haystack
,
char
needle
,
int32_t
len
,
bool
skipquote
);
char
**
strsplit
(
char
*
src
,
const
char
*
delim
,
int32_t
*
num
);
char
*
strtolower
(
char
*
dst
,
const
char
*
src
);
char
*
strntolower
(
char
*
dst
,
const
char
*
src
,
int32_t
n
);
char
*
strntolower_s
(
char
*
dst
,
const
char
*
src
,
int32_t
n
);
int64_t
strnatoi
(
char
*
num
,
int32_t
len
);
char
*
strbetween
(
char
*
string
,
char
*
begin
,
char
*
end
);
char
*
paGetToken
(
char
*
src
,
char
**
token
,
int32_t
*
tokenLen
);
char
*
strbetween
(
char
*
string
,
char
*
begin
,
char
*
end
);
char
*
paGetToken
(
char
*
src
,
char
**
token
,
int32_t
*
tokenLen
);
int32_t
taosByteArrayToHexStr
(
char
bytes
[],
int32_t
len
,
char
hexstr
[]);
int32_t
taosHexStrToByteArray
(
char
hexstr
[],
char
bytes
[]);
...
...
@@ -47,19 +47,19 @@ void taosIp2String(uint32_t ip, char *str);
void
taosIpPort2String
(
uint32_t
ip
,
uint16_t
port
,
char
*
str
);
static
FORCE_INLINE
void
taosEncryptPass
(
uint8_t
*
inBuf
,
size_t
inLen
,
char
*
target
)
{
MD5_CTX
context
;
MD5Init
(
&
context
);
MD5Update
(
&
context
,
inBuf
,
(
unsigned
int
)
inLen
);
MD5Final
(
&
context
);
T_
MD5_CTX
context
;
t
MD5Init
(
&
context
);
t
MD5Update
(
&
context
,
inBuf
,
(
unsigned
int
)
inLen
);
t
MD5Final
(
&
context
);
memcpy
(
target
,
context
.
digest
,
tListLen
(
context
.
digest
));
}
static
FORCE_INLINE
void
taosEncryptPass_c
(
uint8_t
*
inBuf
,
size_t
len
,
char
*
target
)
{
MD5_CTX
context
;
MD5Init
(
&
context
);
MD5Update
(
&
context
,
inBuf
,
(
unsigned
int
)
len
);
T_MD5_CTX
context
;
tMD5Init
(
&
context
);
tMD5Update
(
&
context
,
inBuf
,
(
unsigned
int
)
len
);
tMD5Final
(
&
context
);
MD5Final
(
&
context
);
sprintf
(
target
,
"%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x"
,
context
.
digest
[
0
],
context
.
digest
[
1
],
context
.
digest
[
2
],
context
.
digest
[
3
],
context
.
digest
[
4
],
context
.
digest
[
5
],
context
.
digest
[
6
],
context
.
digest
[
7
],
context
.
digest
[
8
],
context
.
digest
[
9
],
context
.
digest
[
10
],
context
.
digest
[
11
],
context
.
digest
[
12
],
...
...
@@ -70,4 +70,4 @@ static FORCE_INLINE void taosEncryptPass_c(uint8_t *inBuf, size_t len, char *tar
}
#endif
#endif
/*_TD_UTIL_UTIL_H*/
#endif
/*_TD_UTIL_UTIL_H*/
source/common/src/tglobal.c
浏览文件 @
55f100e2
...
...
@@ -143,13 +143,9 @@ int8_t tsWAL = TSDB_DEFAULT_WAL_LEVEL;
int32_t
tsFsyncPeriod
=
TSDB_DEFAULT_FSYNC_PERIOD
;
int32_t
tsReplications
=
TSDB_DEFAULT_DB_REPLICA_OPTION
;
int32_t
tsQuorum
=
TSDB_DEFAULT_DB_QUORUM_OPTION
;
int16_t
tsPartitons
=
TSDB_DEFAULT_DB_PARTITON_OPTION
;
int8_t
tsUpdate
=
TSDB_DEFAULT_DB_UPDATE_OPTION
;
int8_t
tsCacheLastRow
=
TSDB_DEFAULT_CACHE_LAST_ROW
;
int32_t
tsMaxVgroupsPerDb
=
0
;
int32_t
tsMinTablePerVnode
=
TSDB_TABLES_STEP
;
int32_t
tsMaxTablePerVnode
=
TSDB_DEFAULT_TABLES
;
int32_t
tsTableIncStepPerVnode
=
TSDB_TABLES_STEP
;
int32_t
tsTsdbMetaCompactRatio
=
TSDB_META_COMPACT_RATIO
;
// tsdb config
...
...
@@ -727,37 +723,6 @@ static void doInitGlobalConfig(void) {
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosAddConfigOption
(
cfg
);
// database configs
cfg
.
option
=
"maxTablesPerVnode"
;
cfg
.
ptr
=
&
tsMaxTablePerVnode
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT32
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
minValue
=
TSDB_MIN_TABLES
;
cfg
.
maxValue
=
TSDB_MAX_TABLES
;
cfg
.
ptrLength
=
0
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosAddConfigOption
(
cfg
);
cfg
.
option
=
"minTablesPerVnode"
;
cfg
.
ptr
=
&
tsMinTablePerVnode
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT32
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
minValue
=
TSDB_MIN_TABLES
;
cfg
.
maxValue
=
TSDB_MAX_TABLES
;
cfg
.
ptrLength
=
0
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosAddConfigOption
(
cfg
);
cfg
.
option
=
"tableIncStepPerVnode"
;
cfg
.
ptr
=
&
tsTableIncStepPerVnode
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT32
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
minValue
=
TSDB_MIN_TABLES
;
cfg
.
maxValue
=
TSDB_MAX_TABLES
;
cfg
.
ptrLength
=
0
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosAddConfigOption
(
cfg
);
cfg
.
option
=
"cache"
;
cfg
.
ptr
=
&
tsCacheBlockSize
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT32
;
...
...
@@ -868,16 +833,6 @@ static void doInitGlobalConfig(void) {
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosAddConfigOption
(
cfg
);
cfg
.
option
=
"partitions"
;
cfg
.
ptr
=
&
tsPartitons
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT16
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
minValue
=
TSDB_MIN_DB_PARTITON_OPTION
;
cfg
.
maxValue
=
TSDB_MAX_DB_PARTITON_OPTION
;
cfg
.
ptrLength
=
0
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosAddConfigOption
(
cfg
);
cfg
.
option
=
"quorum"
;
cfg
.
ptr
=
&
tsQuorum
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT32
;
...
...
source/dnode/mgmt/impl/src/dndMnode.c
浏览文件 @
55f100e2
...
...
@@ -366,7 +366,7 @@ static void dndBuildMnodeOpenOption(SDnode *pDnode, SMnodeOpt *pOption) {
memcpy
(
&
pOption
->
replicas
,
pMgmt
->
replicas
,
sizeof
(
SReplica
)
*
TSDB_MAX_REPLICA
);
}
static
int32_t
dndBuildMnodeOptionFromMsg
(
SDnode
*
pDnode
,
SMnodeOpt
*
pOption
,
SCreateMnodeMsg
*
pMsg
)
{
static
int32_t
dndBuildMnodeOptionFromMsg
(
SDnode
*
pDnode
,
SMnodeOpt
*
pOption
,
SCreateMnode
In
Msg
*
pMsg
)
{
dndInitMnodeOption
(
pDnode
,
pOption
);
pOption
->
dnodeId
=
dndGetDnodeId
(
pDnode
);
pOption
->
clusterId
=
dndGetClusterId
(
pDnode
);
...
...
@@ -488,8 +488,8 @@ static int32_t dndDropMnode(SDnode *pDnode) {
return
0
;
}
static
SCreateMnodeMsg
*
dndParseCreateMnodeMsg
(
SRpcMsg
*
pRpcMsg
)
{
SCreateMnodeMsg
*
pMsg
=
pRpcMsg
->
pCont
;
static
SCreateMnode
In
Msg
*
dndParseCreateMnodeMsg
(
SRpcMsg
*
pRpcMsg
)
{
SCreateMnode
In
Msg
*
pMsg
=
pRpcMsg
->
pCont
;
pMsg
->
dnodeId
=
htonl
(
pMsg
->
dnodeId
);
for
(
int32_t
i
=
0
;
i
<
pMsg
->
replica
;
++
i
)
{
pMsg
->
replicas
[
i
].
id
=
htonl
(
pMsg
->
replicas
[
i
].
id
);
...
...
@@ -500,7 +500,7 @@ static SCreateMnodeMsg *dndParseCreateMnodeMsg(SRpcMsg *pRpcMsg) {
}
static
int32_t
dndProcessCreateMnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpcMsg
)
{
SCreateMnodeMsg
*
pMsg
=
dndParseCreateMnodeMsg
(
pRpcMsg
->
pCont
);
SCreateMnode
In
Msg
*
pMsg
=
dndParseCreateMnodeMsg
(
pRpcMsg
->
pCont
);
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
terrno
=
TSDB_CODE_DND_MNODE_ID_INVALID
;
...
...
@@ -516,7 +516,7 @@ static int32_t dndProcessCreateMnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
}
static
int32_t
dndProcessAlterMnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpcMsg
)
{
SAlterMnodeMsg
*
pMsg
=
dndParseCreateMnodeMsg
(
pRpcMsg
->
pCont
);
SAlterMnode
In
Msg
*
pMsg
=
dndParseCreateMnodeMsg
(
pRpcMsg
->
pCont
);
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
terrno
=
TSDB_CODE_DND_MNODE_ID_INVALID
;
...
...
@@ -531,7 +531,8 @@ static int32_t dndProcessAlterMnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
}
static
int32_t
dndProcessDropMnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpcMsg
)
{
SDropMnodeMsg
*
pMsg
=
dndParseCreateMnodeMsg
(
pRpcMsg
->
pCont
);
SDropMnodeInMsg
*
pMsg
=
pRpcMsg
->
pCont
;
pMsg
->
dnodeId
=
htonl
(
pMsg
->
dnodeId
);
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
terrno
=
TSDB_CODE_DND_MNODE_ID_INVALID
;
...
...
source/dnode/mgmt/impl/src/dndTransport.c
浏览文件 @
55f100e2
...
...
@@ -65,11 +65,9 @@ static void dndInitMsgFp(STransMgmt *pMgmt) {
pMgmt
->
msgFp
[
TSDB_MSG_TYPE_USE_DB
]
=
dndProcessMnodeWriteMsg
;
pMgmt
->
msgFp
[
TSDB_MSG_TYPE_ALTER_DB
]
=
dndProcessMnodeWriteMsg
;
pMgmt
->
msgFp
[
TSDB_MSG_TYPE_SYNC_DB
]
=
dndProcessMnodeWriteMsg
;
pMgmt
->
msgFp
[
TSDB_MSG_TYPE_CREATE_TOPIC
]
=
dndProcessMnodeWriteMsg
;
pMgmt
->
msgFp
[
TSDB_MSG_TYPE_DROP_TOPIC
]
=
dndProcessMnodeWriteMsg
;
pMgmt
->
msgFp
[
TSDB_MSG_TYPE_ALTER_TOPIC
]
=
dndProcessMnodeWriteMsg
;
pMgmt
->
msgFp
[
TSDB_MSG_TYPE_COMPACT_DB
]
=
dndProcessMnodeWriteMsg
;
pMgmt
->
msgFp
[
TSDB_MSG_TYPE_CREATE_FUNCTION
]
=
dndProcessMnodeWriteMsg
;
pMgmt
->
msgFp
[
TSDB_MSG_TYPE_
ALTER
_FUNCTION
]
=
dndProcessMnodeWriteMsg
;
pMgmt
->
msgFp
[
TSDB_MSG_TYPE_
RETRIEVE
_FUNCTION
]
=
dndProcessMnodeWriteMsg
;
pMgmt
->
msgFp
[
TSDB_MSG_TYPE_DROP_FUNCTION
]
=
dndProcessMnodeWriteMsg
;
pMgmt
->
msgFp
[
TSDB_MSG_TYPE_CREATE_STABLE
]
=
dndProcessMnodeWriteMsg
;
pMgmt
->
msgFp
[
TSDB_MSG_TYPE_ALTER_STABLE
]
=
dndProcessMnodeWriteMsg
;
...
...
@@ -81,8 +79,6 @@ static void dndInitMsgFp(STransMgmt *pMgmt) {
pMgmt
->
msgFp
[
TSDB_MSG_TYPE_HEARTBEAT
]
=
dndProcessMnodeReadMsg
;
pMgmt
->
msgFp
[
TSDB_MSG_TYPE_SHOW
]
=
dndProcessMnodeReadMsg
;
pMgmt
->
msgFp
[
TSDB_MSG_TYPE_SHOW_RETRIEVE
]
=
dndProcessMnodeReadMsg
;
pMgmt
->
msgFp
[
TSDB_MSG_TYPE_SHOW_RETRIEVE_FUNC
]
=
dndProcessMnodeReadMsg
;
pMgmt
->
msgFp
[
TSDB_MSG_TYPE_COMPACT_VNODE
]
=
dndProcessMnodeWriteMsg
;
// message from client to dnode
pMgmt
->
msgFp
[
TSDB_MSG_TYPE_NETWORK_TEST
]
=
dndProcessDnodeReq
;
...
...
source/dnode/mgmt/impl/test/CMakeLists.txt
浏览文件 @
55f100e2
add_subdirectory
(
acct
)
add_subdirectory
(
cluster
)
add_subdirectory
(
profile
)
add_subdirectory
(
show
)
# add_subdirectory(acct)
# add_subdirectory(cluster)
# add_subdirectory(profile)
# add_subdirectory(show)
add_subdirectory
(
user
)
source/dnode/mgmt/impl/test/cluster/cluster.cpp
浏览文件 @
55f100e2
...
...
@@ -93,21 +93,21 @@ TEST_F(DndTestCluster, ShowCluster) {
EXPECT_EQ
(
pMeta
->
suid
,
0
);
SSchema
*
pSchema
=
NULL
;
pSchema
=
&
pMeta
->
s
chema
[
0
];
pSchema
=
&
pMeta
->
pS
chema
[
0
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_INT
);
EXPECT_EQ
(
pSchema
->
bytes
,
4
);
EXPECT_STREQ
(
pSchema
->
name
,
"id"
);
pSchema
=
&
pMeta
->
s
chema
[
1
];
pSchema
=
&
pMeta
->
pS
chema
[
1
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_BINARY
);
EXPECT_EQ
(
pSchema
->
bytes
,
TSDB_CLUSTER_ID_LEN
+
VARSTR_HEADER_SIZE
);
EXPECT_STREQ
(
pSchema
->
name
,
"name"
);
pSchema
=
&
pMeta
->
s
chema
[
2
];
pSchema
=
&
pMeta
->
pS
chema
[
2
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_TIMESTAMP
);
...
...
source/dnode/mgmt/impl/test/profile/profile.cpp
浏览文件 @
55f100e2
...
...
@@ -152,49 +152,49 @@ TEST_F(DndTestProfile, SConnectMsg_03) {
EXPECT_EQ
(
pMeta
->
suid
,
0
);
SSchema
*
pSchema
=
NULL
;
pSchema
=
&
pMeta
->
s
chema
[
0
];
pSchema
=
&
pMeta
->
pS
chema
[
0
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_INT
);
EXPECT_EQ
(
pSchema
->
bytes
,
4
);
EXPECT_STREQ
(
pSchema
->
name
,
"connId"
);
pSchema
=
&
pMeta
->
s
chema
[
1
];
pSchema
=
&
pMeta
->
pS
chema
[
1
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_BINARY
);
EXPECT_EQ
(
pSchema
->
bytes
,
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
);
EXPECT_STREQ
(
pSchema
->
name
,
"user"
);
pSchema
=
&
pMeta
->
s
chema
[
2
];
pSchema
=
&
pMeta
->
pS
chema
[
2
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_BINARY
);
EXPECT_EQ
(
pSchema
->
bytes
,
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
);
EXPECT_STREQ
(
pSchema
->
name
,
"program"
);
pSchema
=
&
pMeta
->
s
chema
[
3
];
pSchema
=
&
pMeta
->
pS
chema
[
3
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_INT
);
EXPECT_EQ
(
pSchema
->
bytes
,
4
);
EXPECT_STREQ
(
pSchema
->
name
,
"pid"
);
pSchema
=
&
pMeta
->
s
chema
[
4
];
pSchema
=
&
pMeta
->
pS
chema
[
4
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_BINARY
);
EXPECT_EQ
(
pSchema
->
bytes
,
TSDB_IPv4ADDR_LEN
+
6
+
VARSTR_HEADER_SIZE
);
EXPECT_STREQ
(
pSchema
->
name
,
"ip:port"
);
pSchema
=
&
pMeta
->
s
chema
[
5
];
pSchema
=
&
pMeta
->
pS
chema
[
5
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_TIMESTAMP
);
EXPECT_EQ
(
pSchema
->
bytes
,
8
);
EXPECT_STREQ
(
pSchema
->
name
,
"login_time"
);
pSchema
=
&
pMeta
->
s
chema
[
6
];
pSchema
=
&
pMeta
->
pS
chema
[
6
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_TIMESTAMP
);
...
...
@@ -493,28 +493,28 @@ TEST_F(DndTestProfile, SKillQueryMsg_03) {
EXPECT_EQ
(
pMeta
->
suid
,
0
);
SSchema
*
pSchema
=
NULL
;
pSchema
=
&
pMeta
->
s
chema
[
0
];
pSchema
=
&
pMeta
->
pS
chema
[
0
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_INT
);
EXPECT_EQ
(
pSchema
->
bytes
,
4
);
EXPECT_STREQ
(
pSchema
->
name
,
"queryId"
);
pSchema
=
&
pMeta
->
s
chema
[
1
];
pSchema
=
&
pMeta
->
pS
chema
[
1
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_INT
);
EXPECT_EQ
(
pSchema
->
bytes
,
4
);
EXPECT_STREQ
(
pSchema
->
name
,
"connId"
);
pSchema
=
&
pMeta
->
s
chema
[
2
];
pSchema
=
&
pMeta
->
pS
chema
[
2
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_BINARY
);
EXPECT_EQ
(
pSchema
->
bytes
,
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
);
EXPECT_STREQ
(
pSchema
->
name
,
"user"
);
pSchema
=
&
pMeta
->
s
chema
[
3
];
pSchema
=
&
pMeta
->
pS
chema
[
3
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_BINARY
);
...
...
@@ -680,21 +680,21 @@ TEST_F(DndTestProfile, SKillStreamMsg_03) {
EXPECT_EQ
(
pMeta
->
suid
,
0
);
SSchema
*
pSchema
=
NULL
;
pSchema
=
&
pMeta
->
s
chema
[
0
];
pSchema
=
&
pMeta
->
pS
chema
[
0
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_INT
);
EXPECT_EQ
(
pSchema
->
bytes
,
4
);
EXPECT_STREQ
(
pSchema
->
name
,
"streamId"
);
pSchema
=
&
pMeta
->
s
chema
[
1
];
pSchema
=
&
pMeta
->
pS
chema
[
1
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_INT
);
EXPECT_EQ
(
pSchema
->
bytes
,
4
);
EXPECT_STREQ
(
pSchema
->
name
,
"connId"
);
pSchema
=
&
pMeta
->
s
chema
[
2
];
pSchema
=
&
pMeta
->
pS
chema
[
2
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_BINARY
);
...
...
source/dnode/mgmt/impl/test/show/show.cpp
浏览文件 @
55f100e2
...
...
@@ -154,49 +154,49 @@ TEST_F(DndTestShow, SShowMsg_04) {
EXPECT_EQ
(
pMeta
->
suid
,
0
);
SSchema
*
pSchema
=
NULL
;
pSchema
=
&
pMeta
->
s
chema
[
0
];
pSchema
=
&
pMeta
->
pS
chema
[
0
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_INT
);
EXPECT_EQ
(
pSchema
->
bytes
,
4
);
EXPECT_STREQ
(
pSchema
->
name
,
"connId"
);
pSchema
=
&
pMeta
->
s
chema
[
1
];
pSchema
=
&
pMeta
->
pS
chema
[
1
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_BINARY
);
EXPECT_EQ
(
pSchema
->
bytes
,
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
);
EXPECT_STREQ
(
pSchema
->
name
,
"user"
);
pSchema
=
&
pMeta
->
s
chema
[
2
];
pSchema
=
&
pMeta
->
pS
chema
[
2
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_BINARY
);
EXPECT_EQ
(
pSchema
->
bytes
,
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
);
EXPECT_STREQ
(
pSchema
->
name
,
"program"
);
pSchema
=
&
pMeta
->
s
chema
[
3
];
pSchema
=
&
pMeta
->
pS
chema
[
3
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_INT
);
EXPECT_EQ
(
pSchema
->
bytes
,
4
);
EXPECT_STREQ
(
pSchema
->
name
,
"pid"
);
pSchema
=
&
pMeta
->
s
chema
[
4
];
pSchema
=
&
pMeta
->
pS
chema
[
4
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_BINARY
);
EXPECT_EQ
(
pSchema
->
bytes
,
TSDB_IPv4ADDR_LEN
+
6
+
VARSTR_HEADER_SIZE
);
EXPECT_STREQ
(
pSchema
->
name
,
"ip:port"
);
pSchema
=
&
pMeta
->
s
chema
[
5
];
pSchema
=
&
pMeta
->
pS
chema
[
5
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_TIMESTAMP
);
EXPECT_EQ
(
pSchema
->
bytes
,
8
);
EXPECT_STREQ
(
pSchema
->
name
,
"login_time"
);
pSchema
=
&
pMeta
->
s
chema
[
6
];
pSchema
=
&
pMeta
->
pS
chema
[
6
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_TIMESTAMP
);
...
...
source/dnode/mgmt/impl/test/sut/deploy.cpp
浏览文件 @
55f100e2
...
...
@@ -33,7 +33,6 @@ void initLog(const char* path) {
sDebugFlag
=
0
;
tsdbDebugFlag
=
0
;
cqDebugFlag
=
0
;
debugFlag
=
0
;
char
temp
[
PATH_MAX
];
snprintf
(
temp
,
PATH_MAX
,
"%s/taosdlog"
,
path
);
...
...
source/dnode/mgmt/impl/test/user/CMakeLists.txt
0 → 100644
浏览文件 @
55f100e2
add_executable
(
dndTestUser
""
)
target_sources
(
dndTestUser
PRIVATE
"user.cpp"
"../sut/deploy.cpp"
)
target_link_libraries
(
dndTestUser
PUBLIC dnode
PUBLIC util
PUBLIC os
PUBLIC gtest_main
)
target_include_directories
(
dndTestUser
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/server/dnode/mgmt"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../sut"
)
enable_testing
()
add_test
(
NAME dndTestUser
COMMAND dndTestUser
)
source/dnode/mgmt/impl/test/user/user.cpp
0 → 100644
浏览文件 @
55f100e2
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "deploy.h"
class
DndTestUser
:
public
::
testing
::
Test
{
protected:
void
SetUp
()
override
{}
void
TearDown
()
override
{}
static
void
SetUpTestSuite
()
{
const
char
*
user
=
"root"
;
const
char
*
pass
=
"taosdata"
;
const
char
*
path
=
"/tmp/dndTestUser"
;
const
char
*
fqdn
=
"localhost"
;
uint16_t
port
=
9524
;
pServer
=
createServer
(
path
,
fqdn
,
port
);
ASSERT
(
pServer
);
pClient
=
createClient
(
user
,
pass
,
fqdn
,
port
);
}
static
void
TearDownTestSuite
()
{
dropServer
(
pServer
);
dropClient
(
pClient
);
}
static
SServer
*
pServer
;
static
SClient
*
pClient
;
static
int32_t
connId
;
};
SServer
*
DndTestUser
::
pServer
;
SClient
*
DndTestUser
::
pClient
;
int32_t
DndTestUser
::
connId
;
#if 0
TEST_F(DndTestUser, ShowUser) {
int32_t showId = 0;
//--- meta ---
SShowMsg* pShow = (SShowMsg*)rpcMallocCont(sizeof(SShowMsg));
pShow->type = TSDB_MGMT_TABLE_USER;
strcpy(pShow->db, "");
SRpcMsg showRpcMsg = {0};
showRpcMsg.pCont = pShow;
showRpcMsg.contLen = sizeof(SShowMsg);
showRpcMsg.msgType = TSDB_MSG_TYPE_SHOW;
sendMsg(pClient, &showRpcMsg);
ASSERT_NE(pClient->pRsp, nullptr);
SShowRsp* pShowRsp = (SShowRsp*)pClient->pRsp->pCont;
ASSERT_NE(pShowRsp, nullptr);
pShowRsp->showId = htonl(pShowRsp->showId);
STableMetaMsg* pMeta = &pShowRsp->tableMeta;
pMeta->contLen = htonl(pMeta->contLen);
pMeta->numOfColumns = htons(pMeta->numOfColumns);
pMeta->sversion = htons(pMeta->sversion);
pMeta->tversion = htons(pMeta->tversion);
pMeta->tid = htonl(pMeta->tid);
pMeta->uid = htobe64(pMeta->uid);
pMeta->suid = htobe64(pMeta->suid);
showId = pShowRsp->showId;
EXPECT_NE(pShowRsp->showId, 0);
EXPECT_EQ(pMeta->contLen, 0);
EXPECT_STREQ(pMeta->tableFname, "show users");
EXPECT_EQ(pMeta->numOfTags, 0);
EXPECT_EQ(pMeta->precision, 0);
EXPECT_EQ(pMeta->tableType, 0);
EXPECT_EQ(pMeta->numOfColumns, 4);
EXPECT_EQ(pMeta->sversion, 0);
EXPECT_EQ(pMeta->tversion, 0);
EXPECT_EQ(pMeta->tid, 0);
EXPECT_EQ(pMeta->uid, 0);
EXPECT_STREQ(pMeta->sTableName, "");
EXPECT_EQ(pMeta->suid, 0);
SSchema* pSchema = NULL;
pSchema = &pMeta->pSchema[0];
pSchema->bytes = htons(pSchema->bytes);
EXPECT_EQ(pSchema->colId, 0);
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BINARY);
EXPECT_EQ(pSchema->bytes, TSDB_USER_LEN + VARSTR_HEADER_SIZE);
EXPECT_STREQ(pSchema->name, "name");
pSchema = &pMeta->pSchema[1];
pSchema->bytes = htons(pSchema->bytes);
EXPECT_EQ(pSchema->colId, 0);
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BINARY);
EXPECT_EQ(pSchema->bytes, 10 + VARSTR_HEADER_SIZE);
EXPECT_STREQ(pSchema->name, "privilege");
pSchema = &pMeta->pSchema[2];
pSchema->bytes = htons(pSchema->bytes);
EXPECT_EQ(pSchema->colId, 0);
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_TIMESTAMP);
EXPECT_EQ(pSchema->bytes, 8);
EXPECT_STREQ(pSchema->name, "create_time");
pSchema = &pMeta->pSchema[3];
pSchema->bytes = htons(pSchema->bytes);
EXPECT_EQ(pSchema->colId, 0);
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BINARY);
EXPECT_EQ(pSchema->bytes, TSDB_USER_LEN + VARSTR_HEADER_SIZE);
EXPECT_STREQ(pSchema->name, "account");
//--- retrieve ---
SRetrieveTableMsg* pRetrieve = (SRetrieveTableMsg*)rpcMallocCont(sizeof(SRetrieveTableMsg));
pRetrieve->showId = htonl(showId);
pRetrieve->free = 0;
SRpcMsg retrieveRpcMsg = {0};
retrieveRpcMsg.pCont = pRetrieve;
retrieveRpcMsg.contLen = sizeof(SRetrieveTableMsg);
retrieveRpcMsg.msgType = TSDB_MSG_TYPE_SHOW_RETRIEVE;
sendMsg(pClient, &retrieveRpcMsg);
ASSERT_NE(pClient->pRsp, nullptr);
ASSERT_EQ(pClient->pRsp->code, 0);
SRetrieveTableRsp* pRetrieveRsp = (SRetrieveTableRsp*)pClient->pRsp->pCont;
ASSERT_NE(pRetrieveRsp, nullptr);
pRetrieveRsp->numOfRows = htonl(pRetrieveRsp->numOfRows);
pRetrieveRsp->offset = htobe64(pRetrieveRsp->offset);
pRetrieveRsp->useconds = htobe64(pRetrieveRsp->useconds);
pRetrieveRsp->compLen = htonl(pRetrieveRsp->compLen);
EXPECT_EQ(pRetrieveRsp->numOfRows, 2);
EXPECT_EQ(pRetrieveRsp->offset, 0);
EXPECT_EQ(pRetrieveRsp->useconds, 0);
EXPECT_EQ(pRetrieveRsp->completed, 1);
EXPECT_EQ(pRetrieveRsp->precision, TSDB_TIME_PRECISION_MILLI);
EXPECT_EQ(pRetrieveRsp->compressed, 0);
EXPECT_EQ(pRetrieveRsp->reserved, 0);
EXPECT_EQ(pRetrieveRsp->compLen, 0);
char* pData = pRetrieveRsp->data;
int32_t pos = 0;
char* strVal = NULL;
int64_t int64Val = 0;
//--- name ---
{
pos += sizeof(VarDataLenT);
strVal = (char*)(pData + pos);
pos += TSDB_USER_LEN;
EXPECT_STREQ(strVal, "root");
pos += sizeof(VarDataLenT);
strVal = (char*)(pData + pos);
pos += TSDB_USER_LEN;
EXPECT_STREQ(strVal, "_root");
}
//--- privilege ---
{
pos += sizeof(VarDataLenT);
strVal = (char*)(pData + pos);
pos += 10;
EXPECT_STREQ(strVal, "super");
pos += sizeof(VarDataLenT);
strVal = (char*)(pData + pos);
pos += 10;
EXPECT_STREQ(strVal, "writable");
}
//--- create_time ---
{
int64Val = *((int64_t*)(pData + pos));
pos += sizeof(int64_t);
EXPECT_GT(int64Val, 0);
int64Val = *((int64_t*)(pData + pos));
pos += sizeof(int64_t);
EXPECT_GT(int64Val, 0);
}
//--- account ---
{
pos += sizeof(VarDataLenT);
strVal = (char*)(pData + pos);
pos += TSDB_USER_LEN;
EXPECT_STREQ(strVal, "root");
pos += sizeof(VarDataLenT);
strVal = (char*)(pData + pos);
pos += TSDB_USER_LEN;
EXPECT_STREQ(strVal, "root");
}
}
#endif
TEST_F
(
DndTestUser
,
CreateUser_01
)
{
ASSERT_NE
(
pClient
,
nullptr
);
//--- create user ---
SCreateUserMsg
*
pReq
=
(
SCreateUserMsg
*
)
rpcMallocCont
(
sizeof
(
SCreateUserMsg
));
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
"p1"
);
SRpcMsg
rpcMsg
=
{
0
};
rpcMsg
.
pCont
=
pReq
;
rpcMsg
.
contLen
=
sizeof
(
SCreateUserMsg
);
rpcMsg
.
msgType
=
TSDB_MSG_TYPE_CREATE_USER
;
sendMsg
(
pClient
,
&
rpcMsg
);
SRpcMsg
*
pMsg
=
pClient
->
pRsp
;
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
//--- meta ---
SShowMsg
*
pShow
=
(
SShowMsg
*
)
rpcMallocCont
(
sizeof
(
SShowMsg
));
pShow
->
type
=
TSDB_MGMT_TABLE_USER
;
SRpcMsg
showRpcMsg
=
{
0
};
showRpcMsg
.
pCont
=
pShow
;
showRpcMsg
.
contLen
=
sizeof
(
SShowMsg
);
showRpcMsg
.
msgType
=
TSDB_MSG_TYPE_SHOW
;
sendMsg
(
pClient
,
&
showRpcMsg
);
SShowRsp
*
pShowRsp
=
(
SShowRsp
*
)
pClient
->
pRsp
->
pCont
;
STableMetaMsg
*
pMeta
=
&
pShowRsp
->
tableMeta
;
pMeta
->
numOfColumns
=
htons
(
pMeta
->
numOfColumns
);
EXPECT_EQ
(
pMeta
->
numOfColumns
,
4
);
//--- retrieve ---
SRetrieveTableMsg
*
pRetrieve
=
(
SRetrieveTableMsg
*
)
rpcMallocCont
(
sizeof
(
SRetrieveTableMsg
));
pRetrieve
->
showId
=
pShowRsp
->
showId
;
SRpcMsg
retrieveRpcMsg
=
{
0
};
retrieveRpcMsg
.
pCont
=
pRetrieve
;
retrieveRpcMsg
.
contLen
=
sizeof
(
SRetrieveTableMsg
);
retrieveRpcMsg
.
msgType
=
TSDB_MSG_TYPE_SHOW_RETRIEVE
;
sendMsg
(
pClient
,
&
retrieveRpcMsg
);
SRetrieveTableRsp
*
pRetrieveRsp
=
(
SRetrieveTableRsp
*
)
pClient
->
pRsp
->
pCont
;
pRetrieveRsp
->
numOfRows
=
htonl
(
pRetrieveRsp
->
numOfRows
);
EXPECT_EQ
(
pRetrieveRsp
->
numOfRows
,
3
);
char
*
pData
=
pRetrieveRsp
->
data
;
int32_t
pos
=
0
;
char
*
strVal
=
NULL
;
//--- name ---
{
pos
+=
sizeof
(
VarDataLenT
);
strVal
=
(
char
*
)(
pData
+
pos
);
pos
+=
TSDB_USER_LEN
;
EXPECT_STREQ
(
strVal
,
"u1"
);
pos
+=
sizeof
(
VarDataLenT
);
strVal
=
(
char
*
)(
pData
+
pos
);
pos
+=
TSDB_USER_LEN
;
EXPECT_STREQ
(
strVal
,
"root"
);
pos
+=
sizeof
(
VarDataLenT
);
strVal
=
(
char
*
)(
pData
+
pos
);
pos
+=
TSDB_USER_LEN
;
EXPECT_STREQ
(
strVal
,
"_root"
);
}
}
TEST_F
(
DndTestUser
,
AlterUser_01
)
{
ASSERT_NE
(
pClient
,
nullptr
);
//--- drop user ---
SAlterUserMsg
*
pReq
=
(
SAlterUserMsg
*
)
rpcMallocCont
(
sizeof
(
SAlterUserMsg
));
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
"p2"
);
SRpcMsg
rpcMsg
=
{
0
};
rpcMsg
.
pCont
=
pReq
;
rpcMsg
.
contLen
=
sizeof
(
SAlterUserMsg
);
rpcMsg
.
msgType
=
TSDB_MSG_TYPE_ALTER_USER
;
sendMsg
(
pClient
,
&
rpcMsg
);
SRpcMsg
*
pMsg
=
pClient
->
pRsp
;
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
//--- meta ---
SShowMsg
*
pShow
=
(
SShowMsg
*
)
rpcMallocCont
(
sizeof
(
SShowMsg
));
pShow
->
type
=
TSDB_MGMT_TABLE_USER
;
SRpcMsg
showRpcMsg
=
{
0
};
showRpcMsg
.
pCont
=
pShow
;
showRpcMsg
.
contLen
=
sizeof
(
SShowMsg
);
showRpcMsg
.
msgType
=
TSDB_MSG_TYPE_SHOW
;
sendMsg
(
pClient
,
&
showRpcMsg
);
SShowRsp
*
pShowRsp
=
(
SShowRsp
*
)
pClient
->
pRsp
->
pCont
;
STableMetaMsg
*
pMeta
=
&
pShowRsp
->
tableMeta
;
pMeta
->
numOfColumns
=
htons
(
pMeta
->
numOfColumns
);
EXPECT_EQ
(
pMeta
->
numOfColumns
,
4
);
//--- retrieve ---
SRetrieveTableMsg
*
pRetrieve
=
(
SRetrieveTableMsg
*
)
rpcMallocCont
(
sizeof
(
SRetrieveTableMsg
));
pRetrieve
->
showId
=
pShowRsp
->
showId
;
SRpcMsg
retrieveRpcMsg
=
{
0
};
retrieveRpcMsg
.
pCont
=
pRetrieve
;
retrieveRpcMsg
.
contLen
=
sizeof
(
SRetrieveTableMsg
);
retrieveRpcMsg
.
msgType
=
TSDB_MSG_TYPE_SHOW_RETRIEVE
;
sendMsg
(
pClient
,
&
retrieveRpcMsg
);
SRetrieveTableRsp
*
pRetrieveRsp
=
(
SRetrieveTableRsp
*
)
pClient
->
pRsp
->
pCont
;
pRetrieveRsp
->
numOfRows
=
htonl
(
pRetrieveRsp
->
numOfRows
);
EXPECT_EQ
(
pRetrieveRsp
->
numOfRows
,
3
);
char
*
pData
=
pRetrieveRsp
->
data
;
int32_t
pos
=
0
;
char
*
strVal
=
NULL
;
//--- name ---
{
pos
+=
sizeof
(
VarDataLenT
);
strVal
=
(
char
*
)(
pData
+
pos
);
pos
+=
TSDB_USER_LEN
;
EXPECT_STREQ
(
strVal
,
"u1"
);
pos
+=
sizeof
(
VarDataLenT
);
strVal
=
(
char
*
)(
pData
+
pos
);
pos
+=
TSDB_USER_LEN
;
EXPECT_STREQ
(
strVal
,
"root"
);
pos
+=
sizeof
(
VarDataLenT
);
strVal
=
(
char
*
)(
pData
+
pos
);
pos
+=
TSDB_USER_LEN
;
EXPECT_STREQ
(
strVal
,
"_root"
);
}
}
TEST_F
(
DndTestUser
,
DropUser_01
)
{
ASSERT_NE
(
pClient
,
nullptr
);
//--- drop user ---
SDropUserMsg
*
pReq
=
(
SDropUserMsg
*
)
rpcMallocCont
(
sizeof
(
SDropUserMsg
));
strcpy
(
pReq
->
user
,
"u1"
);
SRpcMsg
rpcMsg
=
{
0
};
rpcMsg
.
pCont
=
pReq
;
rpcMsg
.
contLen
=
sizeof
(
SDropUserMsg
);
rpcMsg
.
msgType
=
TSDB_MSG_TYPE_DROP_USER
;
sendMsg
(
pClient
,
&
rpcMsg
);
SRpcMsg
*
pMsg
=
pClient
->
pRsp
;
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
//--- meta ---
SShowMsg
*
pShow
=
(
SShowMsg
*
)
rpcMallocCont
(
sizeof
(
SShowMsg
));
pShow
->
type
=
TSDB_MGMT_TABLE_USER
;
SRpcMsg
showRpcMsg
=
{
0
};
showRpcMsg
.
pCont
=
pShow
;
showRpcMsg
.
contLen
=
sizeof
(
SShowMsg
);
showRpcMsg
.
msgType
=
TSDB_MSG_TYPE_SHOW
;
sendMsg
(
pClient
,
&
showRpcMsg
);
SShowRsp
*
pShowRsp
=
(
SShowRsp
*
)
pClient
->
pRsp
->
pCont
;
STableMetaMsg
*
pMeta
=
&
pShowRsp
->
tableMeta
;
pMeta
->
numOfColumns
=
htons
(
pMeta
->
numOfColumns
);
EXPECT_EQ
(
pMeta
->
numOfColumns
,
4
);
//--- retrieve ---
SRetrieveTableMsg
*
pRetrieve
=
(
SRetrieveTableMsg
*
)
rpcMallocCont
(
sizeof
(
SRetrieveTableMsg
));
pRetrieve
->
showId
=
pShowRsp
->
showId
;
SRpcMsg
retrieveRpcMsg
=
{
0
};
retrieveRpcMsg
.
pCont
=
pRetrieve
;
retrieveRpcMsg
.
contLen
=
sizeof
(
SRetrieveTableMsg
);
retrieveRpcMsg
.
msgType
=
TSDB_MSG_TYPE_SHOW_RETRIEVE
;
sendMsg
(
pClient
,
&
retrieveRpcMsg
);
SRetrieveTableRsp
*
pRetrieveRsp
=
(
SRetrieveTableRsp
*
)
pClient
->
pRsp
->
pCont
;
pRetrieveRsp
->
numOfRows
=
htonl
(
pRetrieveRsp
->
numOfRows
);
EXPECT_EQ
(
pRetrieveRsp
->
numOfRows
,
2
);
char
*
pData
=
pRetrieveRsp
->
data
;
int32_t
pos
=
0
;
char
*
strVal
=
NULL
;
//--- name ---
{
pos
+=
sizeof
(
VarDataLenT
);
strVal
=
(
char
*
)(
pData
+
pos
);
pos
+=
TSDB_USER_LEN
;
EXPECT_STREQ
(
strVal
,
"root"
);
pos
+=
sizeof
(
VarDataLenT
);
strVal
=
(
char
*
)(
pData
+
pos
);
pos
+=
TSDB_USER_LEN
;
EXPECT_STREQ
(
strVal
,
"_root"
);
}
}
\ No newline at end of file
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
55f100e2
...
...
@@ -47,7 +47,6 @@ typedef struct SAcctObj SAcctObj;
typedef
struct
SUserObj
SUserObj
;
typedef
struct
SDbObj
SDbObj
;
typedef
struct
SVgObj
SVgObj
;
typedef
struct
SSTableObj
SSTableObj
;
typedef
struct
SFuncObj
SFuncObj
;
typedef
struct
SOperObj
SOperObj
;
...
...
@@ -195,7 +194,6 @@ typedef struct SUserObj {
typedef
struct
{
int32_t
cacheBlockSize
;
int32_t
totalBlocks
;
int32_t
maxTables
;
int32_t
daysPerFile
;
int32_t
daysToKeep0
;
int32_t
daysToKeep1
;
...
...
@@ -204,102 +202,91 @@ typedef struct {
int32_t
maxRowsPerFileBlock
;
int32_t
commitTime
;
int32_t
fsyncPeriod
;
int8_t
walLevel
;
int8_t
precision
;
int8_t
compression
;
int8_t
walLevel
;
int8_t
replications
;
int8_t
quorum
;
int8_t
update
;
int8_t
cacheLastRow
;
int8_t
dbType
;
int16_t
partitions
;
}
SDbCfg
;
typedef
struct
SDbObj
{
char
name
[
TSDB_FULL_DB_NAME_LEN
];
char
acct
[
TSDB_USER_LEN
];
int64_t
createdTime
;
int64_t
updateTime
;
SDbCfg
cfg
;
int64_t
uid
;
int8_t
status
;
int32_t
numOfVgroups
;
int32_t
numOfTables
;
int32_t
numOfSuperTables
;
int32_t
vgListSize
;
int32_t
vgListIndex
;
SVgObj
**
vgList
;
SAcctObj
*
pAcct
;
char
name
[
TSDB_FULL_DB_NAME_LEN
];
char
acct
[
TSDB_USER_LEN
];
int64_t
createdTime
;
int64_t
updateTime
;
int64_t
uid
;
SDbCfg
cfg
;
}
SDbObj
;
typedef
struct
{
int32_t
dnodeId
;
int8_t
role
;
SDnodeObj
*
pDnode
;
ESyncState
role
;
}
SVnodeGid
;
typedef
struct
SVgObj
{
uint32_t
vgId
;
int32_t
numOfVnodes
;
int32_t
vgId
;
int64_t
createdTime
;
int64_t
updateTime
;
int32_t
lbDnodeId
;
int32_t
lbTime
;
int32_t
version
;
char
dbName
[
TSDB_FULL_DB_NAME_LEN
];
int8_t
inUse
;
int8_t
accessState
;
int8_t
status
;
SVnodeGid
vnodeGid
[
TSDB_MAX_REPLICA
];
int32_t
vgCfgVersion
;
int8_t
compact
;
int32_t
numOfTables
;
int32_t
numOfTimeSeries
;
int64_t
totalStorage
;
int64_t
compStorage
;
int64_t
pointsWritten
;
SDbObj
*
pDb
;
int8_t
compact
;
int8_t
replica
;
SVnodeGid
vnodeGid
[
TSDB_MAX_REPLICA
];
}
SVgObj
;
typedef
struct
SS
T
ableObj
{
char
tableId
[
TSDB_TABLE_
NAME_LEN
];
uint64_t
uid
;
typedef
struct
SS
t
ableObj
{
char
name
[
TSDB_TABLE_F
NAME_LEN
];
char
db
[
TSDB_FULL_DB_NAME_LEN
]
;
int64_t
createdTime
;
int64_t
updateTime
;
int32_t
numOfColumns
;
// used by normal table
uint64_t
uid
;
int32_t
version
;
int32_t
numOfColumns
;
int32_t
numOfTags
;
SSchema
*
schema
;
}
SSTableObj
;
SRWLatch
lock
;
SSchema
*
columnSchema
;
SSchema
*
tagSchema
;
}
SStableObj
;
typedef
struct
SFuncObj
{
char
name
[
TSDB_FUNC_NAME_LEN
];
char
path
[
128
];
int32_t
contLen
;
char
cont
[
TSDB_FUNC_CODE_LEN
];
int32_t
funcType
;
int32_t
bufSize
;
int64_t
createdTime
;
uint8_t
resType
;
int16_t
resBytes
;
int64_t
sig
;
int16_t
type
;
int8_t
funcType
;
int8_t
scriptType
;
int8_t
align
;
int8_t
outputType
;
int32_t
outputLen
;
int32_t
bufSize
;
int64_t
sigature
;
int32_t
commentSize
;
int32_t
codeSize
;
char
*
pComment
;
char
*
pCode
;
char
pData
[];
}
SFuncObj
;
typedef
struct
SShowObj
SShowObj
;
typedef
struct
SShowObj
{
int8_t
type
;
int8_t
maxReplica
;
int16_t
numOfColumns
;
int32_t
id
;
int32_t
rowSize
;
int32_t
numOfRows
;
int32_t
numOfReads
;
uint16_t
payloadLen
;
void
*
pIter
;
void
*
pVgIter
;
SMnode
*
pMnode
;
char
db
[
TSDB_FULL_DB_NAME_LEN
];
int16_t
offset
[
TSDB_MAX_COLUMNS
];
int32_t
bytes
[
TSDB_MAX_COLUMNS
];
char
payload
[];
typedef
struct
{
int32_t
id
;
int8_t
type
;
int8_t
replica
;
int16_t
numOfColumns
;
int32_t
rowSize
;
int32_t
numOfRows
;
int32_t
numOfReads
;
int32_t
payloadLen
;
void
*
pIter
;
SMnode
*
pMnode
;
char
db
[
TSDB_FULL_DB_NAME_LEN
];
int16_t
offset
[
TSDB_MAX_COLUMNS
];
int32_t
bytes
[
TSDB_MAX_COLUMNS
];
char
payload
[];
}
SShowObj
;
typedef
struct
SMnodeMsg
{
...
...
@@ -318,6 +305,11 @@ typedef struct SMnodeMsg {
void
*
pCont
;
}
SMnodeMsg
;
typedef
struct
{
int32_t
id
;
void
*
rpcHandle
;
}
STransMsg
;
#ifdef __cplusplus
}
#endif
...
...
source/dnode/mnode/impl/inc/mndDnode.h
浏览文件 @
55f100e2
...
...
@@ -26,6 +26,8 @@ int32_t mndInitDnode(SMnode *pMnode);
void
mndCleanupDnode
(
SMnode
*
pMnode
);
SDnodeObj
*
mndAcquireDnode
(
SMnode
*
pMnode
,
int32_t
dnodeId
);
void
mndReleaseDnode
(
SMnode
*
pMnode
,
SDnodeObj
*
pDnode
);
SEpSet
mndGetDnodeEpset
(
SDnodeObj
*
pDnode
);
int32_t
mndGetDnodeSize
(
SMnode
*
pMnode
);
#ifdef __cplusplus
}
...
...
source/dnode/mnode/impl/inc/mndInt.h
浏览文件 @
55f100e2
...
...
@@ -20,6 +20,7 @@
#include "sdb.h"
#include "tcache.h"
#include "tqueue.h"
#include "ttime.h"
#ifdef __cplusplus
extern
"C"
{
...
...
source/dnode/mnode/impl/inc/mndMnode.h
浏览文件 @
55f100e2
...
...
@@ -26,6 +26,7 @@ int32_t mndInitMnode(SMnode *pMnode);
void
mndCleanupMnode
(
SMnode
*
pMnode
);
bool
mndIsMnode
(
SMnode
*
pMnode
,
int32_t
dnodeId
);
void
mndGetMnodeEpSet
(
SMnode
*
pMnode
,
SEpSet
*
pEpSet
);
char
*
mndGetRoleStr
(
int32_t
role
);
#ifdef __cplusplus
}
...
...
source/dnode/mnode/impl/inc/mndOper.h
已删除
100644 → 0
浏览文件 @
8c416a5e
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_MND_OPER_H_
#define _TD_MND_OPER_H_
#ifdef __cplusplus
extern
"C"
{
#endif
int32_t
mndInitOper
(
SMnode
*
pMnode
);
void
mndCleanupOper
(
SMnode
*
pMnode
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_MND_OPER_H_*/
source/dnode/mnode/impl/inc/mndShow.h
浏览文件 @
55f100e2
...
...
@@ -28,6 +28,7 @@ void mndAddShowMetaHandle(SMnode *pMnode, EShowType showType, ShowMetaFp fp);
void
mndAddShowRetrieveHandle
(
SMnode
*
pMnode
,
EShowType
showType
,
ShowRetrieveFp
fp
);
void
mndAddShowFreeIterHandle
(
SMnode
*
pMnode
,
EShowType
msgType
,
ShowFreeIterFp
fp
);
void
mnodeVacuumResult
(
char
*
data
,
int32_t
numOfCols
,
int32_t
rows
,
int32_t
capacity
,
SShowObj
*
pShow
);
char
*
mndShowStr
(
int32_t
showType
);
#ifdef __cplusplus
}
...
...
source/dnode/mnode/impl/inc/mndSync.h
浏览文件 @
55f100e2
...
...
@@ -25,7 +25,7 @@ extern "C" {
int32_t
mndInitSync
(
SMnode
*
pMnode
);
void
mndCleanupSync
(
SMnode
*
pMnode
);
bool
mndIsMaster
(
SMnode
*
pMnode
);
int32_t
mndSyncPropose
(
S
SdbRaw
*
pRaw
,
void
*
pData
);
int32_t
mndSyncPropose
(
S
Mnode
*
pMnode
,
SSdbRaw
*
pRaw
,
STransMsg
*
pMsg
);
#ifdef __cplusplus
}
...
...
source/dnode/mnode/impl/inc/mndTrans.h
浏览文件 @
55f100e2
...
...
@@ -33,13 +33,10 @@ int32_t mndTransAppendCommitlog(STrans *pTrans, SSdbRaw *pRaw);
int32_t
mndTransAppendRedoAction
(
STrans
*
pTrans
,
SEpSet
*
,
void
*
pMsg
);
int32_t
mndTransAppendUndoAction
(
STrans
*
pTrans
,
SEpSet
*
,
void
*
pMsg
);
int32_t
mndTransPrepare
(
STrans
*
pTrans
,
int32_t
(
*
syncfp
)(
SSdbRaw
*
pRaw
,
void
*
pData
)
);
int32_t
mndTransApply
(
SMnode
*
pMnode
,
SSdbRaw
*
pRaw
,
void
*
pData
,
int32_t
code
);
int32_t
mndTransPrepare
(
STrans
*
pTrans
);
void
mndTransApply
(
SMnode
*
pMnode
,
SSdbRaw
*
pRaw
,
STransMsg
*
pMsg
,
int32_t
code
);
int32_t
mndTransExecute
(
SSdb
*
pSdb
,
int32_t
tranId
);
SSdbRaw
*
mndTransActionEncode
(
STrans
*
pTrans
);
SSdbRow
*
mndTransActionDecode
(
SSdbRaw
*
pRaw
);
#ifdef __cplusplus
}
#endif
...
...
source/dnode/mnode/impl/inc/mndVgroup.h
浏览文件 @
55f100e2
...
...
@@ -24,6 +24,8 @@ extern "C" {
int32_t
mndInitVgroup
(
SMnode
*
pMnode
);
void
mndCleanupVgroup
(
SMnode
*
pMnode
);
SVgObj
*
mndAcquireVgroup
(
SMnode
*
pMnode
,
int32_t
vgId
);
void
mndReleaseVgroup
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
);
#ifdef __cplusplus
}
...
...
source/dnode/mnode/impl/src/mndAcct.c
浏览文件 @
55f100e2
...
...
@@ -24,7 +24,7 @@ static SSdbRaw *mnodeAcctActionEncode(SAcctObj *pAcct);
static
SSdbRow
*
mnodeAcctActionDecode
(
SSdbRaw
*
pRaw
);
static
int32_t
mnodeAcctActionInsert
(
SSdb
*
pSdb
,
SAcctObj
*
pAcct
);
static
int32_t
mnodeAcctActionDelete
(
SSdb
*
pSdb
,
SAcctObj
*
pAcct
);
static
int32_t
mnodeAcctActionUpdate
(
SSdb
*
pSdb
,
SAcctObj
*
p
SrcAcct
,
SAcctObj
*
pDst
Acct
);
static
int32_t
mnodeAcctActionUpdate
(
SSdb
*
pSdb
,
SAcctObj
*
p
OldAcct
,
SAcctObj
*
pNew
Acct
);
static
int32_t
mndProcessCreateAcctMsg
(
SMnodeMsg
*
pMnodeMsg
);
static
int32_t
mndProcessAlterAcctMsg
(
SMnodeMsg
*
pMnodeMsg
);
static
int32_t
mndProcessDropAcctMsg
(
SMnodeMsg
*
pMnodeMsg
);
...
...
@@ -65,7 +65,7 @@ static int32_t mnodeCreateDefaultAcct(SMnode *pMnode) {
if
(
pRaw
==
NULL
)
return
-
1
;
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_READY
);
m
Trace
(
"acct:%s, will be created while deploy sdb"
,
acctObj
.
acct
);
m
Debug
(
"acct:%s, will be created while deploy sdb"
,
acctObj
.
acct
);
return
sdbWrite
(
pMnode
->
pSdb
,
pRaw
);
}
...
...
@@ -131,15 +131,15 @@ static int32_t mnodeAcctActionDelete(SSdb *pSdb, SAcctObj *pAcct) {
return
0
;
}
static
int32_t
mnodeAcctActionUpdate
(
SSdb
*
pSdb
,
SAcctObj
*
p
SrcAcct
,
SAcctObj
*
pDst
Acct
)
{
mTrace
(
"acct:%s, perform update action"
,
p
Src
Acct
->
acct
);
static
int32_t
mnodeAcctActionUpdate
(
SSdb
*
pSdb
,
SAcctObj
*
p
OldAcct
,
SAcctObj
*
pNew
Acct
)
{
mTrace
(
"acct:%s, perform update action"
,
p
Old
Acct
->
acct
);
memcpy
(
p
SrcAcct
->
acct
,
pDst
Acct
->
acct
,
TSDB_USER_LEN
);
p
SrcAcct
->
createdTime
=
pDst
Acct
->
createdTime
;
p
SrcAcct
->
updateTime
=
pDst
Acct
->
updateTime
;
p
SrcAcct
->
acctId
=
pDst
Acct
->
acctId
;
p
SrcAcct
->
status
=
pDst
Acct
->
status
;
p
SrcAcct
->
cfg
=
pDst
Acct
->
cfg
;
memcpy
(
p
OldAcct
->
acct
,
pNew
Acct
->
acct
,
TSDB_USER_LEN
);
p
OldAcct
->
createdTime
=
pNew
Acct
->
createdTime
;
p
OldAcct
->
updateTime
=
pNew
Acct
->
updateTime
;
p
OldAcct
->
acctId
=
pNew
Acct
->
acctId
;
p
OldAcct
->
status
=
pNew
Acct
->
status
;
p
OldAcct
->
cfg
=
pNew
Acct
->
cfg
;
return
0
;
}
...
...
source/dnode/mnode/impl/src/mndCluster.c
浏览文件 @
55f100e2
...
...
@@ -24,7 +24,7 @@ static SSdbRaw *mndClusterActionEncode(SClusterObj *pCluster);
static
SSdbRow
*
mndClusterActionDecode
(
SSdbRaw
*
pRaw
);
static
int32_t
mndClusterActionInsert
(
SSdb
*
pSdb
,
SClusterObj
*
pCluster
);
static
int32_t
mndClusterActionDelete
(
SSdb
*
pSdb
,
SClusterObj
*
pCluster
);
static
int32_t
mndClusterActionUpdate
(
SSdb
*
pSdb
,
SClusterObj
*
p
SrcCluster
,
SClusterObj
*
pDst
Cluster
);
static
int32_t
mndClusterActionUpdate
(
SSdb
*
pSdb
,
SClusterObj
*
p
OldCluster
,
SClusterObj
*
pNew
Cluster
);
static
int32_t
mndCreateDefaultCluster
(
SMnode
*
pMnode
);
static
int32_t
mndGetClusterMeta
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveClusters
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
...
...
@@ -107,8 +107,8 @@ static int32_t mndClusterActionDelete(SSdb *pSdb, SClusterObj *pCluster) {
return
0
;
}
static
int32_t
mndClusterActionUpdate
(
SSdb
*
pSdb
,
SClusterObj
*
p
SrcCluster
,
SClusterObj
*
pDst
Cluster
)
{
mTrace
(
"cluster:%d, perform update action"
,
p
Src
Cluster
->
id
);
static
int32_t
mndClusterActionUpdate
(
SSdb
*
pSdb
,
SClusterObj
*
p
OldCluster
,
SClusterObj
*
pNew
Cluster
)
{
mTrace
(
"cluster:%d, perform update action"
,
p
Old
Cluster
->
id
);
return
0
;
}
...
...
@@ -132,13 +132,13 @@ static int32_t mndCreateDefaultCluster(SMnode *pMnode) {
if
(
pRaw
==
NULL
)
return
-
1
;
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_READY
);
m
Trace
(
"cluster:%d, will be created while deploy sdb"
,
clusterObj
.
id
);
m
Debug
(
"cluster:%d, will be created while deploy sdb"
,
clusterObj
.
id
);
return
sdbWrite
(
pMnode
->
pSdb
,
pRaw
);
}
static
int32_t
mndGetClusterMeta
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
int32_t
cols
=
0
;
SSchema
*
pSchema
=
pMeta
->
s
chema
;
SSchema
*
pSchema
=
pMeta
->
pS
chema
;
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
55f100e2
此差异已折叠。
点击以展开。
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
55f100e2
此差异已折叠。
点击以展开。
source/dnode/mnode/impl/src/mndFunc.c
浏览文件 @
55f100e2
...
...
@@ -14,8 +14,498 @@
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "mndInt.h"
#include "mndFunc.h"
#include "mndShow.h"
#include "mndSync.h"
#include "mndTrans.h"
int32_t
mndInitFunc
(
SMnode
*
pMnode
)
{
return
0
;
}
void
mndCleanupFunc
(
SMnode
*
pMnode
)
{}
\ No newline at end of file
#define SDB_FUNC_VER 1
static
SSdbRaw
*
mndFuncActionEncode
(
SFuncObj
*
pFunc
);
static
SSdbRow
*
mndFuncActionDecode
(
SSdbRaw
*
pRaw
);
static
int32_t
mndFuncActionInsert
(
SSdb
*
pSdb
,
SFuncObj
*
pFunc
);
static
int32_t
mndFuncActionDelete
(
SSdb
*
pSdb
,
SFuncObj
*
pFunc
);
static
int32_t
mndFuncActionUpdate
(
SSdb
*
pSdb
,
SFuncObj
*
pOldFunc
,
SFuncObj
*
pNewFunc
);
static
int32_t
mndCreateFunc
(
SMnode
*
pMnode
,
SMnodeMsg
*
pMsg
,
SCreateFuncMsg
*
pCreate
);
static
int32_t
mndDropFunc
(
SMnode
*
pMnode
,
SMnodeMsg
*
pMsg
,
SFuncObj
*
pFunc
);
static
int32_t
mndProcessCreateFuncMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessDropFuncMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessRetrieveFuncMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndGetFuncMeta
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveFuncs
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
void
mndCancelGetNextFunc
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitFunc
(
SMnode
*
pMnode
)
{
SSdbTable
table
=
{.
sdbType
=
SDB_FUNC
,
.
keyType
=
SDB_KEY_BINARY
,
.
encodeFp
=
(
SdbEncodeFp
)
mndFuncActionEncode
,
.
decodeFp
=
(
SdbDecodeFp
)
mndFuncActionDecode
,
.
insertFp
=
(
SdbInsertFp
)
mndFuncActionInsert
,
.
updateFp
=
(
SdbUpdateFp
)
mndFuncActionUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
mndFuncActionDelete
};
mndSetMsgHandle
(
pMnode
,
TSDB_MSG_TYPE_CREATE_FUNCTION
,
mndProcessCreateFuncMsg
);
mndSetMsgHandle
(
pMnode
,
TSDB_MSG_TYPE_DROP_FUNCTION
,
mndProcessDropFuncMsg
);
mndSetMsgHandle
(
pMnode
,
TSDB_MSG_TYPE_RETRIEVE_FUNCTION
,
mndProcessRetrieveFuncMsg
);
mndAddShowMetaHandle
(
pMnode
,
TSDB_MGMT_TABLE_FUNCTION
,
mndGetFuncMeta
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_FUNCTION
,
mndRetrieveFuncs
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_FUNCTION
,
mndCancelGetNextFunc
);
return
sdbSetTable
(
pMnode
->
pSdb
,
table
);
}
void
mndCleanupFunc
(
SMnode
*
pMnode
)
{}
static
SSdbRaw
*
mndFuncActionEncode
(
SFuncObj
*
pFunc
)
{
int32_t
size
=
pFunc
->
commentSize
+
pFunc
->
codeSize
+
sizeof
(
SFuncObj
);
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_FUNC
,
SDB_FUNC_VER
,
size
);
if
(
pRaw
==
NULL
)
return
NULL
;
int32_t
dataPos
=
0
;
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pFunc
->
name
,
TSDB_FUNC_NAME_LEN
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pFunc
->
createdTime
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pFunc
->
funcType
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pFunc
->
scriptType
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pFunc
->
align
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pFunc
->
outputType
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pFunc
->
outputLen
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pFunc
->
bufSize
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pFunc
->
sigature
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pFunc
->
commentSize
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pFunc
->
codeSize
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pFunc
->
pComment
,
pFunc
->
commentSize
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pFunc
->
pCode
,
pFunc
->
codeSize
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
);
return
pRaw
;
}
static
SSdbRow
*
mndFuncActionDecode
(
SSdbRaw
*
pRaw
)
{
int8_t
sver
=
0
;
if
(
sdbGetRawSoftVer
(
pRaw
,
&
sver
)
!=
0
)
return
NULL
;
if
(
sver
!=
SDB_FUNC_VER
)
{
mError
(
"failed to decode func since %s"
,
terrstr
());
terrno
=
TSDB_CODE_SDB_INVALID_DATA_VER
;
return
NULL
;
}
int32_t
size
=
sizeof
(
SFuncObj
)
+
TSDB_FUNC_COMMENT_LEN
+
TSDB_FUNC_CODE_LEN
;
SSdbRow
*
pRow
=
sdbAllocRow
(
size
);
SFuncObj
*
pFunc
=
sdbGetRowObj
(
pRow
);
if
(
pFunc
==
NULL
)
return
NULL
;
char
*
tmp
=
(
char
*
)
pFunc
+
sizeof
(
SFuncObj
);
int32_t
dataPos
=
0
;
SDB_GET_BINARY
(
pRaw
,
pRow
,
dataPos
,
pFunc
->
name
,
TSDB_FUNC_NAME_LEN
)
SDB_GET_INT64
(
pRaw
,
pRow
,
dataPos
,
&
pFunc
->
createdTime
)
SDB_GET_INT8
(
pRaw
,
pRow
,
dataPos
,
&
pFunc
->
funcType
)
SDB_GET_INT8
(
pRaw
,
pRow
,
dataPos
,
&
pFunc
->
scriptType
)
SDB_GET_INT8
(
pRaw
,
pRow
,
dataPos
,
&
pFunc
->
align
)
SDB_GET_INT8
(
pRaw
,
pRow
,
dataPos
,
&
pFunc
->
outputType
)
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
pFunc
->
outputLen
)
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
pFunc
->
bufSize
)
SDB_GET_INT64
(
pRaw
,
pRow
,
dataPos
,
&
pFunc
->
sigature
)
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
pFunc
->
commentSize
)
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
pFunc
->
codeSize
)
SDB_GET_BINARY
(
pRaw
,
pRow
,
dataPos
,
pFunc
->
pData
,
pFunc
->
commentSize
+
pFunc
->
codeSize
)
pFunc
->
pComment
=
pFunc
->
pData
;
pFunc
->
pCode
=
(
pFunc
->
pData
+
pFunc
->
commentSize
);
return
pRow
;
}
static
int32_t
mndFuncActionInsert
(
SSdb
*
pSdb
,
SFuncObj
*
pFunc
)
{
mTrace
(
"func:%s, perform insert action"
,
pFunc
->
name
);
return
0
;
}
static
int32_t
mndFuncActionDelete
(
SSdb
*
pSdb
,
SFuncObj
*
pFunc
)
{
mTrace
(
"func:%s, perform delete action"
,
pFunc
->
name
);
return
0
;
}
static
int32_t
mndFuncActionUpdate
(
SSdb
*
pSdb
,
SFuncObj
*
pOldFunc
,
SFuncObj
*
pNewFunc
)
{
mTrace
(
"func:%s, perform update action"
,
pOldFunc
->
name
);
return
0
;
}
static
int32_t
mndCreateFunc
(
SMnode
*
pMnode
,
SMnodeMsg
*
pMsg
,
SCreateFuncMsg
*
pCreate
)
{
SFuncObj
*
pFunc
=
calloc
(
1
,
sizeof
(
SFuncObj
)
+
pCreate
->
commentSize
+
pCreate
->
codeSize
);
pFunc
->
createdTime
=
taosGetTimestampMs
();
pFunc
->
funcType
=
pCreate
->
funcType
;
pFunc
->
scriptType
=
pCreate
->
scriptType
;
pFunc
->
outputType
=
pCreate
->
outputType
;
pFunc
->
outputLen
=
pCreate
->
outputLen
;
pFunc
->
bufSize
=
pCreate
->
bufSize
;
pFunc
->
sigature
=
pCreate
->
sigature
;
pFunc
->
commentSize
=
pCreate
->
commentSize
;
pFunc
->
codeSize
=
pCreate
->
codeSize
;
pFunc
->
pComment
=
pFunc
->
pData
;
memcpy
(
pFunc
->
pComment
,
pCreate
->
pCont
,
pCreate
->
commentSize
);
pFunc
->
pCode
=
pFunc
->
pData
+
pCreate
->
commentSize
;
memcpy
(
pFunc
->
pCode
,
pCreate
->
pCont
+
pCreate
->
commentSize
,
pFunc
->
codeSize
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
pMsg
->
rpcMsg
.
handle
);
if
(
pTrans
==
NULL
)
{
free
(
pFunc
);
mError
(
"func:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
return
-
1
;
}
mDebug
(
"trans:%d, used to create func:%s"
,
pTrans
->
id
,
pCreate
->
name
);
SSdbRaw
*
pRedoRaw
=
mndFuncActionEncode
(
pFunc
);
if
(
pRedoRaw
==
NULL
||
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to append redo log since %s"
,
pTrans
->
id
,
terrstr
());
free
(
pFunc
);
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_CREATING
);
SSdbRaw
*
pUndoRaw
=
mndFuncActionEncode
(
pFunc
);
if
(
pUndoRaw
==
NULL
||
mndTransAppendUndolog
(
pTrans
,
pUndoRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to append undo log since %s"
,
pTrans
->
id
,
terrstr
());
free
(
pFunc
);
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pUndoRaw
,
SDB_STATUS_DROPPED
);
SSdbRaw
*
pCommitRaw
=
mndFuncActionEncode
(
pFunc
);
if
(
pCommitRaw
==
NULL
||
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to append commit log since %s"
,
pTrans
->
id
,
terrstr
());
free
(
pFunc
);
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_READY
);
if
(
mndTransPrepare
(
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
free
(
pFunc
);
mndTransDrop
(
pTrans
);
return
0
;
}
static
int32_t
mndDropFunc
(
SMnode
*
pMnode
,
SMnodeMsg
*
pMsg
,
SFuncObj
*
pFunc
)
{
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
pMsg
->
rpcMsg
.
handle
);
if
(
pTrans
==
NULL
)
{
mError
(
"func:%s, failed to drop since %s"
,
pFunc
->
name
,
terrstr
());
return
-
1
;
}
mDebug
(
"trans:%d, used to drop user:%s"
,
pTrans
->
id
,
pFunc
->
name
);
SSdbRaw
*
pRedoRaw
=
mndFuncActionEncode
(
pFunc
);
if
(
pRedoRaw
==
NULL
||
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to append redo log since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_DROPPING
);
SSdbRaw
*
pUndoRaw
=
mndFuncActionEncode
(
pFunc
);
if
(
pUndoRaw
==
NULL
||
mndTransAppendUndolog
(
pTrans
,
pUndoRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to append undo log since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pUndoRaw
,
SDB_STATUS_READY
);
SSdbRaw
*
pCommitRaw
=
mndFuncActionEncode
(
pFunc
);
if
(
pCommitRaw
==
NULL
||
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to append commit log since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_DROPPED
);
if
(
mndTransPrepare
(
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
mndTransDrop
(
pTrans
);
return
0
;
}
static
int32_t
mndProcessCreateFuncMsg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SCreateFuncMsg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
pCreate
->
outputLen
=
htonl
(
pCreate
->
outputLen
);
pCreate
->
bufSize
=
htonl
(
pCreate
->
bufSize
);
pCreate
->
sigature
=
htobe64
(
pCreate
->
sigature
);
pCreate
->
commentSize
=
htonl
(
pCreate
->
commentSize
);
pCreate
->
codeSize
=
htonl
(
pCreate
->
codeSize
);
mDebug
(
"func:%s, start to create"
,
pCreate
->
name
);
SFuncObj
*
pFunc
=
sdbAcquire
(
pMnode
->
pSdb
,
SDB_FUNC
,
pCreate
->
name
);
if
(
pFunc
!=
NULL
)
{
sdbRelease
(
pMnode
->
pSdb
,
pFunc
);
terrno
=
TSDB_CODE_MND_FUNC_ALREADY_EXIST
;
mError
(
"func:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
return
-
1
;
}
if
(
pCreate
->
name
[
0
]
==
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_FUNC_NAME
;
mError
(
"func:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
return
-
1
;
}
if
(
pCreate
->
commentSize
<=
0
||
pCreate
->
commentSize
>
TSDB_FUNC_COMMENT_LEN
)
{
terrno
=
TSDB_CODE_MND_INVALID_FUNC_COMMENT
;
mError
(
"func:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
return
-
1
;
}
if
(
pCreate
->
codeSize
<=
0
||
pCreate
->
codeSize
>
TSDB_FUNC_CODE_LEN
)
{
terrno
=
TSDB_CODE_MND_INVALID_FUNC_CODE
;
mError
(
"func:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
return
-
1
;
}
if
(
pCreate
->
pCont
[
0
]
==
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_FUNC_CODE
;
mError
(
"func:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
return
-
1
;
}
if
(
pCreate
->
bufSize
<
0
||
pCreate
->
bufSize
>
TSDB_FUNC_BUF_SIZE
)
{
terrno
=
TSDB_CODE_MND_INVALID_FUNC_BUFSIZE
;
mError
(
"func:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
return
-
1
;
}
int32_t
code
=
mndCreateFunc
(
pMnode
,
pMsg
,
pCreate
);
if
(
code
!=
0
)
{
mError
(
"func:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
return
-
1
;
}
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
static
int32_t
mndProcessDropFuncMsg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SDropFuncMsg
*
pDrop
=
pMsg
->
rpcMsg
.
pCont
;
mDebug
(
"func:%s, start to drop"
,
pDrop
->
name
);
if
(
pDrop
->
name
[
0
]
==
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_FUNC_NAME
;
mError
(
"func:%s, failed to drop since %s"
,
pDrop
->
name
,
terrstr
());
return
-
1
;
}
SFuncObj
*
pFunc
=
sdbAcquire
(
pMnode
->
pSdb
,
SDB_FUNC
,
pDrop
->
name
);
if
(
pFunc
==
NULL
)
{
terrno
=
TSDB_CODE_MND_FUNC_NOT_EXIST
;
mError
(
"func:%s, failed to drop since %s"
,
pDrop
->
name
,
terrstr
());
return
-
1
;
}
int32_t
code
=
mndDropFunc
(
pMnode
,
pMsg
,
pFunc
);
if
(
code
!=
0
)
{
mError
(
"func:%s, failed to drop since %s"
,
pDrop
->
name
,
terrstr
());
return
-
1
;
}
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
static
int32_t
mndProcessRetrieveFuncMsg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SRetrieveFuncMsg
*
pRetrieve
=
pMsg
->
rpcMsg
.
pCont
;
pRetrieve
->
numOfFuncs
=
htonl
(
pRetrieve
->
numOfFuncs
);
int32_t
size
=
sizeof
(
SRetrieveFuncRsp
)
+
(
sizeof
(
SFuncInfo
)
+
TSDB_FUNC_CODE_LEN
)
*
pRetrieve
->
numOfFuncs
+
16384
;
SRetrieveFuncRsp
*
pRetrieveRsp
=
rpcMallocCont
(
size
);
pRetrieveRsp
->
numOfFuncs
=
htonl
(
pRetrieve
->
numOfFuncs
);
char
*
pOutput
=
pRetrieveRsp
->
pFuncInfos
;
for
(
int32_t
i
=
0
;
i
<
pRetrieve
->
numOfFuncs
;
++
i
)
{
char
funcName
[
TSDB_FUNC_NAME_LEN
]
=
{
0
};
memcpy
(
funcName
,
pRetrieve
->
pFuncNames
+
i
*
TSDB_FUNC_NAME_LEN
,
TSDB_FUNC_NAME_LEN
);
SFuncObj
*
pFunc
=
sdbAcquire
(
pMnode
->
pSdb
,
SDB_FUNC
,
funcName
);
if
(
pFunc
==
NULL
)
{
terrno
=
TSDB_CODE_MND_INVALID_FUNC
;
mError
(
"func:%s, failed to retrieve since %s"
,
funcName
,
terrstr
());
return
-
1
;
}
SFuncInfo
*
pFuncInfo
=
(
SFuncInfo
*
)
pOutput
;
strncpy
(
pFuncInfo
->
name
,
pFunc
->
name
,
TSDB_FUNC_NAME_LEN
);
pFuncInfo
->
funcType
=
pFunc
->
funcType
;
pFuncInfo
->
scriptType
=
pFunc
->
scriptType
;
pFuncInfo
->
outputType
=
pFunc
->
outputType
;
pFuncInfo
->
outputLen
=
htonl
(
pFunc
->
outputLen
);
pFuncInfo
->
bufSize
=
htonl
(
pFunc
->
bufSize
);
pFuncInfo
->
sigature
=
htobe64
(
pFunc
->
sigature
);
pFuncInfo
->
commentSize
=
htonl
(
pFunc
->
commentSize
);
pFuncInfo
->
codeSize
=
htonl
(
pFunc
->
codeSize
);
memcpy
(
pFuncInfo
->
pCont
,
pFunc
->
pCode
,
pFunc
->
commentSize
+
pFunc
->
codeSize
);
pOutput
+=
sizeof
(
SFuncInfo
)
+
pFunc
->
commentSize
+
pFunc
->
codeSize
;
}
pMsg
->
pCont
=
pRetrieveRsp
;
pMsg
->
contLen
=
(
int32_t
)(
pOutput
-
(
char
*
)
pRetrieveRsp
);
return
0
;
}
static
int32_t
mndGetFuncMeta
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
cols
=
0
;
SSchema
*
pSchema
=
pMeta
->
pSchema
;
pShow
->
bytes
[
cols
]
=
TSDB_FUNC_NAME_LEN
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"name"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
PATH_MAX
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"comment"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
[
cols
].
name
,
"aggregate"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
TSDB_TYPE_STR_MAX_LEN
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"outputtype"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
8
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
strcpy
(
pSchema
[
cols
].
name
,
"create_time"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
[
cols
].
name
,
"code_len"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
[
cols
].
name
,
"bufsize"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pMeta
->
numOfColumns
=
htons
(
cols
);
pShow
->
numOfColumns
=
cols
;
pShow
->
offset
[
0
]
=
0
;
for
(
int32_t
i
=
1
;
i
<
cols
;
++
i
)
{
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
}
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_FUNC
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tableFname
,
"show funcs"
);
return
0
;
}
static
void
*
mnodeGenTypeStr
(
char
*
buf
,
int32_t
buflen
,
uint8_t
type
,
int16_t
len
)
{
char
*
msg
=
"unknown"
;
if
(
type
>=
sizeof
(
tDataTypes
)
/
sizeof
(
tDataTypes
[
0
]))
{
return
msg
;
}
if
(
type
==
TSDB_DATA_TYPE_NCHAR
||
type
==
TSDB_DATA_TYPE_BINARY
)
{
int32_t
bytes
=
len
>
0
?
(
int
)(
len
-
VARSTR_HEADER_SIZE
)
:
len
;
snprintf
(
buf
,
buflen
-
1
,
"%s(%d)"
,
tDataTypes
[
type
].
name
,
type
==
TSDB_DATA_TYPE_NCHAR
?
bytes
/
4
:
bytes
);
buf
[
buflen
-
1
]
=
0
;
return
buf
;
}
return
tDataTypes
[
type
].
name
;
}
static
int32_t
mndRetrieveFuncs
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
SFuncObj
*
pFunc
=
NULL
;
int32_t
cols
=
0
;
char
*
pWrite
;
char
buf
[
TSDB_TYPE_STR_MAX_LEN
];
while
(
numOfRows
<
rows
)
{
pShow
->
pIter
=
sdbFetch
(
pSdb
,
SDB_FUNC
,
pShow
->
pIter
,
(
void
**
)
&
pFunc
);
if
(
pShow
->
pIter
==
NULL
)
break
;
cols
=
0
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
pFunc
->
name
,
pShow
->
bytes
[
cols
]);
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
pFunc
->
pComment
,
pShow
->
bytes
[
cols
]);
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int32_t
*
)
pWrite
=
pFunc
->
funcType
==
TSDB_FUNC_TYPE_AGGREGATE
?
1
:
0
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
mnodeGenTypeStr
(
buf
,
TSDB_TYPE_STR_MAX_LEN
,
pFunc
->
outputType
,
pFunc
->
outputLen
),
pShow
->
bytes
[
cols
]);
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int64_t
*
)
pWrite
=
pFunc
->
createdTime
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int32_t
*
)
pWrite
=
pFunc
->
codeSize
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int32_t
*
)
pWrite
=
pFunc
->
bufSize
;
cols
++
;
numOfRows
++
;
sdbRelease
(
pSdb
,
pFunc
);
}
mnodeVacuumResult
(
data
,
pShow
->
numOfColumns
,
numOfRows
,
rows
,
pShow
);
pShow
->
numOfReads
+=
numOfRows
;
return
numOfRows
;
}
static
void
mndCancelGetNextFunc
(
SMnode
*
pMnode
,
void
*
pIter
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
sdbCancelFetch
(
pSdb
,
pIter
);
}
\ No newline at end of file
source/dnode/mnode/impl/src/mndMnode.c
浏览文件 @
55f100e2
...
...
@@ -14,10 +14,88 @@
*/
#define _DEFAULT_SOURCE
#include "mndMnode.h"
#include "mndDnode.h"
#include "mndShow.h"
#include "mndTrans.h"
#define SDB_MNODE_VER 1
static
int32_t
mndCreateDefaultMnode
(
SMnode
*
pMnode
);
static
SSdbRaw
*
mndMnodeActionEncode
(
SMnodeObj
*
pMnodeObj
);
static
SSdbRow
*
mndMnodeActionDecode
(
SSdbRaw
*
pRaw
);
static
int32_t
mndMnodeActionInsert
(
SSdb
*
pSdb
,
SMnodeObj
*
pMnodeObj
);
static
int32_t
mndMnodeActionDelete
(
SSdb
*
pSdb
,
SMnodeObj
*
pMnodeObj
);
static
int32_t
mndMnodeActionUpdate
(
SSdb
*
pSdb
,
SMnodeObj
*
pOldMnode
,
SMnodeObj
*
pNewMnode
);
static
int32_t
mndProcessCreateMnodeMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessDropMnodeMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessCreateMnodeRsp
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessDropMnodeRsp
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndGetMnodeMeta
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveMnodes
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
void
mndCancelGetNextMnode
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitMnode
(
SMnode
*
pMnode
)
{
SSdbTable
table
=
{.
sdbType
=
SDB_MNODE
,
.
keyType
=
SDB_KEY_INT32
,
.
deployFp
=
(
SdbDeployFp
)
mndCreateDefaultMnode
,
.
encodeFp
=
(
SdbEncodeFp
)
mndMnodeActionEncode
,
.
decodeFp
=
(
SdbDecodeFp
)
mndMnodeActionDecode
,
.
insertFp
=
(
SdbInsertFp
)
mndMnodeActionInsert
,
.
updateFp
=
(
SdbUpdateFp
)
mndMnodeActionUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
mndMnodeActionDelete
};
mndSetMsgHandle
(
pMnode
,
TSDB_MSG_TYPE_CREATE_MNODE
,
mndProcessCreateMnodeMsg
);
mndSetMsgHandle
(
pMnode
,
TSDB_MSG_TYPE_DROP_MNODE
,
mndProcessDropMnodeMsg
);
mndSetMsgHandle
(
pMnode
,
TSDB_MSG_TYPE_CREATE_MNODE_IN_RSP
,
mndProcessCreateMnodeRsp
);
mndSetMsgHandle
(
pMnode
,
TSDB_MSG_TYPE_DROP_MNODE_IN_RSP
,
mndProcessDropMnodeRsp
);
mndAddShowMetaHandle
(
pMnode
,
TSDB_MGMT_TABLE_MNODE
,
mndGetMnodeMeta
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_MNODE
,
mndRetrieveMnodes
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_MNODE
,
mndCancelGetNextMnode
);
return
sdbSetTable
(
pMnode
->
pSdb
,
table
);
}
void
mndCleanupMnode
(
SMnode
*
pMnode
)
{}
static
SMnodeObj
*
mndAcquireMnode
(
SMnode
*
pMnode
,
int32_t
mnodeId
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
return
sdbAcquire
(
pSdb
,
SDB_MNODE
,
&
mnodeId
);
}
static
void
mndReleaseMnode
(
SMnode
*
pMnode
,
SMnodeObj
*
pMnodeObj
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
sdbRelease
(
pSdb
,
pMnodeObj
);
}
char
*
mndGetRoleStr
(
int32_t
showType
)
{
switch
(
showType
)
{
case
TAOS_SYNC_STATE_FOLLOWER
:
return
"unsynced"
;
case
TAOS_SYNC_STATE_CANDIDATE
:
return
"slave"
;
case
TAOS_SYNC_STATE_LEADER
:
return
"master"
;
default:
return
"undefined"
;
}
}
static
int32_t
mndCreateDefaultMnode
(
SMnode
*
pMnode
)
{
SMnodeObj
mnodeObj
=
{
0
};
mnodeObj
.
id
=
1
;
mnodeObj
.
createdTime
=
taosGetTimestampMs
();
mnodeObj
.
updateTime
=
mnodeObj
.
createdTime
;
SSdbRaw
*
pRaw
=
mndMnodeActionEncode
(
&
mnodeObj
);
if
(
pRaw
==
NULL
)
return
-
1
;
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_READY
);
mDebug
(
"mnode:%d, will be created while deploy sdb"
,
mnodeObj
.
id
);
return
sdbWrite
(
pMnode
->
pSdb
,
pRaw
);
}
static
SSdbRaw
*
mndMnodeActionEncode
(
SMnodeObj
*
pMnodeObj
)
{
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_MNODE
,
SDB_MNODE_VER
,
sizeof
(
SMnodeObj
));
if
(
pRaw
==
NULL
)
return
NULL
;
...
...
@@ -81,50 +159,14 @@ static int32_t mndMnodeActionDelete(SSdb *pSdb, SMnodeObj *pMnodeObj) {
return
0
;
}
static
int32_t
mndMnodeActionUpdate
(
SSdb
*
pSdb
,
SMnodeObj
*
p
SrcMnode
,
SMnodeObj
*
pDst
Mnode
)
{
mTrace
(
"mnode:%d, perform update action"
,
p
Src
Mnode
->
id
);
p
SrcMnode
->
id
=
pDst
Mnode
->
id
;
p
SrcMnode
->
createdTime
=
pDst
Mnode
->
createdTime
;
p
SrcMnode
->
updateTime
=
pDst
Mnode
->
updateTime
;
static
int32_t
mndMnodeActionUpdate
(
SSdb
*
pSdb
,
SMnodeObj
*
p
OldMnode
,
SMnodeObj
*
pNew
Mnode
)
{
mTrace
(
"mnode:%d, perform update action"
,
p
Old
Mnode
->
id
);
p
OldMnode
->
id
=
pNew
Mnode
->
id
;
p
OldMnode
->
createdTime
=
pNew
Mnode
->
createdTime
;
p
OldMnode
->
updateTime
=
pNew
Mnode
->
updateTime
;
return
0
;
}
static
int32_t
mndCreateDefaultMnode
(
SMnode
*
pMnode
)
{
SMnodeObj
mnodeObj
=
{
0
};
mnodeObj
.
id
=
1
;
mnodeObj
.
createdTime
=
taosGetTimestampMs
();
mnodeObj
.
updateTime
=
mnodeObj
.
createdTime
;
SSdbRaw
*
pRaw
=
mndMnodeActionEncode
(
&
mnodeObj
);
if
(
pRaw
==
NULL
)
return
-
1
;
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_READY
);
mTrace
(
"mnode:%d, will be created while deploy sdb"
,
mnodeObj
.
id
);
return
sdbWrite
(
pMnode
->
pSdb
,
pRaw
);
}
static
int32_t
mndProcessCreateMnodeMsg
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
static
int32_t
mndProcessDropMnodeMsg
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
int32_t
mndInitMnode
(
SMnode
*
pMnode
)
{
SSdbTable
table
=
{.
sdbType
=
SDB_MNODE
,
.
keyType
=
SDB_KEY_INT32
,
.
deployFp
=
(
SdbDeployFp
)
mndCreateDefaultMnode
,
.
encodeFp
=
(
SdbEncodeFp
)
mndMnodeActionEncode
,
.
decodeFp
=
(
SdbDecodeFp
)
mndMnodeActionDecode
,
.
insertFp
=
(
SdbInsertFp
)
mndMnodeActionInsert
,
.
updateFp
=
(
SdbUpdateFp
)
mndMnodeActionUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
mndMnodeActionDelete
};
mndSetMsgHandle
(
pMnode
,
TSDB_MSG_TYPE_CREATE_MNODE
,
mndProcessCreateMnodeMsg
);
mndSetMsgHandle
(
pMnode
,
TSDB_MSG_TYPE_DROP_MNODE
,
mndProcessDropMnodeMsg
);
return
sdbSetTable
(
pMnode
->
pSdb
,
table
);
}
void
mndCleanupMnode
(
SMnode
*
pMnode
)
{}
bool
mndIsMnode
(
SMnode
*
pMnode
,
int32_t
dnodeId
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
...
...
@@ -157,4 +199,271 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
pEpSet
->
numOfEps
++
;
}
}
\ No newline at end of file
}
static
int32_t
mndCreateMnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
pMsg
,
SCreateMnodeMsg
*
pCreate
)
{
SMnodeObj
mnodeObj
=
{
0
};
mnodeObj
.
id
=
1
;
// todo
mnodeObj
.
createdTime
=
taosGetTimestampMs
();
mnodeObj
.
updateTime
=
mnodeObj
.
createdTime
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
pMsg
->
rpcMsg
.
handle
);
if
(
pTrans
==
NULL
)
{
mError
(
"dnode:%d, failed to create since %s"
,
pCreate
->
dnodeId
,
terrstr
());
return
-
1
;
}
mDebug
(
"trans:%d, used to create dnode:%d"
,
pTrans
->
id
,
pCreate
->
dnodeId
);
SSdbRaw
*
pRedoRaw
=
mndMnodeActionEncode
(
&
mnodeObj
);
if
(
pRedoRaw
==
NULL
||
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to append redo log since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_CREATING
);
SSdbRaw
*
pUndoRaw
=
mndMnodeActionEncode
(
&
mnodeObj
);
if
(
pUndoRaw
==
NULL
||
mndTransAppendUndolog
(
pTrans
,
pUndoRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to append undo log since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pUndoRaw
,
SDB_STATUS_DROPPED
);
SSdbRaw
*
pCommitRaw
=
mndMnodeActionEncode
(
&
mnodeObj
);
if
(
pCommitRaw
==
NULL
||
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to append commit log since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_READY
);
if
(
mndTransPrepare
(
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
mndTransDrop
(
pTrans
);
return
0
;
}
static
int32_t
mndProcessCreateMnodeMsg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SCreateMnodeMsg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
pCreate
->
dnodeId
=
htonl
(
pCreate
->
dnodeId
);
mDebug
(
"mnode:%d, start to create"
,
pCreate
->
dnodeId
);
SDnodeObj
*
pDnode
=
mndAcquireDnode
(
pMnode
,
pCreate
->
dnodeId
);
if
(
pDnode
==
NULL
)
{
mError
(
"mnode:%d, dnode not exist"
,
pDnode
->
id
);
terrno
=
TSDB_CODE_MND_DNODE_NOT_EXIST
;
return
-
1
;
}
mndReleaseDnode
(
pMnode
,
pDnode
);
SMnodeObj
*
pMnodeObj
=
mndAcquireMnode
(
pMnode
,
pCreate
->
dnodeId
);
if
(
pMnodeObj
!=
NULL
)
{
mError
(
"mnode:%d, mnode already exist"
,
pMnodeObj
->
id
);
terrno
=
TSDB_CODE_MND_MNODE_ALREADY_EXIST
;
return
-
1
;
}
int32_t
code
=
mndCreateMnode
(
pMnode
,
pMsg
,
pCreate
);
if
(
code
!=
0
)
{
mError
(
"mnode:%d, failed to create since %s"
,
pCreate
->
dnodeId
,
terrstr
());
return
-
1
;
}
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
static
int32_t
mndDropMnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
pMsg
,
SMnodeObj
*
pMnodeObj
)
{
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
pMsg
->
rpcMsg
.
handle
);
if
(
pTrans
==
NULL
)
{
mError
(
"mnode:%d, failed to drop since %s"
,
pMnodeObj
->
id
,
terrstr
());
return
-
1
;
}
mDebug
(
"trans:%d, used to drop user:%d"
,
pTrans
->
id
,
pMnodeObj
->
id
);
SSdbRaw
*
pRedoRaw
=
mndMnodeActionEncode
(
pMnodeObj
);
if
(
pRedoRaw
==
NULL
||
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to append redo log since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_DROPPING
);
SSdbRaw
*
pUndoRaw
=
mndMnodeActionEncode
(
pMnodeObj
);
if
(
pUndoRaw
==
NULL
||
mndTransAppendUndolog
(
pTrans
,
pUndoRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to append undo log since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pUndoRaw
,
SDB_STATUS_READY
);
SSdbRaw
*
pCommitRaw
=
mndMnodeActionEncode
(
pMnodeObj
);
if
(
pCommitRaw
==
NULL
||
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to append commit log since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_DROPPED
);
if
(
mndTransPrepare
(
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
mndTransDrop
(
pTrans
);
return
0
;
}
static
int32_t
mndProcessDropMnodeMsg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SDropMnodeMsg
*
pDrop
=
pMsg
->
rpcMsg
.
pCont
;
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
mDebug
(
"mnode:%d, start to drop"
,
pDrop
->
dnodeId
);
if
(
pDrop
->
dnodeId
<=
0
)
{
terrno
=
TSDB_CODE_SDB_APP_ERROR
;
mError
(
"mnode:%d, failed to drop since %s"
,
pDrop
->
dnodeId
,
terrstr
());
return
-
1
;
}
SMnodeObj
*
pMnodeObj
=
mndAcquireMnode
(
pMnode
,
pDrop
->
dnodeId
);
if
(
pMnodeObj
==
NULL
)
{
mError
(
"mnode:%d, not exist"
,
pDrop
->
dnodeId
);
terrno
=
TSDB_CODE_MND_DNODE_NOT_EXIST
;
return
-
1
;
}
int32_t
code
=
mndDropMnode
(
pMnode
,
pMsg
,
pMnodeObj
);
if
(
code
!=
0
)
{
mError
(
"mnode:%d, failed to drop since %s"
,
pMnode
->
dnodeId
,
terrstr
());
return
-
1
;
}
sdbRelease
(
pMnode
->
pSdb
,
pMnode
);
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
static
int32_t
mndProcessCreateMnodeRsp
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
static
int32_t
mndProcessDropMnodeRsp
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
static
int32_t
mndGetMnodeMeta
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
cols
=
0
;
SSchema
*
pSchema
=
pMeta
->
pSchema
;
pShow
->
bytes
[
cols
]
=
2
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_SMALLINT
;
strcpy
(
pSchema
[
cols
].
name
,
"id"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"end point"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
12
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"role"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
8
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
strcpy
(
pSchema
[
cols
].
name
,
"role time"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
8
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
strcpy
(
pSchema
[
cols
].
name
,
"create time"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pMeta
->
numOfColumns
=
htons
(
cols
);
pShow
->
numOfColumns
=
cols
;
pShow
->
offset
[
0
]
=
0
;
for
(
int32_t
i
=
1
;
i
<
cols
;
++
i
)
{
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
}
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_MNODE
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tableFname
,
mndShowStr
(
pShow
->
type
));
return
0
;
}
static
int32_t
mndRetrieveMnodes
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
int32_t
cols
=
0
;
SMnodeObj
*
pMnodeObj
=
NULL
;
char
*
pWrite
;
while
(
numOfRows
<
rows
)
{
pShow
->
pIter
=
sdbFetch
(
pSdb
,
SDB_MNODE
,
pShow
->
pIter
,
(
void
**
)
&
pMnodeObj
);
if
(
pShow
->
pIter
==
NULL
)
break
;
cols
=
0
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int16_t
*
)
pWrite
=
pMnodeObj
->
id
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
SDnodeObj
*
pDnode
=
mndAcquireDnode
(
pMnode
,
pMnodeObj
->
id
);
if
(
pDnode
!=
NULL
)
{
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
pDnode
->
ep
,
pShow
->
bytes
[
cols
]);
}
else
{
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
"invalid ep"
,
pShow
->
bytes
[
cols
]);
}
mndReleaseDnode
(
pMnode
,
pDnode
);
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
char
*
roles
=
mndGetRoleStr
(
pMnodeObj
->
role
);
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
roles
,
pShow
->
bytes
[
cols
]);
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int64_t
*
)
pWrite
=
pMnodeObj
->
roleTime
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int64_t
*
)
pWrite
=
pMnodeObj
->
createdTime
;
cols
++
;
numOfRows
++
;
sdbRelease
(
pSdb
,
pMnodeObj
);
}
mnodeVacuumResult
(
data
,
pShow
->
numOfColumns
,
numOfRows
,
rows
,
pShow
);
pShow
->
numOfReads
+=
numOfRows
;
return
numOfRows
;
}
static
void
mndCancelGetNextMnode
(
SMnode
*
pMnode
,
void
*
pIter
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
sdbCancelFetch
(
pSdb
,
pIter
);
}
source/dnode/mnode/impl/src/mndOper.c
已删除
100644 → 0
浏览文件 @
8c416a5e
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "mndInt.h"
int32_t
mndInitOper
(
SMnode
*
pMnode
)
{
return
0
;
}
void
mndCleanupOper
(
SMnode
*
pMnode
)
{}
\ No newline at end of file
source/dnode/mnode/impl/src/mndProfile.c
浏览文件 @
55f100e2
...
...
@@ -467,7 +467,7 @@ static int32_t mndGetConnsMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
mndReleaseUser
(
pMnode
,
pUser
);
int32_t
cols
=
0
;
SSchema
*
pSchema
=
pMeta
->
s
chema
;
SSchema
*
pSchema
=
pMeta
->
pS
chema
;
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
...
...
@@ -595,7 +595,7 @@ static int32_t mndGetQueryMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
mndReleaseUser
(
pMnode
,
pUser
);
int32_t
cols
=
0
;
SSchema
*
pSchema
=
pMeta
->
s
chema
;
SSchema
*
pSchema
=
pMeta
->
pS
chema
;
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
...
...
@@ -811,7 +811,7 @@ static int32_t mndGetStreamMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg
mndReleaseUser
(
pMnode
,
pUser
);
int32_t
cols
=
0
;
SSchema
*
pSchema
=
pMeta
->
s
chema
;
SSchema
*
pSchema
=
pMeta
->
pS
chema
;
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
...
...
source/dnode/mnode/impl/src/mndShow.c
浏览文件 @
55f100e2
...
...
@@ -20,7 +20,6 @@ static SShowObj *mndCreateShowObj(SMnode *pMnode, SShowMsg *pMsg);
static
void
mndFreeShowObj
(
SShowObj
*
pShow
);
static
SShowObj
*
mndAcquireShowObj
(
SMnode
*
pMnode
,
int32_t
showId
);
static
void
mndReleaseShowObj
(
SShowObj
*
pShow
,
bool
forceRemove
);
static
char
*
mndShowStr
(
int32_t
showType
);
static
int32_t
mndProcessShowMsg
(
SMnodeMsg
*
pMnodeMsg
);
static
int32_t
mndProcessRetrieveMsg
(
SMnodeMsg
*
pMsg
);
static
bool
mndCheckRetrieveFinished
(
SShowObj
*
pShow
);
...
...
@@ -88,10 +87,6 @@ static void mndFreeShowObj(SShowObj *pShow) {
ShowFreeIterFp
freeFp
=
pMgmt
->
freeIterFps
[
pShow
->
type
];
if
(
freeFp
!=
NULL
)
{
if
(
pShow
->
pVgIter
!=
NULL
)
{
// only used in 'show vnodes "ep"'
(
*
freeFp
)(
pMnode
,
pShow
->
pVgIter
);
}
if
(
pShow
->
pIter
!=
NULL
)
{
(
*
freeFp
)(
pMnode
,
pShow
->
pIter
);
}
...
...
@@ -259,7 +254,7 @@ static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMnodeMsg) {
return
TSDB_CODE_SUCCESS
;
}
static
char
*
mndShowStr
(
int32_t
showType
)
{
char
*
mndShowStr
(
int32_t
showType
)
{
switch
(
showType
)
{
case
TSDB_MGMT_TABLE_ACCT
:
return
"show accounts"
;
...
...
@@ -275,7 +270,7 @@ static char *mndShowStr(int32_t showType) {
return
"show mnodes"
;
case
TSDB_MGMT_TABLE_VGROUP
:
return
"show vgroups"
;
case
TSDB_MGMT_TABLE_
METRIC
:
case
TSDB_MGMT_TABLE_
STABLE
:
return
"show stables"
;
case
TSDB_MGMT_TABLE_MODULE
:
return
"show modules"
;
...
...
source/dnode/mnode/impl/src/mndStable.c
浏览文件 @
55f100e2
...
...
@@ -14,8 +14,414 @@
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "mndInt.h"
#include "mndStable.h"
#include "mndDnode.h"
#include "mndMnode.h"
#include "mndShow.h"
#include "mndTrans.h"
#include "mndUser.h"
#include "mndDb.h"
#include "tname.h"
int32_t
mndInitStable
(
SMnode
*
pMnode
)
{
return
0
;
}
void
mndCleanupStable
(
SMnode
*
pMnode
)
{}
\ No newline at end of file
#define TSDB_STABLE_VER_NUM 1
#define TSDB_STABLE_RESERVE_SIZE 64
static
SSdbRaw
*
mndStableActionEncode
(
SStableObj
*
pStb
);
static
SSdbRow
*
mndStableActionDecode
(
SSdbRaw
*
pRaw
);
static
int32_t
mndStableActionInsert
(
SSdb
*
pSdb
,
SStableObj
*
pStb
);
static
int32_t
mndStableActionDelete
(
SSdb
*
pSdb
,
SStableObj
*
pStb
);
static
int32_t
mndStableActionUpdate
(
SSdb
*
pSdb
,
SStableObj
*
pOldStb
,
SStableObj
*
pNewStb
);
static
int32_t
mndProcessCreateStableMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessAlterStableMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessDropStableMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessCreateStableInRsp
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessAlterStableInRsp
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessDropStableInRsp
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessStableMetaMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndGetStableMeta
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveStables
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
void
mndCancelGetNextStable
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitStable
(
SMnode
*
pMnode
)
{
SSdbTable
table
=
{.
sdbType
=
SDB_STABLE
,
.
keyType
=
SDB_KEY_BINARY
,
.
encodeFp
=
(
SdbEncodeFp
)
mndStableActionEncode
,
.
decodeFp
=
(
SdbDecodeFp
)
mndStableActionDecode
,
.
insertFp
=
(
SdbInsertFp
)
mndStableActionInsert
,
.
updateFp
=
(
SdbUpdateFp
)
mndStableActionUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
mndStableActionDelete
};
mndSetMsgHandle
(
pMnode
,
TSDB_MSG_TYPE_CREATE_STABLE
,
mndProcessCreateStableMsg
);
mndSetMsgHandle
(
pMnode
,
TSDB_MSG_TYPE_ALTER_STABLE
,
mndProcessAlterStableMsg
);
mndSetMsgHandle
(
pMnode
,
TSDB_MSG_TYPE_DROP_STABLE
,
mndProcessDropStableMsg
);
mndSetMsgHandle
(
pMnode
,
TSDB_MSG_TYPE_CREATE_STABLE_IN_RSP
,
mndProcessCreateStableInRsp
);
mndSetMsgHandle
(
pMnode
,
TSDB_MSG_TYPE_ALTER_STABLE_IN_RSP
,
mndProcessAlterStableInRsp
);
mndSetMsgHandle
(
pMnode
,
TSDB_MSG_TYPE_DROP_STABLE_IN_RSP
,
mndProcessDropStableInRsp
);
mndSetMsgHandle
(
pMnode
,
TSDB_MSG_TYPE_TABLE_META
,
mndProcessStableMetaMsg
);
mndAddShowMetaHandle
(
pMnode
,
TSDB_MGMT_TABLE_STABLE
,
mndGetStableMeta
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_STABLE
,
mndRetrieveStables
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_STABLE
,
mndCancelGetNextStable
);
return
sdbSetTable
(
pMnode
->
pSdb
,
table
);
}
void
mndCleanupStable
(
SMnode
*
pMnode
)
{}
static
SSdbRaw
*
mndStableActionEncode
(
SStableObj
*
pStb
)
{
int32_t
size
=
sizeof
(
SStableObj
)
+
(
pStb
->
numOfColumns
+
pStb
->
numOfTags
)
*
sizeof
(
SSchema
);
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_STABLE
,
TSDB_STABLE_VER_NUM
,
size
);
if
(
pRaw
==
NULL
)
return
NULL
;
int32_t
dataPos
=
0
;
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pStb
->
name
,
TSDB_TABLE_NAME_LEN
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pStb
->
createdTime
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pStb
->
updateTime
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pStb
->
uid
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pStb
->
version
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfColumns
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfTags
)
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfColumns
;
++
i
)
{
SSchema
*
pSchema
=
&
pStb
->
columnSchema
[
i
];
SDB_SET_INT8
(
pRaw
,
dataPos
,
pSchema
->
type
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pSchema
->
colId
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pSchema
->
bytes
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
);
}
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfTags
;
++
i
)
{
SSchema
*
pSchema
=
&
pStb
->
tagSchema
[
i
];
SDB_SET_INT8
(
pRaw
,
dataPos
,
pSchema
->
type
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pSchema
->
colId
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pSchema
->
bytes
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
);
}
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
TSDB_STABLE_RESERVE_SIZE
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
);
return
pRaw
;
}
static
SSdbRow
*
mndStableActionDecode
(
SSdbRaw
*
pRaw
)
{
int8_t
sver
=
0
;
if
(
sdbGetRawSoftVer
(
pRaw
,
&
sver
)
!=
0
)
return
NULL
;
if
(
sver
!=
TSDB_STABLE_VER_NUM
)
{
mError
(
"failed to decode stable since %s"
,
terrstr
());
terrno
=
TSDB_CODE_SDB_INVALID_DATA_VER
;
return
NULL
;
}
int32_t
size
=
sizeof
(
SStableObj
)
+
TSDB_MAX_COLUMNS
*
sizeof
(
SSchema
);
SSdbRow
*
pRow
=
sdbAllocRow
(
size
);
SStableObj
*
pStb
=
sdbGetRowObj
(
pRow
);
if
(
pStb
==
NULL
)
return
NULL
;
int32_t
dataPos
=
0
;
SDB_GET_BINARY
(
pRaw
,
pRow
,
dataPos
,
pStb
->
name
,
TSDB_TABLE_NAME_LEN
)
SDB_GET_INT64
(
pRaw
,
pRow
,
dataPos
,
&
pStb
->
createdTime
)
SDB_GET_INT64
(
pRaw
,
pRow
,
dataPos
,
&
pStb
->
updateTime
)
SDB_GET_INT64
(
pRaw
,
pRow
,
dataPos
,
&
pStb
->
uid
)
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
pStb
->
version
)
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
pStb
->
numOfColumns
)
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
pStb
->
numOfTags
)
pStb
->
columnSchema
=
calloc
(
pStb
->
numOfColumns
,
sizeof
(
SSchema
));
pStb
->
tagSchema
=
calloc
(
pStb
->
numOfTags
,
sizeof
(
SSchema
));
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfColumns
;
++
i
)
{
SSchema
*
pSchema
=
&
pStb
->
columnSchema
[
i
];
SDB_GET_INT8
(
pRaw
,
pRow
,
dataPos
,
&
pSchema
->
type
);
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
pSchema
->
colId
);
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
pSchema
->
bytes
);
SDB_GET_BINARY
(
pRaw
,
pRow
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
);
}
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfTags
;
++
i
)
{
SSchema
*
pSchema
=
&
pStb
->
tagSchema
[
i
];
SDB_GET_INT8
(
pRaw
,
pRow
,
dataPos
,
&
pSchema
->
type
);
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
pSchema
->
colId
);
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
pSchema
->
bytes
);
SDB_GET_BINARY
(
pRaw
,
pRow
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
);
}
SDB_GET_RESERVE
(
pRaw
,
pRow
,
dataPos
,
TSDB_STABLE_RESERVE_SIZE
)
return
pRow
;
}
static
int32_t
mndStableActionInsert
(
SSdb
*
pSdb
,
SStableObj
*
pStb
)
{
mTrace
(
"stable:%s, perform insert action"
,
pStb
->
name
);
return
0
;
}
static
int32_t
mndStableActionDelete
(
SSdb
*
pSdb
,
SStableObj
*
pStb
)
{
mTrace
(
"stable:%s, perform delete action"
,
pStb
->
name
);
return
0
;
}
static
int32_t
mndStableActionUpdate
(
SSdb
*
pSdb
,
SStableObj
*
pOldStb
,
SStableObj
*
pNewStb
)
{
mTrace
(
"stable:%s, perform update action"
,
pOldStb
->
name
);
atomic_exchange_32
(
&
pOldStb
->
updateTime
,
pNewStb
->
updateTime
);
atomic_exchange_32
(
&
pOldStb
->
version
,
pNewStb
->
version
);
taosWLockLatch
(
&
pOldStb
->
lock
);
int32_t
numOfTags
=
pNewStb
->
numOfTags
;
int32_t
tagSize
=
numOfTags
*
sizeof
(
SSchema
);
int32_t
numOfColumns
=
pNewStb
->
numOfColumns
;
int32_t
columnSize
=
numOfColumns
*
sizeof
(
SSchema
);
if
(
pOldStb
->
numOfTags
<
numOfTags
)
{
pOldStb
->
tagSchema
=
malloc
(
tagSize
);
}
if
(
pOldStb
->
numOfColumns
<
numOfColumns
)
{
pOldStb
->
columnSchema
=
malloc
(
columnSize
);
}
memcpy
(
pOldStb
->
tagSchema
,
pNewStb
->
tagSchema
,
tagSize
);
memcpy
(
pOldStb
->
columnSchema
,
pNewStb
->
columnSchema
,
columnSize
);
taosWUnLockLatch
(
&
pOldStb
->
lock
);
return
0
;
}
SStableObj
*
mndAcquireStb
(
SMnode
*
pMnode
,
char
*
stbName
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
return
sdbAcquire
(
pSdb
,
SDB_STABLE
,
stbName
);
}
void
mndReleaseStb
(
SMnode
*
pMnode
,
SStableObj
*
pStb
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
sdbRelease
(
pSdb
,
pStb
);
}
static
int32_t
mndProcessCreateStableMsg
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
static
int32_t
mndProcessCreateStableInRsp
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
static
int32_t
mndProcessAlterStableMsg
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
static
int32_t
mndProcessAlterStableInRsp
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
static
int32_t
mndProcessDropStableMsg
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
static
int32_t
mndProcessDropStableInRsp
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
static
SDbObj
*
mndGetDbByStbName
(
SMnode
*
pMnode
,
char
*
stbName
)
{
SName
name
=
{
0
};
tNameFromString
(
&
name
,
stbName
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
char
db
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName
(
&
name
,
db
);
return
mndAcquireDb
(
pMnode
,
db
);
}
static
int32_t
mndProcessStableMetaMsg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SStableInfoMsg
*
pInfo
=
pMsg
->
rpcMsg
.
pCont
;
mDebug
(
"stable:%s, start to retrieve meta"
,
pInfo
->
name
);
SDbObj
*
pDb
=
mndGetDbByStbName
(
pMnode
,
pInfo
->
name
);
if
(
pDb
==
NULL
)
{
terrno
=
TSDB_CODE_MND_DB_NOT_SELECTED
;
mError
(
"stable:%s, failed to retrieve meta since %s"
,
pInfo
->
name
,
terrstr
());
return
-
1
;
}
SStableObj
*
pStb
=
mndAcquireStb
(
pMnode
,
pInfo
->
name
);
if
(
pStb
==
NULL
)
{
mndReleaseDb
(
pMnode
,
pDb
);
terrno
=
TSDB_CODE_MND_INVALID_TABLE_NAME
;
mError
(
"stable:%s, failed to get meta since %s"
,
pInfo
->
name
,
terrstr
());
return
-
1
;
}
int32_t
contLen
=
sizeof
(
STableMetaMsg
)
+
(
pStb
->
numOfColumns
+
pStb
->
numOfTags
)
*
sizeof
(
SSchema
);
STableMetaMsg
*
pMeta
=
rpcMallocCont
(
contLen
);
if
(
pMeta
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
mError
(
"stable:%s, failed to get meta since %s"
,
pInfo
->
name
,
terrstr
());
return
-
1
;
}
memcpy
(
pMeta
->
stableFname
,
pStb
->
name
,
TSDB_TABLE_FNAME_LEN
);
pMeta
->
numOfTags
=
htonl
(
pStb
->
numOfTags
);
pMeta
->
numOfColumns
=
htonl
(
pStb
->
numOfColumns
);
pMeta
->
precision
=
pDb
->
cfg
.
precision
;
pMeta
->
tableType
=
TSDB_SUPER_TABLE
;
pMeta
->
update
=
pDb
->
cfg
.
update
;
pMeta
->
sversion
=
htonl
(
pStb
->
version
);
pMeta
->
suid
=
htonl
(
pStb
->
uid
);
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfColumns
;
++
i
)
{
SSchema
*
pSchema
=
&
pMeta
->
pSchema
[
i
];
SSchema
*
pColumn
=
&
pStb
->
columnSchema
[
i
];
memcpy
(
pSchema
->
name
,
pColumn
->
name
,
TSDB_COL_NAME_LEN
);
pSchema
->
type
=
pColumn
->
type
;
pSchema
->
colId
=
htonl
(
pColumn
->
colId
);
pSchema
->
bytes
=
htonl
(
pColumn
->
bytes
);
}
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfTags
;
++
i
)
{
SSchema
*
pSchema
=
&
pMeta
->
pSchema
[
i
+
pStb
->
numOfColumns
];
SSchema
*
pTag
=
&
pStb
->
tagSchema
[
i
];
memcpy
(
pSchema
->
name
,
pTag
->
name
,
TSDB_COL_NAME_LEN
);
pSchema
->
type
=
pTag
->
type
;
pSchema
->
colId
=
htons
(
pTag
->
colId
);
pSchema
->
bytes
=
htonl
(
pTag
->
bytes
);
}
pMsg
->
pCont
=
pMeta
;
pMsg
->
contLen
=
contLen
;
mDebug
(
"stable:%s, meta is retrieved, cols:%d tags:%d"
,
pInfo
->
name
,
pStb
->
numOfColumns
,
pStb
->
numOfTags
);
return
0
;
}
static
int32_t
mndGetNumOfStables
(
SMnode
*
pMnode
,
char
*
dbName
,
int32_t
*
pNumOfStables
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SDbObj
*
pDb
=
mndAcquireDb
(
pMnode
,
dbName
);
if
(
pDb
==
NULL
)
{
terrno
=
TSDB_CODE_MND_DB_NOT_SELECTED
;
return
-
1
;
}
int32_t
numOfStables
=
0
;
void
*
pIter
=
NULL
;
while
(
1
)
{
SStableObj
*
pStb
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pIter
,
(
void
**
)
&
pStb
);
if
(
pIter
==
NULL
)
break
;
if
(
strcmp
(
pStb
->
db
,
dbName
)
==
0
)
{
numOfStables
++
;
}
sdbRelease
(
pSdb
,
pStb
);
}
*
pNumOfStables
=
numOfStables
;
return
0
;
}
static
int32_t
mndGetStableMeta
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
if
(
mndGetNumOfStables
(
pMnode
,
pShow
->
db
,
&
pShow
->
numOfRows
)
!=
0
)
{
return
-
1
;
}
int32_t
cols
=
0
;
SSchema
*
pSchema
=
pMeta
->
pSchema
;
pShow
->
bytes
[
cols
]
=
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"name"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
8
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
strcpy
(
pSchema
[
cols
].
name
,
"create time"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
2
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_SMALLINT
;
strcpy
(
pSchema
[
cols
].
name
,
"columns"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
2
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_SMALLINT
;
strcpy
(
pSchema
[
cols
].
name
,
"tags"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pMeta
->
numOfColumns
=
htons
(
cols
);
pShow
->
numOfColumns
=
cols
;
pShow
->
offset
[
0
]
=
0
;
for
(
int32_t
i
=
1
;
i
<
cols
;
++
i
)
{
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
}
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tableFname
,
mndShowStr
(
pShow
->
type
));
return
0
;
}
static
void
mnodeExtractTableName
(
char
*
tableId
,
char
*
name
)
{
int
pos
=
-
1
;
int
num
=
0
;
for
(
pos
=
0
;
tableId
[
pos
]
!=
0
;
++
pos
)
{
if
(
tableId
[
pos
]
==
'.'
)
num
++
;
if
(
num
==
2
)
break
;
}
if
(
num
==
2
)
{
strcpy
(
name
,
tableId
+
pos
+
1
);
}
}
static
int32_t
mndRetrieveStables
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
SStableObj
*
pStb
=
NULL
;
int32_t
cols
=
0
;
char
*
pWrite
;
char
prefix
[
64
]
=
{
0
};
tstrncpy
(
prefix
,
pShow
->
db
,
64
);
strcat
(
prefix
,
TS_PATH_DELIMITER
);
int32_t
prefixLen
=
(
int32_t
)
strlen
(
prefix
);
while
(
numOfRows
<
rows
)
{
pShow
->
pIter
=
sdbFetch
(
pSdb
,
SDB_STABLE
,
pShow
->
pIter
,
(
void
**
)
&
pStb
);
if
(
pShow
->
pIter
==
NULL
)
break
;
if
(
strncmp
(
pStb
->
name
,
prefix
,
prefixLen
)
!=
0
)
{
sdbRelease
(
pSdb
,
pStb
);
continue
;
}
cols
=
0
;
char
stableName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
memcpy
(
stableName
,
pStb
->
name
+
prefixLen
,
TSDB_TABLE_FNAME_LEN
-
prefixLen
);
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
STR_TO_VARSTR
(
pWrite
,
stableName
);
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int64_t
*
)
pWrite
=
pStb
->
createdTime
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int16_t
*
)
pWrite
=
pStb
->
numOfColumns
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int16_t
*
)
pWrite
=
pStb
->
numOfTags
;
cols
++
;
numOfRows
++
;
sdbRelease
(
pSdb
,
pStb
);
}
pShow
->
numOfReads
+=
numOfRows
;
mnodeVacuumResult
(
data
,
pShow
->
numOfColumns
,
numOfRows
,
rows
,
pShow
);
return
numOfRows
;
}
static
void
mndCancelGetNextStable
(
SMnode
*
pMnode
,
void
*
pIter
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
sdbCancelFetch
(
pSdb
,
pIter
);
}
\ No newline at end of file
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
55f100e2
...
...
@@ -21,9 +21,15 @@
int32_t
mndInitSync
(
SMnode
*
pMnode
)
{
return
0
;
}
void
mndCleanupSync
(
SMnode
*
pMnode
)
{}
int32_t
mndSyncPropose
(
SMnode
*
pMnode
,
SSdbRaw
*
pRaw
,
void
*
pData
)
{
mndTransApply
(
pMnode
,
pData
,
pData
,
0
);
free
(
pData
);
int32_t
mndSyncPropose
(
SMnode
*
pMnode
,
SSdbRaw
*
pRaw
,
STransMsg
*
pMsg
)
{
int32_t
code
=
0
;
int32_t
len
=
sdbGetRawTotalSize
(
pRaw
);
SSdbRaw
*
pReceived
=
calloc
(
1
,
len
);
memcpy
(
pReceived
,
pRaw
,
len
);
mDebug
(
"trans:%d, data:%p recv from sync, code:0x%x pMsg:%p"
,
pMsg
->
id
,
pReceived
,
code
&
0xFFFF
,
pMsg
);
mndTransApply
(
pMnode
,
pReceived
,
pMsg
,
code
);
return
0
;
}
...
...
source/dnode/mnode/impl/src/mndTelem.c
浏览文件 @
55f100e2
...
...
@@ -189,12 +189,12 @@ static void mndSendTelemetryReport(SMnode* pMnode) {
char
buf
[
128
]
=
{
0
};
uint32_t
ip
=
taosGetIpv4FromFqdn
(
TELEMETRY_SERVER
);
if
(
ip
==
0xffffffff
)
{
m
Trace
(
"failed to get IP address of "
TELEMETRY_SERVER
" since :%s"
,
strerror
(
errno
));
m
Debug
(
"failed to get IP address of "
TELEMETRY_SERVER
" since :%s"
,
strerror
(
errno
));
return
;
}
SOCKET
fd
=
taosOpenTcpClientSocket
(
ip
,
TELEMETRY_PORT
,
0
);
if
(
fd
<
0
)
{
m
Trace
(
"failed to create socket for telemetry, reason:%s"
,
strerror
(
errno
));
m
Debug
(
"failed to create socket for telemetry, reason:%s"
,
strerror
(
errno
));
return
;
}
...
...
@@ -228,7 +228,7 @@ static void mndSendTelemetryReport(SMnode* pMnode) {
// read something to avoid nginx error 499
if
(
taosReadSocket
(
fd
,
buf
,
10
)
<
0
)
{
m
Trace
(
"failed to receive response since %s"
,
strerror
(
errno
));
m
Debug
(
"failed to receive response since %s"
,
strerror
(
errno
));
}
taosCloseSocket
(
fd
);
...
...
@@ -297,7 +297,7 @@ int32_t mndInitTelem(SMnode* pMnode) {
int32_t
code
=
pthread_create
(
&
pMgmt
->
thread
,
&
attr
,
mndTelemThreadFp
,
pMnode
);
pthread_attr_destroy
(
&
attr
);
if
(
code
!=
0
)
{
m
Trace
(
"failed to create telemetry thread since :%s"
,
strerror
(
code
));
m
Debug
(
"failed to create telemetry thread since :%s"
,
strerror
(
code
));
}
mInfo
(
"mnd telemetry is initialized"
);
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
55f100e2
此差异已折叠。
点击以展开。
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
55f100e2
此差异已折叠。
点击以展开。
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
55f100e2
此差异已折叠。
点击以展开。
source/dnode/mnode/impl/src/mnode.c
浏览文件 @
55f100e2
...
...
@@ -22,7 +22,6 @@
#include "mndDnode.h"
#include "mndFunc.h"
#include "mndMnode.h"
#include "mndOper.h"
#include "mndProfile.h"
#include "mndShow.h"
#include "mndStable.h"
...
...
@@ -333,7 +332,7 @@ SMnodeMsg *mndInitMsg(SMnode *pMnode, SRpcMsg *pRpcMsg) {
SMnodeMsg
*
pMsg
=
taosAllocateQitem
(
sizeof
(
SMnodeMsg
));
if
(
pMsg
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
mError
(
"
failed to create msg since %s"
,
terrstr
());
mError
(
"
RPC:%p, app:%p failed to create msg since %s"
,
pRpcMsg
->
handle
,
pRpcMsg
->
ahandle
,
terrstr
());
return
NULL
;
}
...
...
@@ -341,7 +340,7 @@ SMnodeMsg *mndInitMsg(SMnode *pMnode, SRpcMsg *pRpcMsg) {
if
(
rpcGetConnInfo
(
pRpcMsg
->
handle
,
&
connInfo
)
!=
0
)
{
mndCleanupMsg
(
pMsg
);
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
mError
(
"
failed to create msg since %s"
,
terrstr
());
mError
(
"
RPC:%p, app:%p failed to create msg since %s"
,
pRpcMsg
->
handle
,
pRpcMsg
->
ahandle
,
terrstr
());
return
NULL
;
}
memcpy
(
pMsg
->
user
,
connInfo
.
user
,
TSDB_USER_LEN
);
...
...
@@ -350,13 +349,13 @@ SMnodeMsg *mndInitMsg(SMnode *pMnode, SRpcMsg *pRpcMsg) {
pMsg
->
rpcMsg
=
*
pRpcMsg
;
pMsg
->
createdTime
=
taosGetTimestampSec
();
mTrace
(
"msg:%p,
is created"
,
pMsg
);
mTrace
(
"msg:%p,
app:%p is created, RPC:%p"
,
pMsg
,
pRpcMsg
->
ahandle
,
pRpcMsg
->
handle
);
return
pMsg
;
}
void
mndCleanupMsg
(
SMnodeMsg
*
pMsg
)
{
mTrace
(
"msg:%p, app:%p is destroyed, RPC:%p"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
->
rpcMsg
.
handle
);
taosFreeQitem
(
pMsg
);
mTrace
(
"msg:%p, is destroyed"
,
pMsg
);
}
void
mndSendRsp
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
...
...
@@ -371,7 +370,7 @@ static void mndProcessRpcMsg(SMnodeMsg *pMsg) {
void
*
ahandle
=
pMsg
->
rpcMsg
.
ahandle
;
bool
isReq
=
(
msgType
%
2
==
1
);
mTrace
(
"msg:%p, app:%p
will be processed"
,
pMsg
,
ahandle
);
mTrace
(
"msg:%p, app:%p
type:%s will be processed"
,
pMsg
,
ahandle
,
taosMsg
[
msgType
]
);
if
(
isReq
&&
!
mndIsMaster
(
pMnode
))
{
code
=
TSDB_CODE_APP_NOT_READY
;
...
...
@@ -393,7 +392,10 @@ static void mndProcessRpcMsg(SMnodeMsg *pMsg) {
}
code
=
(
*
fp
)(
pMsg
);
if
(
code
!=
0
)
{
if
(
code
==
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mTrace
(
"msg:%p, app:%p in progressing"
,
pMsg
,
ahandle
);
return
;
}
else
if
(
code
!=
0
)
{
code
=
terrno
;
mError
(
"msg:%p, app:%p failed to process since %s"
,
pMsg
,
ahandle
,
terrstr
());
goto
PROCESS_RPC_END
;
...
...
source/dnode/mnode/sdb/inc/sdbInt.h
浏览文件 @
55f100e2
...
...
@@ -71,7 +71,6 @@ typedef struct SSdb {
}
SSdb
;
int32_t
sdbWriteFile
(
SSdb
*
pSdb
);
int32_t
sdbWriteRaw
(
SSdb
*
pSdb
,
SSdbRaw
*
pRaw
);
#ifdef __cplusplus
}
...
...
source/dnode/mnode/sdb/src/sdb.c
浏览文件 @
55f100e2
...
...
@@ -94,7 +94,7 @@ void sdbCleanup(SSdb *pSdb) {
taosHashClear
(
hash
);
taosHashCleanup
(
hash
);
pSdb
->
hashObjs
[
i
]
=
NULL
;
m
Trace
(
"sdb table:%d is cleaned up"
,
i
);
m
Debug
(
"sdb table:%d is cleaned up"
,
i
);
}
free
(
pSdb
);
...
...
@@ -129,7 +129,7 @@ int32_t sdbSetTable(SSdb *pSdb, SSdbTable table) {
pSdb
->
hashObjs
[
sdbType
]
=
hash
;
taosInitRWLatch
(
&
pSdb
->
locks
[
sdbType
]);
m
Trace
(
"sdb table:%d is initialized"
,
sdbType
);
m
Debug
(
"sdb table:%d is initialized"
,
sdbType
);
return
0
;
}
\ No newline at end of file
source/dnode/mnode/sdb/src/sdbFile.c
浏览文件 @
55f100e2
...
...
@@ -118,7 +118,7 @@ int32_t sdbReadFile(SSdb *pSdb) {
break
;
}
code
=
sdbWrite
Raw
(
pSdb
,
pRaw
);
code
=
sdbWrite
NotFree
(
pSdb
,
pRaw
);
if
(
code
!=
0
)
{
mError
(
"failed to read file:%s since %s"
,
file
,
terrstr
());
goto
PARSE_SDB_DATA_ERROR
;
...
...
source/dnode/mnode/sdb/src/sdbHash.c
浏览文件 @
55f100e2
...
...
@@ -52,11 +52,12 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
SRWLatch
*
pLock
=
&
pSdb
->
locks
[
pRow
->
type
];
taosWLockLatch
(
pLock
);
SSdbRow
*
p
Dst
Row
=
taosHashGet
(
hash
,
pRow
->
pObj
,
keySize
);
if
(
p
Dst
Row
!=
NULL
)
{
SSdbRow
*
p
Old
Row
=
taosHashGet
(
hash
,
pRow
->
pObj
,
keySize
);
if
(
p
Old
Row
!=
NULL
)
{
taosWUnLockLatch
(
pLock
);
sdbFreeRow
(
pRow
);
return
TSDB_CODE_SDB_OBJ_ALREADY_THERE
;
terrno
=
TSDB_CODE_SDB_OBJ_ALREADY_THERE
;
return
terrno
;
}
pRow
->
refCount
=
1
;
...
...
@@ -65,7 +66,8 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
if
(
taosHashPut
(
hash
,
pRow
->
pObj
,
keySize
,
&
pRow
,
sizeof
(
void
*
))
!=
0
)
{
taosWUnLockLatch
(
pLock
);
sdbFreeRow
(
pRow
);
return
TSDB_CODE_SDB_OBJ_ALREADY_THERE
;
terrno
=
TSDB_CODE_SDB_OBJ_ALREADY_THERE
;
return
terrno
;
}
taosWUnLockLatch
(
pLock
);
...
...
@@ -78,35 +80,36 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
taosHashRemove
(
hash
,
pRow
->
pObj
,
keySize
);
taosWUnLockLatch
(
pLock
);
sdbFreeRow
(
pRow
);
return
code
;
terrno
=
code
;
return
terrno
;
}
}
return
0
;
}
static
int32_t
sdbUpdateRow
(
SSdb
*
pSdb
,
SHashObj
*
hash
,
SSdbRaw
*
pRaw
,
SSdbRow
*
pRow
,
int32_t
keySize
)
{
static
int32_t
sdbUpdateRow
(
SSdb
*
pSdb
,
SHashObj
*
hash
,
SSdbRaw
*
pRaw
,
SSdbRow
*
p
New
Row
,
int32_t
keySize
)
{
int32_t
code
=
0
;
SRWLatch
*
pLock
=
&
pSdb
->
locks
[
pRow
->
type
];
SRWLatch
*
pLock
=
&
pSdb
->
locks
[
p
New
Row
->
type
];
taosRLockLatch
(
pLock
);
SSdbRow
**
pp
DstRow
=
taosHashGet
(
hash
,
p
Row
->
pObj
,
keySize
);
if
(
pp
DstRow
==
NULL
||
*
ppDst
Row
==
NULL
)
{
SSdbRow
**
pp
OldRow
=
taosHashGet
(
hash
,
pNew
Row
->
pObj
,
keySize
);
if
(
pp
OldRow
==
NULL
||
*
ppOld
Row
==
NULL
)
{
taosRUnLockLatch
(
pLock
);
return
sdbInsertRow
(
pSdb
,
hash
,
pRaw
,
pRow
,
keySize
);
return
sdbInsertRow
(
pSdb
,
hash
,
pRaw
,
p
New
Row
,
keySize
);
}
SSdbRow
*
p
DstRow
=
*
ppDst
Row
;
SSdbRow
*
p
OldRow
=
*
ppOld
Row
;
pRow
->
status
=
pRaw
->
status
;
p
Old
Row
->
status
=
pRaw
->
status
;
taosRUnLockLatch
(
pLock
);
SdbUpdateFp
updateFp
=
pSdb
->
updateFps
[
pRow
->
type
];
SdbUpdateFp
updateFp
=
pSdb
->
updateFps
[
p
New
Row
->
type
];
if
(
updateFp
!=
NULL
)
{
code
=
(
*
updateFp
)(
pSdb
,
p
Row
->
pObj
,
pDst
Row
->
pObj
);
code
=
(
*
updateFp
)(
pSdb
,
p
OldRow
->
pObj
,
pNew
Row
->
pObj
);
}
sdbFreeRow
(
pRow
);
sdbFreeRow
(
p
New
Row
);
return
code
;
}
...
...
@@ -116,29 +119,30 @@ static int32_t sdbDeleteRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
SRWLatch
*
pLock
=
&
pSdb
->
locks
[
pRow
->
type
];
taosWLockLatch
(
pLock
);
SSdbRow
**
pp
Dst
Row
=
taosHashGet
(
hash
,
pRow
->
pObj
,
keySize
);
if
(
pp
DstRow
==
NULL
||
*
ppDst
Row
==
NULL
)
{
SSdbRow
**
pp
Old
Row
=
taosHashGet
(
hash
,
pRow
->
pObj
,
keySize
);
if
(
pp
OldRow
==
NULL
||
*
ppOld
Row
==
NULL
)
{
taosWUnLockLatch
(
pLock
);
sdbFreeRow
(
pRow
);
return
TSDB_CODE_SDB_OBJ_NOT_THERE
;
terrno
=
TSDB_CODE_SDB_OBJ_NOT_THERE
;
return
terrno
;
}
SSdbRow
*
p
DstRow
=
*
ppDst
Row
;
SSdbRow
*
p
OldRow
=
*
ppOld
Row
;
p
Dst
Row
->
status
=
pRaw
->
status
;
taosHashRemove
(
hash
,
p
Dst
Row
->
pObj
,
keySize
);
p
Old
Row
->
status
=
pRaw
->
status
;
taosHashRemove
(
hash
,
p
Old
Row
->
pObj
,
keySize
);
taosWUnLockLatch
(
pLock
);
SdbDeleteFp
deleteFp
=
pSdb
->
deleteFps
[
p
Dst
Row
->
type
];
SdbDeleteFp
deleteFp
=
pSdb
->
deleteFps
[
p
Old
Row
->
type
];
if
(
deleteFp
!=
NULL
)
{
code
=
(
*
deleteFp
)(
pSdb
,
p
Dst
Row
->
pObj
);
code
=
(
*
deleteFp
)(
pSdb
,
p
Old
Row
->
pObj
);
}
sdbRelease
(
pSdb
,
p
Dst
Row
->
pObj
);
sdbRelease
(
pSdb
,
p
Old
Row
->
pObj
);
sdbFreeRow
(
pRow
);
return
code
;
}
int32_t
sdbWrite
Raw
(
SSdb
*
pSdb
,
SSdbRaw
*
pRaw
)
{
int32_t
sdbWrite
NotFree
(
SSdb
*
pSdb
,
SSdbRaw
*
pRaw
)
{
SHashObj
*
hash
=
sdbGetHash
(
pSdb
,
pRaw
->
type
);
if
(
hash
==
NULL
)
return
terrno
;
...
...
@@ -170,7 +174,7 @@ int32_t sdbWriteRaw(SSdb *pSdb, SSdbRaw *pRaw) {
}
int32_t
sdbWrite
(
SSdb
*
pSdb
,
SSdbRaw
*
pRaw
)
{
int32_t
code
=
sdbWrite
Raw
(
pSdb
,
pRaw
);
int32_t
code
=
sdbWrite
NotFree
(
pSdb
,
pRaw
);
sdbFreeRaw
(
pRaw
);
return
code
;
}
...
...
source/dnode/mnode/sdb/src/sdbRaw.c
浏览文件 @
55f100e2
...
...
@@ -26,10 +26,15 @@ SSdbRaw *sdbAllocRaw(ESdbType type, int8_t sver, int32_t dataLen) {
pRaw
->
type
=
type
;
pRaw
->
sver
=
sver
;
pRaw
->
dataLen
=
dataLen
;
mTrace
(
"raw:%p, is created, len:%d"
,
pRaw
,
dataLen
);
return
pRaw
;
}
void
sdbFreeRaw
(
SSdbRaw
*
pRaw
)
{
free
(
pRaw
);
}
void
sdbFreeRaw
(
SSdbRaw
*
pRaw
)
{
mTrace
(
"raw:%p, is freed"
,
pRaw
);
free
(
pRaw
);
}
int32_t
sdbSetRawInt8
(
SSdbRaw
*
pRaw
,
int32_t
dataPos
,
int8_t
val
)
{
if
(
pRaw
==
NULL
)
{
...
...
source/dnode/vnode/impl/CMakeLists.txt
浏览文件 @
55f100e2
...
...
@@ -18,6 +18,6 @@ target_link_libraries(
)
# test
if
(
${
BUILD_TEST
}
)
add_subdirectory
(
test
)
endif
(
${
BUILD_TEST
}
)
\ No newline at end of file
#if(${BUILD_TEST})
# add_subdirectory(test)
#endif(${BUILD_TEST})
\ No newline at end of file
source/dnode/vnode/impl/test/vnodeApiTests.cpp
浏览文件 @
55f100e2
...
...
@@ -45,7 +45,7 @@ static SKVRow createBasicTag() {
tdInitKVRowBuilder
(
&
rb
);
for
(
int
i
=
10
;
i
<
1
2
;
i
++
)
{
for
(
int
i
=
0
;
i
<
2
;
i
++
)
{
void
*
pVal
=
malloc
(
sizeof
(
VarDataLenT
)
+
strlen
(
"foo"
));
varDataLen
(
pVal
)
=
strlen
(
"foo"
);
memcpy
(
varDataVal
(
pVal
),
"foo"
,
strlen
(
"foo"
));
...
...
@@ -120,7 +120,7 @@ TEST(vnodeApiTest, vnodeOpen_vnodeClose_test) {
{
// Create some child tables
int
ntables
=
100000
;
int
ntables
=
100000
0
;
int
batch
=
10
;
for
(
int
i
=
0
;
i
<
ntables
/
batch
;
i
++
)
{
SArray
*
pMsgs
=
(
SArray
*
)
taosArrayInit
(
batch
,
sizeof
(
SRpcMsg
*
));
...
...
source/dnode/vnode/meta/src/metaBDBImpl.c
浏览文件 @
55f100e2
此差异已折叠。
点击以展开。
source/libs/function/src/tfunction.c
浏览文件 @
55f100e2
...
...
@@ -343,7 +343,7 @@ bool isProjectionQueryOnSTable(SArray* pFunctionIdList, int32_t tableIndex) {
//
// if (functionId < 0) {
// SUdfInfo* pUdfInfo = taosArrayGet(pQueryInfo->pUdfInfo, -1 * functionId - 1);
// if (pUdfInfo->funcType == TSDB_
UDF
_TYPE_AGGREGATE) {
// if (pUdfInfo->funcType == TSDB_
FUNC
_TYPE_AGGREGATE) {
// return false;
// }
//
...
...
source/libs/function/src/tudf.c
浏览文件 @
55f100e2
...
...
@@ -146,7 +146,7 @@ void doInvokeUdf(struct SUdfInfo* pUdfInfo, SQLFunctionCtx *pCtx, int32_t idx, i
pCtx->pOutput, interBuf, (char *)pCtx->ptsOutputBuf, &output, pCtx->resDataInfo.type, pCtx->resDataInfo.bytes, &pUdfInfo->init);
}
if (pUdfInfo->funcType == TSDB_
UDF
_TYPE_AGGREGATE) {
if (pUdfInfo->funcType == TSDB_
FUNC
_TYPE_AGGREGATE) {
pCtx->resultInfo->numOfRes = output;
} else {
pCtx->resultInfo->numOfRes += output;
...
...
source/libs/index/src/index_fst.c
浏览文件 @
55f100e2
此差异已折叠。
点击以展开。
source/libs/index/test/indexTests.cpp
浏览文件 @
55f100e2
此差异已折叠。
点击以展开。
source/libs/parser/inc/sql.y
浏览文件 @
55f100e2
此差异已折叠。
点击以展开。
source/libs/parser/src/astGenerator.c
浏览文件 @
55f100e2
此差异已折叠。
点击以展开。
source/libs/parser/src/parserUtil.c
浏览文件 @
55f100e2
...
...
@@ -1480,7 +1480,7 @@ STableMeta* createSuperTableMeta(STableMetaMsg* pChild) {
pTableMeta
->
tversion
=
pChild
->
tversion
;
pTableMeta
->
sversion
=
pChild
->
sversion
;
memcpy
(
pTableMeta
->
schema
,
pChild
->
s
chema
,
sizeof
(
SSchema
)
*
total
);
memcpy
(
pTableMeta
->
schema
,
pChild
->
pS
chema
,
sizeof
(
SSchema
)
*
total
);
int32_t
num
=
pTableMeta
->
tableInfo
.
numOfColumns
;
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
...
...
source/libs/parser/src/sql.c
浏览文件 @
55f100e2
此差异已折叠。
点击以展开。
source/libs/transport/src/rpcMain.c
浏览文件 @
55f100e2
此差异已折叠。
点击以展开。
source/libs/wal/CMakeLists.txt
浏览文件 @
55f100e2
此差异已折叠。
点击以展开。
source/libs/wal/inc/walInt.h
浏览文件 @
55f100e2
此差异已折叠。
点击以展开。
source/libs/wal/src/walIndex.c
浏览文件 @
55f100e2
此差异已折叠。
点击以展开。
source/libs/wal/src/walMeta.c
0 → 100644
浏览文件 @
55f100e2
此差异已折叠。
点击以展开。
source/libs/wal/src/walMgmt.c
浏览文件 @
55f100e2
此差异已折叠。
点击以展开。
source/libs/wal/src/walRead.c
浏览文件 @
55f100e2
此差异已折叠。
点击以展开。
source/libs/wal/src/walWrite.c
浏览文件 @
55f100e2
此差异已折叠。
点击以展开。
source/libs/wal/test/CMakeLists.txt
0 → 100644
浏览文件 @
55f100e2
此差异已折叠。
点击以展开。
source/libs/wal/test/walMetaTest.cpp
0 → 100644
浏览文件 @
55f100e2
此差异已折叠。
点击以展开。
source/libs/wal/test/walTests.cpp
已删除
100644 → 0
浏览文件 @
8c416a5e
此差异已折叠。
点击以展开。
source/util/src/tarray.c
浏览文件 @
55f100e2
此差异已折叠。
点击以展开。
source/util/src/terror.c
浏览文件 @
55f100e2
此差异已折叠。
点击以展开。
source/util/src/tfile.c
浏览文件 @
55f100e2
此差异已折叠。
点击以展开。
source/util/src/tmd5.c
浏览文件 @
55f100e2
此差异已折叠。
点击以展开。
source/util/src/tutil.c
浏览文件 @
55f100e2
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录