Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e28e92ea
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看板
提交
e28e92ea
编写于
6月 16, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:add ttl
上级
f2a19c98
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
164 addition
and
21 deletion
+164
-21
include/common/tmsg.h
include/common/tmsg.h
+3
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+12
-2
source/dnode/mnode/impl/src/mndMain.c
source/dnode/mnode/impl/src/mndMain.c
+42
-0
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+2
-3
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
+4
-0
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+84
-14
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+3
-1
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+12
-1
未找到文件。
include/common/tmsg.h
浏览文件 @
e28e92ea
...
@@ -1806,6 +1806,8 @@ typedef struct SVCreateTbReq {
...
@@ -1806,6 +1806,8 @@ typedef struct SVCreateTbReq {
tb_uid_t
uid
;
tb_uid_t
uid
;
int64_t
ctime
;
int64_t
ctime
;
int32_t
ttl
;
int32_t
ttl
;
int32_t
commentLen
;
char
*
comment
;
int8_t
type
;
int8_t
type
;
union
{
union
{
struct
{
struct
{
...
@@ -1823,6 +1825,7 @@ int tDecodeSVCreateTbReq(SDecoder* pCoder, SVCreateTbReq* pReq);
...
@@ -1823,6 +1825,7 @@ int tDecodeSVCreateTbReq(SDecoder* pCoder, SVCreateTbReq* pReq);
static
FORCE_INLINE
void
tdDestroySVCreateTbReq
(
SVCreateTbReq
*
req
)
{
static
FORCE_INLINE
void
tdDestroySVCreateTbReq
(
SVCreateTbReq
*
req
)
{
taosMemoryFreeClear
(
req
->
name
);
taosMemoryFreeClear
(
req
->
name
);
taosMemoryFreeClear
(
req
->
comment
);
if
(
req
->
type
==
TSDB_CHILD_TABLE
)
{
if
(
req
->
type
==
TSDB_CHILD_TABLE
)
{
taosMemoryFreeClear
(
req
->
ctb
.
pTag
);
taosMemoryFreeClear
(
req
->
ctb
.
pTag
);
}
else
if
(
req
->
type
==
TSDB_NORMAL_TABLE
)
{
}
else
if
(
req
->
type
==
TSDB_NORMAL_TABLE
)
{
...
...
source/common/src/tmsg.c
浏览文件 @
e28e92ea
...
@@ -498,7 +498,7 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
...
@@ -498,7 +498,7 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
}
}
if
(
pReq
->
commentLen
>
0
)
{
if
(
pReq
->
commentLen
>
0
)
{
if
(
tEncodeCStr
WithLen
(
&
encoder
,
pReq
->
comment
,
pReq
->
commentLen
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
comment
)
<
0
)
return
-
1
;
}
}
if
(
pReq
->
ast1Len
>
0
)
{
if
(
pReq
->
ast1Len
>
0
)
{
if
(
tEncodeBinary
(
&
encoder
,
pReq
->
pAst1
,
pReq
->
ast1Len
)
<
0
)
return
-
1
;
if
(
tEncodeBinary
(
&
encoder
,
pReq
->
pAst1
,
pReq
->
ast1Len
)
<
0
)
return
-
1
;
...
@@ -561,7 +561,7 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
...
@@ -561,7 +561,7 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
}
}
if
(
pReq
->
commentLen
>
0
)
{
if
(
pReq
->
commentLen
>
0
)
{
pReq
->
comment
=
taosMemory
Calloc
(
1
,
pReq
->
commentLen
+
1
);
pReq
->
comment
=
taosMemory
Malloc
(
pReq
->
commentLen
);
if
(
pReq
->
comment
==
NULL
)
return
-
1
;
if
(
pReq
->
comment
==
NULL
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
comment
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
comment
)
<
0
)
return
-
1
;
}
}
...
@@ -4321,6 +4321,10 @@ int tEncodeSVCreateTbReq(SEncoder *pCoder, const SVCreateTbReq *pReq) {
...
@@ -4321,6 +4321,10 @@ int tEncodeSVCreateTbReq(SEncoder *pCoder, const SVCreateTbReq *pReq) {
if
(
tEncodeI64
(
pCoder
,
pReq
->
ctime
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pCoder
,
pReq
->
ctime
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pCoder
,
pReq
->
ttl
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pCoder
,
pReq
->
ttl
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pCoder
,
pReq
->
type
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pCoder
,
pReq
->
type
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pCoder
,
pReq
->
commentLen
)
<
0
)
return
-
1
;
if
(
pReq
->
commentLen
>
0
)
{
if
(
tEncodeCStr
(
pCoder
,
pReq
->
comment
)
<
0
)
return
-
1
;
}
if
(
pReq
->
type
==
TSDB_CHILD_TABLE
)
{
if
(
pReq
->
type
==
TSDB_CHILD_TABLE
)
{
if
(
tEncodeI64
(
pCoder
,
pReq
->
ctb
.
suid
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pCoder
,
pReq
->
ctb
.
suid
)
<
0
)
return
-
1
;
...
@@ -4344,6 +4348,12 @@ int tDecodeSVCreateTbReq(SDecoder *pCoder, SVCreateTbReq *pReq) {
...
@@ -4344,6 +4348,12 @@ int tDecodeSVCreateTbReq(SDecoder *pCoder, SVCreateTbReq *pReq) {
if
(
tDecodeI64
(
pCoder
,
&
pReq
->
ctime
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pCoder
,
&
pReq
->
ctime
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pReq
->
ttl
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pReq
->
ttl
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pCoder
,
&
pReq
->
type
)
<
0
)
return
-
1
;
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
);
if
(
pReq
->
comment
==
NULL
)
return
-
1
;
if
(
tDecodeCStrTo
(
pCoder
,
pReq
->
comment
)
<
0
)
return
-
1
;
}
if
(
pReq
->
type
==
TSDB_CHILD_TABLE
)
{
if
(
pReq
->
type
==
TSDB_CHILD_TABLE
)
{
if
(
tDecodeI64
(
pCoder
,
&
pReq
->
ctb
.
suid
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pCoder
,
&
pReq
->
ctb
.
suid
)
<
0
)
return
-
1
;
...
...
source/dnode/mnode/impl/src/mndMain.c
浏览文件 @
e28e92ea
...
@@ -77,12 +77,52 @@ static void mndPullupTelem(SMnode *pMnode) {
...
@@ -77,12 +77,52 @@ static void mndPullupTelem(SMnode *pMnode) {
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
READ_QUEUE
,
&
rpcMsg
);
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
READ_QUEUE
,
&
rpcMsg
);
}
}
static
void
mndPushTtlTime
(
SMnode
*
pMnode
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SVgObj
*
pVgroup
=
NULL
;
void
*
pIter
=
NULL
;
while
(
1
)
{
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pIter
,
(
void
**
)
&
pVgroup
);
if
(
pIter
==
NULL
)
break
;
int32_t
contLen
=
sizeof
(
SMsgHead
)
+
sizeof
(
int32_t
);
SMsgHead
*
pHead
=
taosMemoryMalloc
(
contLen
);
if
(
pHead
==
NULL
)
{
mError
(
"ttl time malloc err. contLen:%d"
,
contLen
);
sdbRelease
(
pSdb
,
pVgroup
);
continue
;
}
pHead
->
contLen
=
htonl
(
pHead
->
contLen
);
pHead
->
vgId
=
htonl
(
pHead
->
vgId
);
int32_t
t
=
taosGetTimestampSec
();
*
(
int32_t
*
)(
pHead
+
sizeof
(
SMsgHead
))
=
htonl
(
t
);
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_VND_DROP_TTL_TABLE
,
.
pCont
=
pHead
,
.
contLen
=
contLen
};
SEpSet
epSet
=
mndGetVgroupEpset
(
pMnode
,
pVgroup
);
int32_t
code
=
tmsgSendReq
(
&
epSet
,
&
rpcMsg
);
if
(
code
!=
0
){
mError
(
"ttl time seed err. code:%d"
,
code
);
}
mError
(
"ttl time seed succ. time:%d"
,
t
);
sdbRelease
(
pSdb
,
pVgroup
);
taosMemoryFree
(
pHead
);
}
}
static
void
*
mndThreadFp
(
void
*
param
)
{
static
void
*
mndThreadFp
(
void
*
param
)
{
SMnode
*
pMnode
=
param
;
SMnode
*
pMnode
=
param
;
int64_t
lastTime
=
0
;
int64_t
lastTime
=
0
;
setThreadName
(
"mnode-timer"
);
setThreadName
(
"mnode-timer"
);
while
(
1
)
{
while
(
1
)
{
if
(
lastTime
%
(
100
)
==
0
)
{
// sleep 1 day for ttl
mndPushTtlTime
(
pMnode
);
}
lastTime
++
;
lastTime
++
;
taosMsleep
(
100
);
taosMsleep
(
100
);
if
(
mndGetStop
(
pMnode
))
break
;
if
(
mndGetStop
(
pMnode
))
break
;
...
@@ -98,6 +138,8 @@ static void *mndThreadFp(void *param) {
...
@@ -98,6 +138,8 @@ static void *mndThreadFp(void *param) {
if
(
lastTime
%
(
tsTelemInterval
*
10
)
==
0
)
{
if
(
lastTime
%
(
tsTelemInterval
*
10
)
==
0
)
{
mndPullupTelem
(
pMnode
);
mndPullupTelem
(
pMnode
);
}
}
}
}
return
NULL
;
return
NULL
;
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
e28e92ea
...
@@ -671,12 +671,12 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
...
@@ -671,12 +671,12 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
pDst
->
numOfTags
=
pCreate
->
numOfTags
;
pDst
->
numOfTags
=
pCreate
->
numOfTags
;
pDst
->
commentLen
=
pCreate
->
commentLen
;
pDst
->
commentLen
=
pCreate
->
commentLen
;
if
(
pDst
->
commentLen
>
0
)
{
if
(
pDst
->
commentLen
>
0
)
{
pDst
->
comment
=
taosMemoryCalloc
(
pDst
->
commentLen
+
1
,
1
);
pDst
->
comment
=
taosMemoryCalloc
(
pDst
->
commentLen
,
1
);
if
(
pDst
->
comment
==
NULL
)
{
if
(
pDst
->
comment
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
memcpy
(
pDst
->
comment
,
pCreate
->
comment
,
pDst
->
commentLen
+
1
);
memcpy
(
pDst
->
comment
,
pCreate
->
comment
,
pDst
->
commentLen
);
}
}
pDst
->
ast1Len
=
pCreate
->
ast1Len
;
pDst
->
ast1Len
=
pCreate
->
ast1Len
;
...
@@ -1208,7 +1208,6 @@ static int32_t mndSetAlterStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj
...
@@ -1208,7 +1208,6 @@ static int32_t mndSetAlterStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj
sdbRelease
(
pSdb
,
pVgroup
);
sdbRelease
(
pSdb
,
pVgroup
);
return
-
1
;
return
-
1
;
}
}
STransAction
action
=
{
0
};
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetVgroupEpset
(
pMnode
,
pVgroup
);
action
.
epSet
=
mndGetVgroupEpset
(
pMnode
,
pVgroup
);
action
.
pCont
=
pReq
;
action
.
pCont
=
pReq
;
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
e28e92ea
...
@@ -210,12 +210,14 @@ struct SMetaEntry {
...
@@ -210,12 +210,14 @@ struct SMetaEntry {
struct
{
struct
{
int64_t
ctime
;
int64_t
ctime
;
int32_t
ttlDays
;
int32_t
ttlDays
;
char
*
comment
;
tb_uid_t
suid
;
tb_uid_t
suid
;
uint8_t
*
pTags
;
uint8_t
*
pTags
;
}
ctbEntry
;
}
ctbEntry
;
struct
{
struct
{
int64_t
ctime
;
int64_t
ctime
;
int32_t
ttlDays
;
int32_t
ttlDays
;
char
*
comment
;
int32_t
ncid
;
// next column id
int32_t
ncid
;
// next column id
SSchemaWrapper
schemaRow
;
SSchemaWrapper
schemaRow
;
}
ntbEntry
;
}
ntbEntry
;
...
...
source/dnode/vnode/src/meta/metaEntry.c
浏览文件 @
e28e92ea
...
@@ -29,12 +29,14 @@ int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) {
...
@@ -29,12 +29,14 @@ int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) {
}
else
if
(
pME
->
type
==
TSDB_CHILD_TABLE
)
{
}
else
if
(
pME
->
type
==
TSDB_CHILD_TABLE
)
{
if
(
tEncodeI64
(
pCoder
,
pME
->
ctbEntry
.
ctime
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pCoder
,
pME
->
ctbEntry
.
ctime
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pCoder
,
pME
->
ctbEntry
.
ttlDays
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pCoder
,
pME
->
ctbEntry
.
ttlDays
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pCoder
,
pME
->
ctbEntry
.
comment
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pCoder
,
pME
->
ctbEntry
.
suid
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pCoder
,
pME
->
ctbEntry
.
suid
)
<
0
)
return
-
1
;
debugCheckTags
((
STag
*
)
pME
->
ctbEntry
.
pTags
);
// TODO: remove after debug
debugCheckTags
((
STag
*
)
pME
->
ctbEntry
.
pTags
);
// TODO: remove after debug
if
(
tEncodeTag
(
pCoder
,
(
const
STag
*
)
pME
->
ctbEntry
.
pTags
)
<
0
)
return
-
1
;
if
(
tEncodeTag
(
pCoder
,
(
const
STag
*
)
pME
->
ctbEntry
.
pTags
)
<
0
)
return
-
1
;
}
else
if
(
pME
->
type
==
TSDB_NORMAL_TABLE
)
{
}
else
if
(
pME
->
type
==
TSDB_NORMAL_TABLE
)
{
if
(
tEncodeI64
(
pCoder
,
pME
->
ntbEntry
.
ctime
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pCoder
,
pME
->
ntbEntry
.
ctime
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pCoder
,
pME
->
ntbEntry
.
ttlDays
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pCoder
,
pME
->
ntbEntry
.
ttlDays
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pCoder
,
pME
->
ntbEntry
.
comment
)
<
0
)
return
-
1
;
if
(
tEncodeI32v
(
pCoder
,
pME
->
ntbEntry
.
ncid
)
<
0
)
return
-
1
;
if
(
tEncodeI32v
(
pCoder
,
pME
->
ntbEntry
.
ncid
)
<
0
)
return
-
1
;
if
(
tEncodeSSchemaWrapper
(
pCoder
,
&
pME
->
ntbEntry
.
schemaRow
)
<
0
)
return
-
1
;
if
(
tEncodeSSchemaWrapper
(
pCoder
,
&
pME
->
ntbEntry
.
schemaRow
)
<
0
)
return
-
1
;
}
else
if
(
pME
->
type
==
TSDB_TSMA_TABLE
)
{
}
else
if
(
pME
->
type
==
TSDB_TSMA_TABLE
)
{
...
@@ -61,12 +63,14 @@ int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) {
...
@@ -61,12 +63,14 @@ int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) {
}
else
if
(
pME
->
type
==
TSDB_CHILD_TABLE
)
{
}
else
if
(
pME
->
type
==
TSDB_CHILD_TABLE
)
{
if
(
tDecodeI64
(
pCoder
,
&
pME
->
ctbEntry
.
ctime
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pCoder
,
&
pME
->
ctbEntry
.
ctime
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pME
->
ctbEntry
.
ttlDays
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pME
->
ctbEntry
.
ttlDays
)
<
0
)
return
-
1
;
if
(
tDecodeCStr
(
pCoder
,
&
pME
->
ctbEntry
.
comment
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pCoder
,
&
pME
->
ctbEntry
.
suid
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pCoder
,
&
pME
->
ctbEntry
.
suid
)
<
0
)
return
-
1
;
if
(
tDecodeTag
(
pCoder
,
(
STag
**
)
&
pME
->
ctbEntry
.
pTags
)
<
0
)
return
-
1
;
// (TODO)
if
(
tDecodeTag
(
pCoder
,
(
STag
**
)
&
pME
->
ctbEntry
.
pTags
)
<
0
)
return
-
1
;
// (TODO)
debugCheckTags
((
STag
*
)
pME
->
ctbEntry
.
pTags
);
// TODO: remove after debug
debugCheckTags
((
STag
*
)
pME
->
ctbEntry
.
pTags
);
// TODO: remove after debug
}
else
if
(
pME
->
type
==
TSDB_NORMAL_TABLE
)
{
}
else
if
(
pME
->
type
==
TSDB_NORMAL_TABLE
)
{
if
(
tDecodeI64
(
pCoder
,
&
pME
->
ntbEntry
.
ctime
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pCoder
,
&
pME
->
ntbEntry
.
ctime
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pME
->
ntbEntry
.
ttlDays
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pME
->
ntbEntry
.
ttlDays
)
<
0
)
return
-
1
;
if
(
tDecodeCStr
(
pCoder
,
&
pME
->
ntbEntry
.
comment
)
<
0
)
return
-
1
;
if
(
tDecodeI32v
(
pCoder
,
&
pME
->
ntbEntry
.
ncid
)
<
0
)
return
-
1
;
if
(
tDecodeI32v
(
pCoder
,
&
pME
->
ntbEntry
.
ncid
)
<
0
)
return
-
1
;
if
(
tDecodeSSchemaWrapperEx
(
pCoder
,
&
pME
->
ntbEntry
.
schemaRow
)
<
0
)
return
-
1
;
if
(
tDecodeSSchemaWrapperEx
(
pCoder
,
&
pME
->
ntbEntry
.
schemaRow
)
<
0
)
return
-
1
;
}
else
if
(
pME
->
type
==
TSDB_TSMA_TABLE
)
{
}
else
if
(
pME
->
type
==
TSDB_TSMA_TABLE
)
{
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
e28e92ea
...
@@ -320,11 +320,13 @@ int metaCreateTable(SMeta *pMeta, int64_t version, SVCreateTbReq *pReq) {
...
@@ -320,11 +320,13 @@ int metaCreateTable(SMeta *pMeta, int64_t version, SVCreateTbReq *pReq) {
if
(
me
.
type
==
TSDB_CHILD_TABLE
)
{
if
(
me
.
type
==
TSDB_CHILD_TABLE
)
{
me
.
ctbEntry
.
ctime
=
pReq
->
ctime
;
me
.
ctbEntry
.
ctime
=
pReq
->
ctime
;
me
.
ctbEntry
.
ttlDays
=
pReq
->
ttl
;
me
.
ctbEntry
.
ttlDays
=
pReq
->
ttl
;
me
.
ctbEntry
.
comment
=
pReq
->
comment
;
me
.
ctbEntry
.
suid
=
pReq
->
ctb
.
suid
;
me
.
ctbEntry
.
suid
=
pReq
->
ctb
.
suid
;
me
.
ctbEntry
.
pTags
=
pReq
->
ctb
.
pTag
;
me
.
ctbEntry
.
pTags
=
pReq
->
ctb
.
pTag
;
}
else
{
}
else
{
me
.
ntbEntry
.
ctime
=
pReq
->
ctime
;
me
.
ntbEntry
.
ctime
=
pReq
->
ctime
;
me
.
ntbEntry
.
ttlDays
=
pReq
->
ttl
;
me
.
ntbEntry
.
ttlDays
=
pReq
->
ttl
;
me
.
ntbEntry
.
comment
=
pReq
->
comment
;
me
.
ntbEntry
.
schemaRow
=
pReq
->
ntb
.
schemaRow
;
me
.
ntbEntry
.
schemaRow
=
pReq
->
ntb
.
schemaRow
;
me
.
ntbEntry
.
ncid
=
me
.
ntbEntry
.
schemaRow
.
pSchema
[
me
.
ntbEntry
.
schemaRow
.
nCols
-
1
].
colId
+
1
;
me
.
ntbEntry
.
ncid
=
me
.
ntbEntry
.
schemaRow
.
pSchema
[
me
.
ntbEntry
.
schemaRow
.
nCols
-
1
].
colId
+
1
;
}
}
...
@@ -412,12 +414,11 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
...
@@ -412,12 +414,11 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
void
*
pData
=
NULL
;
void
*
pData
=
NULL
;
int
nData
=
0
;
int
nData
=
0
;
int
rc
=
0
;
int
rc
=
0
;
int64_t
version
;
SMetaEntry
e
=
{
0
};
SMetaEntry
e
=
{
0
};
SDecoder
dc
=
{
0
};
SDecoder
dc
=
{
0
};
rc
=
tdbTbGet
(
pMeta
->
pUidIdx
,
&
uid
,
sizeof
(
uid
),
&
pData
,
&
nData
);
rc
=
tdbTbGet
(
pMeta
->
pUidIdx
,
&
uid
,
sizeof
(
uid
),
&
pData
,
&
nData
);
version
=
*
(
int64_t
*
)
pData
;
int64_t
version
=
*
(
int64_t
*
)
pData
;
tdbTbGet
(
pMeta
->
pTbDb
,
&
(
STbDbKey
){.
version
=
version
,
.
uid
=
uid
},
sizeof
(
STbDbKey
),
&
pData
,
&
nData
);
tdbTbGet
(
pMeta
->
pTbDb
,
&
(
STbDbKey
){.
version
=
version
,
.
uid
=
uid
},
sizeof
(
STbDbKey
),
&
pData
,
&
nData
);
...
@@ -439,6 +440,7 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
...
@@ -439,6 +440,7 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
// drop schema.db (todo)
// drop schema.db (todo)
}
}
metaError
(
"ttl drop table:%s"
,
e
.
name
);
tDecoderClear
(
&
dc
);
tDecoderClear
(
&
dc
);
tdbFree
(
pData
);
tdbFree
(
pData
);
...
@@ -494,6 +496,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
...
@@ -494,6 +496,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
tDecoderInit
(
&
dc
,
entry
.
pBuf
,
nData
);
tDecoderInit
(
&
dc
,
entry
.
pBuf
,
nData
);
ret
=
metaDecodeEntry
(
&
dc
,
&
entry
);
ret
=
metaDecodeEntry
(
&
dc
,
&
entry
);
ASSERT
(
ret
==
0
);
ASSERT
(
ret
==
0
);
tDecoderClear
(
&
dc
);
if
(
entry
.
type
!=
TSDB_NORMAL_TABLE
)
{
if
(
entry
.
type
!=
TSDB_NORMAL_TABLE
)
{
terrno
=
TSDB_CODE_VND_INVALID_TABLE_ACTION
;
terrno
=
TSDB_CODE_VND_INVALID_TABLE_ACTION
;
...
@@ -579,6 +582,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
...
@@ -579,6 +582,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
// save to table db
// save to table db
metaSaveToTbDb
(
pMeta
,
&
entry
);
metaSaveToTbDb
(
pMeta
,
&
entry
);
tdbTbcOpen
(
pMeta
->
pUidIdx
,
&
pUidIdxc
,
&
pMeta
->
txn
);
tdbTbcUpsert
(
pUidIdxc
,
&
entry
.
uid
,
sizeof
(
tb_uid_t
),
&
version
,
sizeof
(
version
),
0
);
tdbTbcUpsert
(
pUidIdxc
,
&
entry
.
uid
,
sizeof
(
tb_uid_t
),
&
version
,
sizeof
(
version
),
0
);
metaSaveToSkmDb
(
pMeta
,
&
entry
);
metaSaveToSkmDb
(
pMeta
,
&
entry
);
...
@@ -587,14 +591,14 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
...
@@ -587,14 +591,14 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
metaUpdateMetaRsp
(
uid
,
pAlterTbReq
->
tbName
,
pSchema
,
pMetaRsp
);
metaUpdateMetaRsp
(
uid
,
pAlterTbReq
->
tbName
,
pSchema
,
pMetaRsp
);
if
(
entry
.
pBuf
)
taosMemoryFree
(
entry
.
pBuf
);
if
(
pNewSchema
)
taosMemoryFree
(
pNewSchema
);
if
(
pNewSchema
)
taosMemoryFree
(
pNewSchema
);
tDecoderClear
(
&
dc
);
tdbTbcClose
(
pTbDbc
);
tdbTbcClose
(
pTbDbc
);
tdbTbcClose
(
pUidIdxc
);
tdbTbcClose
(
pUidIdxc
);
return
0
;
return
0
;
_err:
_err:
tDecoderClear
(
&
dc
);
if
(
entry
.
pBuf
)
taosMemoryFree
(
entry
.
pBuf
);
tdbTbcClose
(
pTbDbc
);
tdbTbcClose
(
pTbDbc
);
tdbTbcClose
(
pUidIdxc
);
tdbTbcClose
(
pUidIdxc
);
return
-
1
;
return
-
1
;
...
@@ -748,18 +752,84 @@ _err:
...
@@ -748,18 +752,84 @@ _err:
}
}
static
int
metaUpdateTableOptions
(
SMeta
*
pMeta
,
int64_t
version
,
SVAlterTbReq
*
pAlterTbReq
)
{
static
int
metaUpdateTableOptions
(
SMeta
*
pMeta
,
int64_t
version
,
SVAlterTbReq
*
pAlterTbReq
)
{
if
(
commentLen
>
0
)
{
void
*
pVal
=
NULL
;
pNew
->
commentLen
=
commentLen
;
int
nVal
=
0
;
pNew
->
comment
=
taosMemoryCalloc
(
1
,
commentLen
);
const
void
*
pData
=
NULL
;
if
(
pNew
->
comment
==
NULL
)
{
int
nData
=
0
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
int
ret
=
0
;
return
-
1
;
tb_uid_t
uid
;
}
int64_t
oversion
;
memcpy
(
pNew
->
comment
,
pComment
,
commentLen
);
SMetaEntry
entry
=
{
0
};
int
c
=
0
;
// search name index
ret
=
tdbTbGet
(
pMeta
->
pNameIdx
,
pAlterTbReq
->
tbName
,
strlen
(
pAlterTbReq
->
tbName
)
+
1
,
&
pVal
,
&
nVal
);
if
(
ret
<
0
)
{
terrno
=
TSDB_CODE_VND_TABLE_NOT_EXIST
;
return
-
1
;
}
}
if
(
ttl
>=
0
)
{
pNew
->
ttl
=
ttl
;
uid
=
*
(
tb_uid_t
*
)
pVal
;
tdbFree
(
pVal
);
pVal
=
NULL
;
// search uid index
TBC
*
pUidIdxc
=
NULL
;
tdbTbcOpen
(
pMeta
->
pUidIdx
,
&
pUidIdxc
,
&
pMeta
->
txn
);
tdbTbcMoveTo
(
pUidIdxc
,
&
uid
,
sizeof
(
uid
),
&
c
);
ASSERT
(
c
==
0
);
tdbTbcGet
(
pUidIdxc
,
NULL
,
NULL
,
&
pData
,
&
nData
);
oversion
=
*
(
int64_t
*
)
pData
;
// search table.db
TBC
*
pTbDbc
=
NULL
;
tdbTbcOpen
(
pMeta
->
pTbDb
,
&
pTbDbc
,
&
pMeta
->
txn
);
tdbTbcMoveTo
(
pTbDbc
,
&
((
STbDbKey
){.
uid
=
uid
,
.
version
=
oversion
}),
sizeof
(
STbDbKey
),
&
c
);
ASSERT
(
c
==
0
);
tdbTbcGet
(
pTbDbc
,
NULL
,
NULL
,
&
pData
,
&
nData
);
// get table entry
SDecoder
dc
=
{
0
};
entry
.
pBuf
=
taosMemoryMalloc
(
nData
);
memcpy
(
entry
.
pBuf
,
pData
,
nData
);
tDecoderInit
(
&
dc
,
entry
.
pBuf
,
nData
);
ret
=
metaDecodeEntry
(
&
dc
,
&
entry
);
ASSERT
(
ret
==
0
);
tDecoderClear
(
&
dc
);
entry
.
version
=
version
;
metaWLock
(
pMeta
);
// build SMetaEntry
if
(
entry
.
type
==
TSDB_CHILD_TABLE
)
{
if
(
pAlterTbReq
->
updateTTL
)
{
metaDeleteTtlIdx
(
pMeta
,
&
entry
);
entry
.
ctbEntry
.
ttlDays
=
pAlterTbReq
->
newTTL
;
metaUpdateTtlIdx
(
pMeta
,
&
entry
);
}
if
(
pAlterTbReq
->
updateComment
)
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
;
}
}
// 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
);
tdbTbcClose
(
pUidIdxc
);
if
(
entry
.
pBuf
)
taosMemoryFree
(
entry
.
pBuf
);
return
0
;
return
0
;
}
}
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
e28e92ea
...
@@ -398,7 +398,9 @@ static int32_t vnodeProcessDropTtlTbReq(SVnode *pVnode, int64_t version, void *p
...
@@ -398,7 +398,9 @@ static int32_t vnodeProcessDropTtlTbReq(SVnode *pVnode, int64_t version, void *p
SArray
*
tbUids
=
taosArrayInit
(
8
,
sizeof
(
int64_t
));
SArray
*
tbUids
=
taosArrayInit
(
8
,
sizeof
(
int64_t
));
if
(
tbUids
==
NULL
)
return
TSDB_CODE_OUT_OF_MEMORY
;
if
(
tbUids
==
NULL
)
return
TSDB_CODE_OUT_OF_MEMORY
;
int32_t
ret
=
metaTtlDropTable
(
pVnode
->
pMeta
,
*
(
int64_t
*
)
pReq
,
tbUids
);
int32_t
t
=
ntohl
(
*
(
int32_t
*
)
pReq
);
vError
(
"rec ttl time:%d"
,
t
);
int32_t
ret
=
metaTtlDropTable
(
pVnode
->
pMeta
,
t
,
tbUids
);
if
(
ret
!=
0
){
if
(
ret
!=
0
){
goto
end
;
goto
end
;
}
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
e28e92ea
...
@@ -4253,6 +4253,13 @@ static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt*
...
@@ -4253,6 +4253,13 @@ static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt*
req
.
type
=
TD_NORMAL_TABLE
;
req
.
type
=
TD_NORMAL_TABLE
;
req
.
name
=
strdup
(
pStmt
->
tableName
);
req
.
name
=
strdup
(
pStmt
->
tableName
);
req
.
ttl
=
pStmt
->
pOptions
->
ttl
;
req
.
ttl
=
pStmt
->
pOptions
->
ttl
;
if
(
'\0'
!=
pStmt
->
pOptions
->
comment
[
0
])
{
req
.
comment
=
strdup
(
pStmt
->
pOptions
->
comment
);
if
(
NULL
==
req
.
comment
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
req
.
commentLen
=
strlen
(
pStmt
->
pOptions
->
comment
)
+
1
;
}
req
.
ntb
.
schemaRow
.
nCols
=
LIST_LENGTH
(
pStmt
->
pCols
);
req
.
ntb
.
schemaRow
.
nCols
=
LIST_LENGTH
(
pStmt
->
pCols
);
req
.
ntb
.
schemaRow
.
version
=
1
;
req
.
ntb
.
schemaRow
.
version
=
1
;
req
.
ntb
.
schemaRow
.
pSchema
=
taosMemoryCalloc
(
req
.
ntb
.
schemaRow
.
nCols
,
sizeof
(
SSchema
));
req
.
ntb
.
schemaRow
.
pSchema
=
taosMemoryCalloc
(
req
.
ntb
.
schemaRow
.
nCols
,
sizeof
(
SSchema
));
...
@@ -4404,6 +4411,10 @@ static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap, S
...
@@ -4404,6 +4411,10 @@ static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap, S
req
.
type
=
TD_CHILD_TABLE
;
req
.
type
=
TD_CHILD_TABLE
;
req
.
name
=
strdup
(
pStmt
->
tableName
);
req
.
name
=
strdup
(
pStmt
->
tableName
);
req
.
ttl
=
pStmt
->
pOptions
->
ttl
;
req
.
ttl
=
pStmt
->
pOptions
->
ttl
;
if
(
'\0'
!=
pStmt
->
pOptions
->
comment
[
0
])
{
req
.
comment
=
strdup
(
pStmt
->
pOptions
->
comment
);
req
.
commentLen
=
strlen
(
pStmt
->
pOptions
->
comment
)
+
1
;
}
req
.
ctb
.
suid
=
suid
;
req
.
ctb
.
suid
=
suid
;
req
.
ctb
.
pTag
=
(
uint8_t
*
)
pTag
;
req
.
ctb
.
pTag
=
(
uint8_t
*
)
pTag
;
if
(
pStmt
->
ignoreExists
)
{
if
(
pStmt
->
ignoreExists
)
{
...
@@ -4982,7 +4993,7 @@ static int32_t buildUpdateOptionsReq(STranslateContext* pCxt, SAlterTableStmt* p
...
@@ -4982,7 +4993,7 @@ static int32_t buildUpdateOptionsReq(STranslateContext* pCxt, SAlterTableStmt* p
}
}
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
'\0'
!=
pStmt
->
pOptions
->
comment
[
0
]
)
{
pReq
->
updateComment
=
true
;
pReq
->
updateComment
=
true
;
pReq
->
newComment
=
strdup
(
pStmt
->
pOptions
->
comment
);
pReq
->
newComment
=
strdup
(
pStmt
->
pOptions
->
comment
);
if
(
NULL
==
pReq
->
newComment
)
{
if
(
NULL
==
pReq
->
newComment
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录