Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2bd2996e
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
2bd2996e
编写于
6月 16, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:add comment function
上级
e28e92ea
变更
16
显示空白变更内容
内联
并排
Showing
16 changed file
with
143 addition
and
80 deletion
+143
-80
include/common/tmsg.h
include/common/tmsg.h
+1
-1
include/libs/nodes/cmdnodes.h
include/libs/nodes/cmdnodes.h
+1
-0
source/common/src/systable.c
source/common/src/systable.c
+2
-2
source/common/src/tmsg.c
source/common/src/tmsg.c
+6
-6
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+1
-0
source/dnode/mnode/impl/src/mndMain.c
source/dnode/mnode/impl/src/mndMain.c
+4
-8
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+23
-20
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+2
-0
source/dnode/vnode/src/meta/metaEntry.c
source/dnode/vnode/src/meta/metaEntry.c
+17
-4
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+12
-7
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+6
-4
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+33
-11
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+3
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+27
-13
source/libs/parser/test/parInitialATest.cpp
source/libs/parser/test/parInitialATest.cpp
+4
-3
source/libs/parser/test/parInitialCTest.cpp
source/libs/parser/test/parInitialCTest.cpp
+1
-1
未找到文件。
include/common/tmsg.h
浏览文件 @
2bd2996e
...
...
@@ -1922,7 +1922,7 @@ typedef struct {
// TSDB_ALTER_TABLE_UPDATE_OPTIONS
int8_t
updateTTL
;
int32_t
newTTL
;
int
8_t
updateComment
;
int
32_t
newCommentLen
;
char
*
newComment
;
}
SVAlterTbReq
;
...
...
include/libs/nodes/cmdnodes.h
浏览文件 @
2bd2996e
...
...
@@ -87,6 +87,7 @@ typedef struct SAlterDatabaseStmt {
typedef
struct
STableOptions
{
ENodeType
type
;
bool
commentNull
;
char
comment
[
TSDB_TB_COMMENT_LEN
];
double
filesFactor
;
SNodeList
*
pRollupFuncs
;
...
...
source/common/src/systable.c
浏览文件 @
2bd2996e
...
...
@@ -124,7 +124,7 @@ static const SSysDbTableSchema userStbsSchema[] = {
{.
name
=
"columns"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"tags"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"last_update"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"table_comment"
,
.
bytes
=
1024
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"table_comment"
,
.
bytes
=
TSDB_TB_COMMENT_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
};
static
const
SSysDbTableSchema
streamSchema
[]
=
{
...
...
@@ -148,7 +148,7 @@ static const SSysDbTableSchema userTblsSchema[] = {
{.
name
=
"uid"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_BIGINT
},
{.
name
=
"vgroup_id"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"ttl"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"table_comment"
,
.
bytes
=
512
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"table_comment"
,
.
bytes
=
TSDB_TB_COMMENT_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"type"
,
.
bytes
=
20
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
};
...
...
source/common/src/tmsg.c
浏览文件 @
2bd2996e
...
...
@@ -561,7 +561,7 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
}
if
(
pReq
->
commentLen
>
0
)
{
pReq
->
comment
=
taosMemoryMalloc
(
pReq
->
commentLen
);
pReq
->
comment
=
taosMemoryMalloc
(
pReq
->
commentLen
+
1
);
if
(
pReq
->
comment
==
NULL
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
comment
)
<
0
)
return
-
1
;
}
...
...
@@ -4350,7 +4350,7 @@ int tDecodeSVCreateTbReq(SDecoder *pCoder, SVCreateTbReq *pReq) {
if
(
tDecodeI8
(
pCoder
,
&
pReq
->
type
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pReq
->
commentLen
)
<
0
)
return
-
1
;
if
(
pReq
->
commentLen
>
0
)
{
pReq
->
comment
=
taosMemoryMalloc
(
pReq
->
commentLen
);
pReq
->
comment
=
taosMemoryMalloc
(
pReq
->
commentLen
+
1
);
if
(
pReq
->
comment
==
NULL
)
return
-
1
;
if
(
tDecodeCStrTo
(
pCoder
,
pReq
->
comment
)
<
0
)
return
-
1
;
}
...
...
@@ -4707,8 +4707,8 @@ int32_t tEncodeSVAlterTbReq(SEncoder *pEncoder, const SVAlterTbReq *pReq) {
if
(
pReq
->
updateTTL
)
{
if
(
tEncodeI32v
(
pEncoder
,
pReq
->
newTTL
)
<
0
)
return
-
1
;
}
if
(
tEncodeI
8
(
pEncoder
,
pReq
->
updateComment
)
<
0
)
return
-
1
;
if
(
pReq
->
updateComment
)
{
if
(
tEncodeI
32v
(
pEncoder
,
pReq
->
newCommentLen
)
<
0
)
return
-
1
;
if
(
pReq
->
newCommentLen
>
0
)
{
if
(
tEncodeCStr
(
pEncoder
,
pReq
->
newComment
)
<
0
)
return
-
1
;
}
break
;
...
...
@@ -4755,8 +4755,8 @@ int32_t tDecodeSVAlterTbReq(SDecoder *pDecoder, SVAlterTbReq *pReq) {
if
(
pReq
->
updateTTL
)
{
if
(
tDecodeI32v
(
pDecoder
,
&
pReq
->
newTTL
)
<
0
)
return
-
1
;
}
if
(
tDecodeI
8
(
pDecoder
,
&
pReq
->
updateComment
)
<
0
)
return
-
1
;
if
(
pReq
->
updateComment
)
{
if
(
tDecodeI
32v
(
pDecoder
,
&
pReq
->
newCommentLen
)
<
0
)
return
-
1
;
if
(
pReq
->
newCommentLen
>
0
)
{
if
(
tDecodeCStr
(
pDecoder
,
&
pReq
->
newComment
)
<
0
)
return
-
1
;
}
break
;
...
...
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
浏览文件 @
2bd2996e
...
...
@@ -334,6 +334,7 @@ SArray *vmGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_CANCEL_TASK
,
vmPutMsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_DROP_TASK
,
vmPutMsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_CREATE_STB
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_DROP_TTL_TABLE
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_STB
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_DROP_STB
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_CREATE_TABLE
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
...
...
source/dnode/mnode/impl/src/mndMain.c
浏览文件 @
2bd2996e
...
...
@@ -87,18 +87,17 @@ static void mndPushTtlTime(SMnode *pMnode) {
if
(
pIter
==
NULL
)
break
;
int32_t
contLen
=
sizeof
(
SMsgHead
)
+
sizeof
(
int32_t
);
SMsgHead
*
pHead
=
taosMemoryMalloc
(
contLen
);
SMsgHead
*
pHead
=
rpcMallocCont
(
contLen
);
if
(
pHead
==
NULL
)
{
mError
(
"ttl time malloc err. contLen:%d"
,
contLen
);
sdbRelease
(
pSdb
,
pVgroup
);
continue
;
}
pHead
->
contLen
=
htonl
(
pHead
->
contLen
);
pHead
->
vgId
=
htonl
(
p
Head
->
vgId
);
pHead
->
contLen
=
htonl
(
contLen
);
pHead
->
vgId
=
htonl
(
p
Vgroup
->
vgId
);
int32_t
t
=
taosGetTimestampSec
();
*
(
int32_t
*
)(
pHead
+
sizeof
(
SMsgHead
))
=
htonl
(
t
);
*
(
int32_t
*
)(
POINTER_SHIFT
(
pHead
,
sizeof
(
SMsgHead
)
))
=
htonl
(
t
);
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_VND_DROP_TTL_TABLE
,
.
pCont
=
pHead
,
.
contLen
=
contLen
};
...
...
@@ -109,7 +108,6 @@ static void mndPushTtlTime(SMnode *pMnode) {
}
mError
(
"ttl time seed succ. time:%d"
,
t
);
sdbRelease
(
pSdb
,
pVgroup
);
taosMemoryFree
(
pHead
);
}
}
...
...
@@ -138,8 +136,6 @@ static void *mndThreadFp(void *param) {
if
(
lastTime
%
(
tsTelemInterval
*
10
)
==
0
)
{
mndPullupTelem
(
pMnode
);
}
}
return
NULL
;
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
2bd2996e
...
...
@@ -117,7 +117,7 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
}
if
(
pStb
->
commentLen
>
0
)
{
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pStb
->
comment
,
pStb
->
commentLen
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pStb
->
comment
,
pStb
->
commentLen
+
1
,
_OVER
)
}
if
(
pStb
->
ast1Len
>
0
)
{
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pStb
->
pAst1
,
pStb
->
ast1Len
,
_OVER
)
...
...
@@ -204,9 +204,9 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
}
if
(
pStb
->
commentLen
>
0
)
{
pStb
->
comment
=
taosMemoryCalloc
(
pStb
->
commentLen
,
1
);
pStb
->
comment
=
taosMemoryCalloc
(
pStb
->
commentLen
+
1
,
1
);
if
(
pStb
->
comment
==
NULL
)
goto
_OVER
;
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pStb
->
comment
,
pStb
->
commentLen
,
_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pStb
->
comment
,
pStb
->
commentLen
+
1
,
_OVER
)
}
if
(
pStb
->
ast1Len
>
0
)
{
pStb
->
pAst1
=
taosMemoryCalloc
(
pStb
->
ast1Len
,
1
);
...
...
@@ -281,7 +281,7 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
}
if
(
pOld
->
commentLen
<
pNew
->
commentLen
)
{
void
*
comment
=
taosMemoryMalloc
(
pNew
->
commentLen
);
void
*
comment
=
taosMemoryMalloc
(
pNew
->
commentLen
+
1
);
if
(
comment
!=
NULL
)
{
taosMemoryFree
(
pOld
->
comment
);
pOld
->
comment
=
comment
;
...
...
@@ -326,7 +326,7 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
memcpy
(
pOld
->
pColumns
,
pNew
->
pColumns
,
pOld
->
numOfColumns
*
sizeof
(
SSchema
));
memcpy
(
pOld
->
pTags
,
pNew
->
pTags
,
pOld
->
numOfTags
*
sizeof
(
SSchema
));
if
(
pNew
->
commentLen
!=
0
)
{
memcpy
(
pOld
->
comment
,
pNew
->
comment
,
pNew
->
commentLen
);
memcpy
(
pOld
->
comment
,
pNew
->
comment
,
pNew
->
commentLen
+
1
);
}
if
(
pNew
->
ast1Len
!=
0
)
{
memcpy
(
pOld
->
pAst1
,
pNew
->
pAst1
,
pNew
->
ast1Len
);
...
...
@@ -671,12 +671,12 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
pDst
->
numOfTags
=
pCreate
->
numOfTags
;
pDst
->
commentLen
=
pCreate
->
commentLen
;
if
(
pDst
->
commentLen
>
0
)
{
pDst
->
comment
=
taosMemoryCalloc
(
pDst
->
commentLen
,
1
);
pDst
->
comment
=
taosMemoryCalloc
(
pDst
->
commentLen
+
1
,
1
);
if
(
pDst
->
comment
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
memcpy
(
pDst
->
comment
,
pCreate
->
comment
,
pDst
->
commentLen
);
memcpy
(
pDst
->
comment
,
pCreate
->
comment
,
pDst
->
commentLen
+
1
);
}
pDst
->
ast1Len
=
pCreate
->
ast1Len
;
...
...
@@ -892,13 +892,16 @@ static int32_t mndUpdateStbCommentAndTTL(const SStbObj *pOld, SStbObj *pNew, cha
int32_t
ttl
)
{
if
(
commentLen
>
0
)
{
pNew
->
commentLen
=
commentLen
;
pNew
->
comment
=
taosMemoryCalloc
(
1
,
commentLen
);
pNew
->
comment
=
taosMemoryCalloc
(
1
,
commentLen
+
1
);
if
(
pNew
->
comment
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
memcpy
(
pNew
->
comment
,
pComment
,
commentLen
);
memcpy
(
pNew
->
comment
,
pComment
,
commentLen
+
1
);
}
else
if
(
commentLen
==
0
){
pNew
->
commentLen
=
0
;
}
if
(
ttl
>=
0
)
{
pNew
->
ttl
=
ttl
;
}
...
...
@@ -1848,17 +1851,17 @@ static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pStb
->
updateTime
,
false
);
// number of tables
char
*
p
=
taosMemoryCalloc
(
1
,
pStb
->
commentLen
+
1
+
VARSTR_HEADER_SIZE
);
// check malloc failures
if
(
p
!=
NULL
)
{
if
(
pStb
->
commentLen
!=
0
)
{
STR_TO_VARSTR
(
p
,
pStb
->
comment
);
}
else
{
STR_TO_VARSTR
(
p
,
""
);
}
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
p
,
false
);
taosMemoryFree
(
p
);
if
(
pStb
->
commentLen
>
0
)
{
char
comment
[
TSDB_TB_COMMENT_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_TO_VARSTR
(
comment
,
pStb
->
comment
);
colDataAppend
(
pColInfo
,
numOfRows
,
comment
,
false
);
}
else
if
(
pStb
->
commentLen
==
0
)
{
char
comment
[
VARSTR_HEADER_SIZE
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_TO_VARSTR
(
comment
,
""
);
colDataAppend
(
pColInfo
,
numOfRows
,
comment
,
false
);
}
else
{
colDataAppendNULL
(
pColInfo
,
numOfRows
);
}
numOfRows
++
;
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
2bd2996e
...
...
@@ -210,6 +210,7 @@ struct SMetaEntry {
struct
{
int64_t
ctime
;
int32_t
ttlDays
;
int32_t
commentLen
;
char
*
comment
;
tb_uid_t
suid
;
uint8_t
*
pTags
;
...
...
@@ -217,6 +218,7 @@ struct SMetaEntry {
struct
{
int64_t
ctime
;
int32_t
ttlDays
;
int32_t
commentLen
;
char
*
comment
;
int32_t
ncid
;
// next column id
SSchemaWrapper
schemaRow
;
...
...
source/dnode/vnode/src/meta/metaEntry.c
浏览文件 @
2bd2996e
...
...
@@ -29,14 +29,20 @@ int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) {
}
else
if
(
pME
->
type
==
TSDB_CHILD_TABLE
)
{
if
(
tEncodeI64
(
pCoder
,
pME
->
ctbEntry
.
ctime
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pCoder
,
pME
->
ctbEntry
.
ttlDays
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pCoder
,
pME
->
ctbEntry
.
commentLen
)
<
0
)
return
-
1
;
if
(
pME
->
ctbEntry
.
commentLen
>
0
){
if
(
tEncodeCStr
(
pCoder
,
pME
->
ctbEntry
.
comment
)
<
0
)
return
-
1
;
}
if
(
tEncodeI64
(
pCoder
,
pME
->
ctbEntry
.
suid
)
<
0
)
return
-
1
;
debugCheckTags
((
STag
*
)
pME
->
ctbEntry
.
pTags
);
// TODO: remove after debug
if
(
tEncodeTag
(
pCoder
,
(
const
STag
*
)
pME
->
ctbEntry
.
pTags
)
<
0
)
return
-
1
;
}
else
if
(
pME
->
type
==
TSDB_NORMAL_TABLE
)
{
if
(
tEncodeI64
(
pCoder
,
pME
->
ntbEntry
.
ctime
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pCoder
,
pME
->
ntbEntry
.
ttlDays
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pCoder
,
pME
->
ntbEntry
.
commentLen
)
<
0
)
return
-
1
;
if
(
pME
->
ntbEntry
.
commentLen
>
0
){
if
(
tEncodeCStr
(
pCoder
,
pME
->
ntbEntry
.
comment
)
<
0
)
return
-
1
;
}
if
(
tEncodeI32v
(
pCoder
,
pME
->
ntbEntry
.
ncid
)
<
0
)
return
-
1
;
if
(
tEncodeSSchemaWrapper
(
pCoder
,
&
pME
->
ntbEntry
.
schemaRow
)
<
0
)
return
-
1
;
}
else
if
(
pME
->
type
==
TSDB_TSMA_TABLE
)
{
...
...
@@ -63,14 +69,21 @@ int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) {
}
else
if
(
pME
->
type
==
TSDB_CHILD_TABLE
)
{
if
(
tDecodeI64
(
pCoder
,
&
pME
->
ctbEntry
.
ctime
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pME
->
ctbEntry
.
ttlDays
)
<
0
)
return
-
1
;
if
(
tDecodeCStr
(
pCoder
,
&
pME
->
ctbEntry
.
comment
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pME
->
ctbEntry
.
commentLen
)
<
0
)
return
-
1
;
if
(
pME
->
ctbEntry
.
commentLen
>
0
){
if
(
tDecodeCStr
(
pCoder
,
&
pME
->
ctbEntry
.
comment
)
<
0
)
return
-
1
;
}
if
(
tDecodeI64
(
pCoder
,
&
pME
->
ctbEntry
.
suid
)
<
0
)
return
-
1
;
if
(
tDecodeTag
(
pCoder
,
(
STag
**
)
&
pME
->
ctbEntry
.
pTags
)
<
0
)
return
-
1
;
// (TODO)
debugCheckTags
((
STag
*
)
pME
->
ctbEntry
.
pTags
);
// TODO: remove after debug
}
else
if
(
pME
->
type
==
TSDB_NORMAL_TABLE
)
{
if
(
tDecodeI64
(
pCoder
,
&
pME
->
ntbEntry
.
ctime
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pME
->
ntbEntry
.
ttlDays
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pME
->
ntbEntry
.
commentLen
)
<
0
)
return
-
1
;
if
(
pME
->
ntbEntry
.
commentLen
>
0
){
if
(
tDecodeCStr
(
pCoder
,
&
pME
->
ntbEntry
.
comment
)
<
0
)
return
-
1
;
}
if
(
tDecodeI32v
(
pCoder
,
&
pME
->
ntbEntry
.
ncid
)
<
0
)
return
-
1
;
if
(
tDecodeSSchemaWrapperEx
(
pCoder
,
&
pME
->
ntbEntry
.
schemaRow
)
<
0
)
return
-
1
;
}
else
if
(
pME
->
type
==
TSDB_TSMA_TABLE
)
{
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
2bd2996e
...
...
@@ -320,12 +320,14 @@ int metaCreateTable(SMeta *pMeta, int64_t version, SVCreateTbReq *pReq) {
if
(
me
.
type
==
TSDB_CHILD_TABLE
)
{
me
.
ctbEntry
.
ctime
=
pReq
->
ctime
;
me
.
ctbEntry
.
ttlDays
=
pReq
->
ttl
;
me
.
ctbEntry
.
commentLen
=
pReq
->
commentLen
;
me
.
ctbEntry
.
comment
=
pReq
->
comment
;
me
.
ctbEntry
.
suid
=
pReq
->
ctb
.
suid
;
me
.
ctbEntry
.
pTags
=
pReq
->
ctb
.
pTag
;
}
else
{
me
.
ntbEntry
.
ctime
=
pReq
->
ctime
;
me
.
ntbEntry
.
ttlDays
=
pReq
->
ttl
;
me
.
ntbEntry
.
commentLen
=
pReq
->
commentLen
;
me
.
ntbEntry
.
comment
=
pReq
->
comment
;
me
.
ntbEntry
.
schemaRow
=
pReq
->
ntb
.
schemaRow
;
me
.
ntbEntry
.
ncid
=
me
.
ntbEntry
.
schemaRow
.
pSchema
[
me
.
ntbEntry
.
schemaRow
.
nCols
-
1
].
colId
+
1
;
...
...
@@ -398,7 +400,8 @@ static void metaBuildTtlIdxKey(STtlIdxKey *ttlKey, const SMetaEntry *pME){
if
(
ttlDays
<=
0
)
return
;
ttlKey
->
dtime
=
ctime
+
ttlDays
*
24
*
60
*
60
;
// ttlKey->dtime = ctime / 1000 + ttlDays * 24 * 60 * 60;
ttlKey
->
dtime
=
ctime
/
1000
+
ttlDays
;
ttlKey
->
uid
=
pME
->
uid
;
}
...
...
@@ -582,7 +585,6 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
// save to table db
metaSaveToTbDb
(
pMeta
,
&
entry
);
tdbTbcOpen
(
pMeta
->
pUidIdx
,
&
pUidIdxc
,
&
pMeta
->
txn
);
tdbTbcUpsert
(
pUidIdxc
,
&
entry
.
uid
,
sizeof
(
tb_uid_t
),
&
version
,
sizeof
(
version
),
0
);
metaSaveToSkmDb
(
pMeta
,
&
entry
);
...
...
@@ -809,22 +811,25 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
entry
.
ctbEntry
.
ttlDays
=
pAlterTbReq
->
newTTL
;
metaUpdateTtlIdx
(
pMeta
,
&
entry
);
}
if
(
pAlterTbReq
->
updateComment
)
entry
.
ctbEntry
.
comment
=
pAlterTbReq
->
newComment
;
if
(
pAlterTbReq
->
newCommentLen
>=
0
)
{
entry
.
ctbEntry
.
commentLen
=
pAlterTbReq
->
newCommentLen
;
entry
.
ctbEntry
.
comment
=
pAlterTbReq
->
newComment
;
}
}
else
{
if
(
pAlterTbReq
->
updateTTL
)
{
metaDeleteTtlIdx
(
pMeta
,
&
entry
);
entry
.
ntbEntry
.
ttlDays
=
pAlterTbReq
->
newTTL
;
metaUpdateTtlIdx
(
pMeta
,
&
entry
);
}
if
(
pAlterTbReq
->
updateComment
)
entry
.
ntbEntry
.
comment
=
pAlterTbReq
->
newComment
;
if
(
pAlterTbReq
->
newCommentLen
>=
0
)
{
entry
.
ntbEntry
.
commentLen
=
pAlterTbReq
->
newCommentLen
;
entry
.
ntbEntry
.
comment
=
pAlterTbReq
->
newComment
;
}
}
// save to table db
metaSaveToTbDb
(
pMeta
,
&
entry
);
tdbTbcOpen
(
pMeta
->
pUidIdx
,
&
pUidIdxc
,
&
pMeta
->
txn
);
tdbTbcUpsert
(
pUidIdxc
,
&
entry
.
uid
,
sizeof
(
tb_uid_t
),
&
version
,
sizeof
(
version
),
0
);
metaULock
(
pMeta
);
tdbTbcClose
(
pTbDbc
);
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
2bd2996e
...
...
@@ -34,7 +34,7 @@ int32_t vnodePreprocessReq(SVnode *pVnode, SRpcMsg *pMsg) {
switch
(
pMsg
->
msgType
)
{
case
TDMT_VND_CREATE_TABLE
:
{
int64_t
ctime
=
taosGetTimestamp
Sec
();
int64_t
ctime
=
taosGetTimestamp
Ms
();
int32_t
nReqs
;
tDecoderInit
(
&
dc
,
(
uint8_t
*
)
pMsg
->
pCont
+
sizeof
(
SMsgHead
),
pMsg
->
contLen
-
sizeof
(
SMsgHead
));
...
...
@@ -61,7 +61,7 @@ int32_t vnodePreprocessReq(SVnode *pVnode, SRpcMsg *pMsg) {
SSubmitMsgIter
msgIter
=
{
0
};
SSubmitReq
*
pSubmitReq
=
(
SSubmitReq
*
)
pMsg
->
pCont
;
SSubmitBlk
*
pBlock
=
NULL
;
int64_t
ctime
=
taosGetTimestamp
Sec
();
int64_t
ctime
=
taosGetTimestamp
Ms
();
tb_uid_t
uid
;
tInitSubmitMsgIter
(
pSubmitReq
,
&
msgIter
);
...
...
@@ -106,7 +106,7 @@ int32_t vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
int32_t
len
;
int32_t
ret
;
v
Trace
(
"vgId:%d, start to process write request %s, index:%"
PRId64
,
TD_VID
(
pVnode
),
TMSG_INFO
(
pMsg
->
msgType
),
v
Error
(
"vgId:%d, start to process write request %s, index:%"
PRId64
,
TD_VID
(
pVnode
),
TMSG_INFO
(
pMsg
->
msgType
),
version
);
pVnode
->
state
.
applied
=
version
;
...
...
@@ -404,7 +404,9 @@ static int32_t vnodeProcessDropTtlTbReq(SVnode *pVnode, int64_t version, void *p
if
(
ret
!=
0
){
goto
end
;
}
if
(
taosArrayGetSize
(
tbUids
)
>
0
){
tqUpdateTbUidList
(
pVnode
->
pTq
,
tbUids
,
false
);
}
end:
taosArrayDestroy
(
tbUids
);
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
2bd2996e
...
...
@@ -1299,12 +1299,6 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) {
pColInfoData
=
taosArrayGet
(
p
->
pDataBlock
,
6
);
colDataAppend
(
pColInfoData
,
numOfRows
,
(
char
*
)
&
vgId
,
false
);
// table comment
// todo: set the correct comment
pColInfoData
=
taosArrayGet
(
p
->
pDataBlock
,
8
);
colDataAppendNULL
(
pColInfoData
,
numOfRows
);
char
str
[
256
]
=
{
0
};
int32_t
tableType
=
pInfo
->
pCur
->
mr
.
me
.
type
;
if
(
tableType
==
TSDB_CHILD_TABLE
)
{
// create time
...
...
@@ -1321,11 +1315,25 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) {
colDataAppend
(
pColInfoData
,
numOfRows
,
(
char
*
)
&
mr
.
me
.
stbEntry
.
schemaRow
.
nCols
,
false
);
// super table name
STR_TO_VARSTR
(
str
,
mr
.
me
.
name
);
STR_TO_VARSTR
(
n
,
mr
.
me
.
name
);
pColInfoData
=
taosArrayGet
(
p
->
pDataBlock
,
4
);
colDataAppend
(
pColInfoData
,
numOfRows
,
str
,
false
);
colDataAppend
(
pColInfoData
,
numOfRows
,
n
,
false
);
metaReaderClear
(
&
mr
);
// table comment
pColInfoData
=
taosArrayGet
(
p
->
pDataBlock
,
8
);
if
(
pInfo
->
pCur
->
mr
.
me
.
ctbEntry
.
commentLen
>
0
)
{
char
comment
[
TSDB_TB_COMMENT_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_TO_VARSTR
(
comment
,
pInfo
->
pCur
->
mr
.
me
.
ctbEntry
.
comment
);
colDataAppend
(
pColInfoData
,
numOfRows
,
comment
,
false
);
}
else
if
(
pInfo
->
pCur
->
mr
.
me
.
ctbEntry
.
commentLen
==
0
)
{
char
comment
[
VARSTR_HEADER_SIZE
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_TO_VARSTR
(
comment
,
""
);
colDataAppend
(
pColInfoData
,
numOfRows
,
comment
,
false
);
}
else
{
colDataAppendNULL
(
pColInfoData
,
numOfRows
);
}
// uid
pColInfoData
=
taosArrayGet
(
p
->
pDataBlock
,
5
);
colDataAppend
(
pColInfoData
,
numOfRows
,
(
char
*
)
&
pInfo
->
pCur
->
mr
.
me
.
uid
,
false
);
...
...
@@ -1334,7 +1342,7 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) {
pColInfoData
=
taosArrayGet
(
p
->
pDataBlock
,
7
);
colDataAppend
(
pColInfoData
,
numOfRows
,
(
char
*
)
&
pInfo
->
pCur
->
mr
.
me
.
ctbEntry
.
ttlDays
,
false
);
STR_TO_VARSTR
(
str
,
"CHILD_TABLE"
);
STR_TO_VARSTR
(
n
,
"CHILD_TABLE"
);
}
else
if
(
tableType
==
TSDB_NORMAL_TABLE
)
{
// create time
pColInfoData
=
taosArrayGet
(
p
->
pDataBlock
,
2
);
...
...
@@ -1348,6 +1356,20 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) {
pColInfoData
=
taosArrayGet
(
p
->
pDataBlock
,
4
);
colDataAppendNULL
(
pColInfoData
,
numOfRows
);
// table comment
pColInfoData
=
taosArrayGet
(
p
->
pDataBlock
,
8
);
if
(
pInfo
->
pCur
->
mr
.
me
.
ntbEntry
.
commentLen
>
0
)
{
char
comment
[
TSDB_TB_COMMENT_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_TO_VARSTR
(
comment
,
pInfo
->
pCur
->
mr
.
me
.
ntbEntry
.
comment
);
colDataAppend
(
pColInfoData
,
numOfRows
,
comment
,
false
);
}
else
if
(
pInfo
->
pCur
->
mr
.
me
.
ntbEntry
.
commentLen
==
0
)
{
char
comment
[
VARSTR_HEADER_SIZE
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_TO_VARSTR
(
comment
,
""
);
colDataAppend
(
pColInfoData
,
numOfRows
,
comment
,
false
);
}
else
{
colDataAppendNULL
(
pColInfoData
,
numOfRows
);
}
// uid
pColInfoData
=
taosArrayGet
(
p
->
pDataBlock
,
5
);
colDataAppend
(
pColInfoData
,
numOfRows
,
(
char
*
)
&
pInfo
->
pCur
->
mr
.
me
.
uid
,
false
);
...
...
@@ -1356,11 +1378,11 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) {
pColInfoData
=
taosArrayGet
(
p
->
pDataBlock
,
7
);
colDataAppend
(
pColInfoData
,
numOfRows
,
(
char
*
)
&
pInfo
->
pCur
->
mr
.
me
.
ntbEntry
.
ttlDays
,
false
);
STR_TO_VARSTR
(
str
,
"NORMAL_TABLE"
);
STR_TO_VARSTR
(
n
,
"NORMAL_TABLE"
);
}
pColInfoData
=
taosArrayGet
(
p
->
pDataBlock
,
9
);
colDataAppend
(
pColInfoData
,
numOfRows
,
str
,
false
);
colDataAppend
(
pColInfoData
,
numOfRows
,
n
,
false
);
if
(
++
numOfRows
>=
pOperator
->
resultInfo
.
capacity
)
{
break
;
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
2bd2996e
...
...
@@ -865,6 +865,7 @@ SNode* createDefaultTableOptions(SAstCreateContext* pCxt) {
CHECK_OUT_OF_MEM
(
pOptions
);
pOptions
->
filesFactor
=
TSDB_DEFAULT_ROLLUP_FILE_FACTOR
;
pOptions
->
ttl
=
TSDB_DEFAULT_TABLE_TTL
;
pOptions
->
commentNull
=
true
;
// mark null
return
(
SNode
*
)
pOptions
;
}
...
...
@@ -874,6 +875,7 @@ SNode* createAlterTableOptions(SAstCreateContext* pCxt) {
CHECK_OUT_OF_MEM
(
pOptions
);
pOptions
->
filesFactor
=
-
1
;
pOptions
->
ttl
=
-
1
;
pOptions
->
commentNull
=
true
;
// mark null
return
(
SNode
*
)
pOptions
;
}
...
...
@@ -882,6 +884,7 @@ SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType
switch
(
type
)
{
case
TABLE_OPTION_COMMENT
:
if
(
checkComment
(
pCxt
,
(
SToken
*
)
pVal
,
true
))
{
((
STableOptions
*
)
pOptions
)
->
commentNull
=
false
;
copyStringFormStringToken
((
SToken
*
)
pVal
,
((
STableOptions
*
)
pOptions
)
->
comment
,
sizeof
(((
STableOptions
*
)
pOptions
)
->
comment
));
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
2bd2996e
...
...
@@ -3055,12 +3055,14 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm
columnDefNodeToField
(
pStmt
->
pTags
,
&
pReq
->
pTags
);
pReq
->
numOfColumns
=
LIST_LENGTH
(
pStmt
->
pCols
);
pReq
->
numOfTags
=
LIST_LENGTH
(
pStmt
->
pTags
);
if
(
'\0'
!=
pStmt
->
pOptions
->
comment
[
0
])
{
if
(
pStmt
->
pOptions
->
commentNull
==
false
)
{
pReq
->
comment
=
strdup
(
pStmt
->
pOptions
->
comment
);
if
(
NULL
==
pReq
->
comment
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pReq
->
commentLen
=
strlen
(
pStmt
->
pOptions
->
comment
)
+
1
;
pReq
->
commentLen
=
strlen
(
pStmt
->
pOptions
->
comment
);
}
else
{
pReq
->
commentLen
=
-
1
;
}
SName
tableName
;
...
...
@@ -3109,13 +3111,16 @@ static int32_t translateDropSuperTable(STranslateContext* pCxt, SDropSuperTableS
static
int32_t
setAlterTableField
(
SAlterTableStmt
*
pStmt
,
SMAlterStbReq
*
pAlterReq
)
{
if
(
TSDB_ALTER_TABLE_UPDATE_OPTIONS
==
pStmt
->
alterType
)
{
pAlterReq
->
ttl
=
pStmt
->
pOptions
->
ttl
;
if
(
'\0'
!=
pStmt
->
pOptions
->
comment
[
0
]
)
{
if
(
pStmt
->
pOptions
->
commentNull
==
false
)
{
pAlterReq
->
comment
=
strdup
(
pStmt
->
pOptions
->
comment
);
if
(
NULL
==
pAlterReq
->
comment
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pAlterReq
->
commentLen
=
strlen
(
pStmt
->
pOptions
->
comment
)
+
1
;
pAlterReq
->
commentLen
=
strlen
(
pStmt
->
pOptions
->
comment
);
}
else
{
pAlterReq
->
commentLen
=
-
1
;
}
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -4253,12 +4258,14 @@ static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt*
req
.
type
=
TD_NORMAL_TABLE
;
req
.
name
=
strdup
(
pStmt
->
tableName
);
req
.
ttl
=
pStmt
->
pOptions
->
ttl
;
if
(
'\0'
!=
pStmt
->
pOptions
->
comment
[
0
]
)
{
if
(
pStmt
->
pOptions
->
commentNull
==
false
)
{
req
.
comment
=
strdup
(
pStmt
->
pOptions
->
comment
);
if
(
NULL
==
req
.
comment
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
req
.
commentLen
=
strlen
(
pStmt
->
pOptions
->
comment
)
+
1
;
req
.
commentLen
=
strlen
(
pStmt
->
pOptions
->
comment
);
}
else
{
req
.
commentLen
=
-
1
;
}
req
.
ntb
.
schemaRow
.
nCols
=
LIST_LENGTH
(
pStmt
->
pCols
);
req
.
ntb
.
schemaRow
.
version
=
1
;
...
...
@@ -4411,9 +4418,11 @@ static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap, S
req
.
type
=
TD_CHILD_TABLE
;
req
.
name
=
strdup
(
pStmt
->
tableName
);
req
.
ttl
=
pStmt
->
pOptions
->
ttl
;
if
(
'\0'
!=
pStmt
->
pOptions
->
comment
[
0
]
)
{
if
(
pStmt
->
pOptions
->
commentNull
==
false
)
{
req
.
comment
=
strdup
(
pStmt
->
pOptions
->
comment
);
req
.
commentLen
=
strlen
(
pStmt
->
pOptions
->
comment
)
+
1
;
req
.
commentLen
=
strlen
(
pStmt
->
pOptions
->
comment
);
}
else
{
req
.
commentLen
=
-
1
;
}
req
.
ctb
.
suid
=
suid
;
req
.
ctb
.
pTag
=
(
uint8_t
*
)
pTag
;
...
...
@@ -4993,12 +5002,17 @@ static int32_t buildUpdateOptionsReq(STranslateContext* pCxt, SAlterTableStmt* p
}
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
'\0'
!=
pStmt
->
pOptions
->
comment
[
0
])
{
pReq
->
updateComment
=
true
;
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
pStmt
->
pOptions
->
commentNull
==
false
)
{
pReq
->
newComment
=
strdup
(
pStmt
->
pOptions
->
comment
);
if
(
NULL
==
pReq
->
newComment
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
pReq
->
newCommentLen
=
strlen
(
pReq
->
newComment
);
}
else
{
pReq
->
newCommentLen
=
-
1
;
}
}
return
code
;
...
...
source/libs/parser/test/parInitialATest.cpp
浏览文件 @
2bd2996e
...
...
@@ -91,7 +91,7 @@ TEST_F(ParserInitialATest, alterSTable) {
expect
.
ttl
=
ttl
;
if
(
nullptr
!=
pComment
)
{
expect
.
comment
=
strdup
(
pComment
);
expect
.
commentLen
=
strlen
(
pComment
)
+
1
;
expect
.
commentLen
=
strlen
(
pComment
);
}
expect
.
numOfFields
=
numOfFields
;
...
...
@@ -252,7 +252,7 @@ TEST_F(ParserInitialATest, alterTable) {
expect
.
newTTL
=
ttl
;
}
if
(
nullptr
!=
pComment
)
{
expect
.
updateComment
=
true
;
expect
.
newCommentLen
=
strlen
(
pComment
)
;
expect
.
newComment
=
pComment
;
}
};
...
...
@@ -291,9 +291,10 @@ TEST_F(ParserInitialATest, alterTable) {
ASSERT_EQ
(
memcmp
(
req
.
pTagVal
,
expect
.
pTagVal
,
expect
.
nTagVal
),
0
);
ASSERT_EQ
(
req
.
updateTTL
,
expect
.
updateTTL
);
ASSERT_EQ
(
req
.
newTTL
,
expect
.
newTTL
);
ASSERT_EQ
(
req
.
updateComment
,
expect
.
updateComment
);
if
(
nullptr
!=
expect
.
newComment
)
{
ASSERT_EQ
(
std
::
string
(
req
.
newComment
),
std
::
string
(
expect
.
newComment
));
ASSERT_EQ
(
req
.
newCommentLen
,
strlen
(
req
.
newComment
));
ASSERT_EQ
(
expect
.
newCommentLen
,
strlen
(
expect
.
newComment
));
}
tDecoderClear
(
&
coder
);
...
...
source/libs/parser/test/parInitialCTest.cpp
浏览文件 @
2bd2996e
...
...
@@ -332,7 +332,7 @@ TEST_F(ParserInitialCTest, createStable) {
expect
.
ttl
=
ttl
;
if
(
nullptr
!=
pComment
)
{
expect
.
comment
=
strdup
(
pComment
);
expect
.
commentLen
=
strlen
(
pComment
)
+
1
;
expect
.
commentLen
=
strlen
(
pComment
);
}
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录