Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
411b9a2d
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1181
Star
22014
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
411b9a2d
编写于
3月 23, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add tsma
上级
20017d82
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
195 addition
and
17 deletion
+195
-17
include/common/tmsg.h
include/common/tmsg.h
+29
-0
include/common/tmsgdef.h
include/common/tmsgdef.h
+2
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+93
-0
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+32
-14
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+39
-3
未找到文件。
include/common/tmsg.h
浏览文件 @
411b9a2d
...
...
@@ -1897,6 +1897,35 @@ static FORCE_INLINE void* tDecodeSSchemaWrapper(void* buf, SSchemaWrapper* pSW)
}
return
buf
;
}
typedef
struct
{
char
name
[
TSDB_TABLE_FNAME_LEN
];
char
stb
[
TSDB_TABLE_FNAME_LEN
];
int8_t
igExists
;
int8_t
intervalUnit
;
int8_t
slidingUnit
;
int8_t
timezone
;
int64_t
interval
;
int64_t
offset
;
int64_t
sliding
;
int32_t
exprLen
;
int32_t
tagsFilterLen
;
char
*
expr
;
char
*
tagsFilter
;
}
SMCreateTSmaReq
;
int32_t
tSerializeSMCreateTSmaReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateTSmaReq
*
pReq
);
int32_t
tDeserializeSMCreateTSmaReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateTSmaReq
*
pReq
);
void
tFreeSMCreateTSmaReq
(
SMCreateTSmaReq
*
pReq
);
typedef
struct
{
char
name
[
TSDB_TABLE_FNAME_LEN
];
int8_t
igNotExists
;
}
SMDropTSmaReq
;
int32_t
tSerializeSMDropTSmaReq
(
void
*
buf
,
int32_t
bufLen
,
SMDropTSmaReq
*
pReq
);
int32_t
tDeserializeSMDropTSmaReq
(
void
*
buf
,
int32_t
bufLen
,
SMDropTSmaReq
*
pReq
);
typedef
struct
{
int8_t
version
;
// for compatibility(default 0)
int8_t
intervalUnit
;
// MACRO: TIME_UNIT_XXX
...
...
include/common/tmsgdef.h
浏览文件 @
411b9a2d
...
...
@@ -127,6 +127,8 @@ enum {
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_STB
,
"mnode-create-stb"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_ALTER_STB
,
"mnode-alter-stb"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_STB
,
"mnode-drop-stb"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_SMA
,
"mnode-create-tsma"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_SMA
,
"mnode-drop-tsma"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_TABLE_META
,
"mnode-table-meta"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_VGROUP_LIST
,
"mnode-vgroup-list"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_QNODE_LIST
,
"mnode-qnode-list"
,
NULL
,
NULL
)
...
...
source/common/src/tmsg.c
浏览文件 @
411b9a2d
...
...
@@ -589,6 +589,99 @@ void tFreeSMAltertbReq(SMAltertbReq *pReq) {
pReq
->
pFields
=
NULL
;
}
int32_t
tSerializeSMCreateSmaReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateTSmaReq
*
pReq
)
{
SCoder
encoder
=
{
0
};
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
stb
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
igExists
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
intervalUnit
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
slidingUnit
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
timezone
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
interval
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
offset
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
sliding
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
exprLen
)
<
0
)
return
-
1
;
if
(
pReq
->
exprLen
>
0
)
{
if
(
tEncodeBinary
(
&
encoder
,
pReq
->
expr
,
pReq
->
exprLen
)
<
0
)
return
-
1
;
}
if
(
tEncodeI32
(
&
encoder
,
pReq
->
tagsFilterLen
)
<
0
)
return
-
1
;
if
(
pReq
->
tagsFilterLen
>
0
)
{
if
(
tEncodeBinary
(
&
encoder
,
pReq
->
tagsFilter
,
pReq
->
tagsFilterLen
)
<
0
)
return
-
1
;
}
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
tCoderClear
(
&
encoder
);
return
tlen
;
}
int32_t
tDeserializeSMCreateSmaReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateTSmaReq
*
pReq
)
{
SCoder
decoder
=
{
0
};
tCoderInit
(
&
decoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_DECODER
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
stb
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
igExists
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
intervalUnit
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
slidingUnit
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
timezone
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
interval
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
offset
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
sliding
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
exprLen
)
<
0
)
return
-
1
;
if
(
pReq
->
exprLen
>
0
)
{
pReq
->
expr
=
malloc
(
pReq
->
exprLen
);
if
(
pReq
->
expr
==
NULL
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
expr
)
<
0
)
return
-
1
;
}
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
tagsFilterLen
)
<
0
)
return
-
1
;
if
(
pReq
->
tagsFilterLen
>
0
)
{
pReq
->
tagsFilter
=
malloc
(
pReq
->
tagsFilterLen
);
if
(
pReq
->
tagsFilter
==
NULL
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
tagsFilter
)
<
0
)
return
-
1
;
}
tEndDecode
(
&
decoder
);
tCoderClear
(
&
decoder
);
return
0
;
}
void
tFreeSMCreateSmaReq
(
SMCreateTSmaReq
*
pReq
)
{
tfree
(
pReq
->
expr
);
tfree
(
pReq
->
tagsFilter
);
}
int32_t
tSerializeSMDropSmaReq
(
void
*
buf
,
int32_t
bufLen
,
SMDropTSmaReq
*
pReq
)
{
SCoder
encoder
=
{
0
};
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
igNotExists
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
tCoderClear
(
&
encoder
);
return
tlen
;
}
int32_t
tDeserializeSMDropSmaReq
(
void
*
buf
,
int32_t
bufLen
,
SMDropTSmaReq
*
pReq
)
{
SCoder
decoder
=
{
0
};
tCoderInit
(
&
decoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_DECODER
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
igNotExists
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tCoderClear
(
&
decoder
);
return
0
;
}
int32_t
tSerializeSStatusReq
(
void
*
buf
,
int32_t
bufLen
,
SStatusReq
*
pReq
)
{
SCoder
encoder
=
{
0
};
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
411b9a2d
...
...
@@ -306,20 +306,38 @@ typedef struct {
}
SVgObj
;
typedef
struct
{
char
name
[
TSDB_TABLE_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
int64_t
createdTime
;
int64_t
updateTime
;
int64_t
uid
;
int64_t
dbUid
;
int32_t
version
;
int32_t
nextColId
;
int32_t
numOfColumns
;
int32_t
numOfTags
;
SSchema
*
pColumns
;
SSchema
*
pTags
;
SRWLatch
lock
;
char
comment
[
TSDB_STB_COMMENT_LEN
];
char
name
[
TSDB_TABLE_FNAME_LEN
];
int64_t
createdTime
;
int64_t
uid
;
int8_t
intervalUnit
;
int8_t
slidingUnit
;
int8_t
timezone
;
int64_t
interval
;
int64_t
offset
;
int64_t
sliding
;
int32_t
exprLen
;
int32_t
tagsFilterLen
;
char
*
expr
;
char
*
tagsFilter
;
}
STSmaObj
;
typedef
struct
{
char
name
[
TSDB_TABLE_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
int64_t
createdTime
;
int64_t
updateTime
;
int64_t
uid
;
int64_t
dbUid
;
int32_t
version
;
int32_t
nextColId
;
int32_t
numOfColumns
;
int32_t
numOfTags
;
int32_t
numOfTSmas
;
SSchema
*
pColumns
;
SSchema
*
pTags
;
STSmaObj
*
pTSmas
;
SRWLatch
lock
;
char
comment
[
TSDB_STB_COMMENT_LEN
];
}
SStbObj
;
typedef
struct
{
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
411b9a2d
...
...
@@ -18,15 +18,15 @@
#include "mndAuth.h"
#include "mndDb.h"
#include "mndDnode.h"
#include "mndInfoSchema.h"
#include "mndMnode.h"
#include "mndShow.h"
#include "mndTrans.h"
#include "mndUser.h"
#include "mndVgroup.h"
#include "mndInfoSchema.h"
#include "tname.h"
#define TSDB_STB_VER_NUMBER 1
#define TSDB_STB_VER_NUMBER
1
#define TSDB_STB_RESERVE_SIZE 64
static
SSdbRow
*
mndStbActionDecode
(
SSdbRaw
*
pRaw
);
...
...
@@ -88,6 +88,7 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
nextColId
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfColumns
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfTags
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfTSmas
,
STB_ENCODE_OVER
)
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfColumns
;
++
i
)
{
SSchema
*
pSchema
=
&
pStb
->
pColumns
[
i
];
...
...
@@ -105,6 +106,23 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
STB_ENCODE_OVER
)
}
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfTSmas
;
++
i
)
{
STSmaObj
*
pTSma
=
&
pStb
->
pTSmas
[
i
];
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTSma
->
name
,
TSDB_TABLE_FNAME_LEN
,
STB_ENCODE_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTSma
->
createdTime
,
STB_ENCODE_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTSma
->
uid
,
STB_ENCODE_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pTSma
->
intervalUnit
,
STB_ENCODE_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pTSma
->
slidingUnit
,
STB_ENCODE_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pTSma
->
timezone
,
STB_ENCODE_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTSma
->
interval
,
STB_ENCODE_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTSma
->
offset
,
STB_ENCODE_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTSma
->
sliding
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTSma
->
exprLen
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTSma
->
tagsFilterLen
,
STB_ENCODE_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTSma
->
expr
,
pTSma
->
exprLen
,
STB_ENCODE_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTSma
->
tagsFilter
,
pTSma
->
tagsFilterLen
,
STB_ENCODE_OVER
)
}
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pStb
->
comment
,
TSDB_STB_COMMENT_LEN
,
STB_ENCODE_OVER
)
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
TSDB_STB_RESERVE_SIZE
,
STB_ENCODE_OVER
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
STB_ENCODE_OVER
)
...
...
@@ -150,6 +168,7 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
nextColId
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
numOfColumns
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
numOfTags
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
numOfTSmas
,
STB_DECODE_OVER
)
pStb
->
pColumns
=
calloc
(
pStb
->
numOfColumns
,
sizeof
(
SSchema
));
pStb
->
pTags
=
calloc
(
pStb
->
numOfTags
,
sizeof
(
SSchema
));
...
...
@@ -173,6 +192,23 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
STB_DECODE_OVER
)
}
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfTSmas
;
++
i
)
{
STSmaObj
*
pTSma
=
&
pStb
->
pTSmas
[
i
];
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pTSma
->
name
,
TSDB_TABLE_FNAME_LEN
,
STB_DECODE_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTSma
->
createdTime
,
STB_DECODE_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTSma
->
uid
,
STB_DECODE_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pTSma
->
intervalUnit
,
STB_DECODE_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pTSma
->
slidingUnit
,
STB_DECODE_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pTSma
->
timezone
,
STB_DECODE_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTSma
->
interval
,
STB_DECODE_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTSma
->
offset
,
STB_DECODE_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTSma
->
sliding
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTSma
->
exprLen
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTSma
->
tagsFilterLen
,
STB_DECODE_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pTSma
->
expr
,
pTSma
->
exprLen
,
STB_DECODE_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pTSma
->
tagsFilter
,
pTSma
->
tagsFilterLen
,
STB_DECODE_OVER
)
}
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pStb
->
comment
,
TSDB_STB_COMMENT_LEN
,
STB_DECODE_OVER
)
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
TSDB_STB_RESERVE_SIZE
,
STB_DECODE_OVER
)
...
...
@@ -1162,7 +1198,7 @@ static int32_t mndSetDropStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *
static
int32_t
mndDropStb
(
SMnode
*
pMnode
,
SNodeMsg
*
pReq
,
SDbObj
*
pDb
,
SStbObj
*
pStb
)
{
int32_t
code
=
-
1
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_DROP_STB
,
&
pReq
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_DROP_STB
,
&
pReq
->
rpcMsg
);
if
(
pTrans
==
NULL
)
goto
DROP_STB_OVER
;
mDebug
(
"trans:%d, used to drop stb:%s"
,
pTrans
->
id
,
pStb
->
name
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录