Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1b3fde4a
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1191
Star
22018
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看板
提交
1b3fde4a
编写于
7月 01, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: stable mgmt
上级
126d884a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
100 addition
and
80 deletion
+100
-80
include/common/tmsg.h
include/common/tmsg.h
+3
-2
source/common/src/tmsg.c
source/common/src/tmsg.c
+26
-32
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+2
-1
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+63
-40
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+6
-5
未找到文件。
include/common/tmsg.h
浏览文件 @
1b3fde4a
...
@@ -436,15 +436,16 @@ typedef struct {
...
@@ -436,15 +436,16 @@ typedef struct {
int32_t
ttl
;
int32_t
ttl
;
int32_t
numOfColumns
;
int32_t
numOfColumns
;
int32_t
numOfTags
;
int32_t
numOfTags
;
int32_t
numOfFuncs
;
int32_t
commentLen
;
int32_t
commentLen
;
int32_t
ast1Len
;
int32_t
ast1Len
;
int32_t
ast2Len
;
int32_t
ast2Len
;
SArray
*
pColumns
;
// array of SField
SArray
*
pColumns
;
// array of SField
SArray
*
pTags
;
// array of SField
SArray
*
pTags
;
// array of SField
char
*
comment
;
SArray
*
pFuncs
;
char
*
pComment
;
char
*
pAst1
;
char
*
pAst1
;
char
*
pAst2
;
char
*
pAst2
;
SArray
*
pFuncs
;
}
SMCreateStbReq
;
}
SMCreateStbReq
;
int32_t
tSerializeSMCreateStbReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateStbReq
*
pReq
);
int32_t
tSerializeSMCreateStbReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateStbReq
*
pReq
);
...
...
source/common/src/tmsg.c
浏览文件 @
1b3fde4a
...
@@ -503,6 +503,7 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
...
@@ -503,6 +503,7 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
if
(
tEncodeI32
(
&
encoder
,
pReq
->
ttl
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
ttl
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfColumns
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfColumns
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfTags
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfTags
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfFuncs
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
commentLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
commentLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
ast1Len
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
ast1Len
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
ast2Len
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
ast2Len
)
<
0
)
return
-
1
;
...
@@ -510,21 +511,26 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
...
@@ -510,21 +511,26 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfColumns
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfColumns
;
++
i
)
{
SField
*
pField
=
taosArrayGet
(
pReq
->
pColumns
,
i
);
SField
*
pField
=
taosArrayGet
(
pReq
->
pColumns
,
i
);
if
(
tEncodeI8
(
&
encoder
,
pField
->
type
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pField
->
type
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pField
->
flags
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pField
->
bytes
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pField
->
bytes
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pField
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pField
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pField
->
flags
)
<
0
)
return
-
1
;
}
}
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfTags
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfTags
;
++
i
)
{
SField
*
pField
=
taosArrayGet
(
pReq
->
pTags
,
i
);
SField
*
pField
=
taosArrayGet
(
pReq
->
pTags
,
i
);
if
(
tEncodeI8
(
&
encoder
,
pField
->
type
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pField
->
type
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pField
->
flags
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pField
->
bytes
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pField
->
bytes
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pField
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pField
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pField
->
flags
)
<
0
)
return
-
1
;
}
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfFuncs
;
++
i
)
{
const
char
*
pFunc
=
taosArrayGet
(
pReq
->
pFuncs
,
i
);
if
(
tEncodeCStr
(
&
encoder
,
pFunc
)
<
0
)
return
-
1
;
}
}
if
(
pReq
->
commentLen
>
0
)
{
if
(
pReq
->
commentLen
>
0
)
{
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
c
omment
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
pC
omment
)
<
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
;
...
@@ -533,13 +539,6 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
...
@@ -533,13 +539,6 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
if
(
tEncodeBinary
(
&
encoder
,
pReq
->
pAst2
,
pReq
->
ast2Len
)
<
0
)
return
-
1
;
if
(
tEncodeBinary
(
&
encoder
,
pReq
->
pAst2
,
pReq
->
ast2Len
)
<
0
)
return
-
1
;
}
}
int32_t
numOfFuncs
=
taosArrayGetSize
(
pReq
->
pFuncs
);
if
(
tEncodeI32
(
&
encoder
,
numOfFuncs
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
numOfFuncs
;
++
i
)
{
const
char
*
pFunc
=
taosArrayGet
(
pReq
->
pFuncs
,
i
);
if
(
tEncodeCStr
(
&
encoder
,
pFunc
)
<
0
)
return
-
1
;
}
tEndEncode
(
&
encoder
);
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
int32_t
tlen
=
encoder
.
pos
;
...
@@ -561,13 +560,15 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
...
@@ -561,13 +560,15 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
ttl
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
ttl
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfColumns
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfColumns
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfTags
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfTags
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfFuncs
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
commentLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
commentLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
ast1Len
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
ast1Len
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
ast2Len
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
ast2Len
)
<
0
)
return
-
1
;
pReq
->
pColumns
=
taosArrayInit
(
pReq
->
numOfColumns
,
sizeof
(
SField
));
pReq
->
pColumns
=
taosArrayInit
(
pReq
->
numOfColumns
,
sizeof
(
SField
));
pReq
->
pTags
=
taosArrayInit
(
pReq
->
numOfTags
,
sizeof
(
SField
));
pReq
->
pTags
=
taosArrayInit
(
pReq
->
numOfTags
,
sizeof
(
SField
));
if
(
pReq
->
pColumns
==
NULL
||
pReq
->
pTags
==
NULL
)
{
pReq
->
pFuncs
=
taosArrayInit
(
pReq
->
numOfFuncs
,
TSDB_FUNC_NAME_LEN
);
if
(
pReq
->
pColumns
==
NULL
||
pReq
->
pTags
==
NULL
||
pReq
->
pFuncs
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
...
@@ -596,10 +597,19 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
...
@@ -596,10 +597,19 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
}
}
}
}
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfFuncs
;
++
i
)
{
char
pFunc
[
TSDB_FUNC_NAME_LEN
]
=
{
0
};
if
(
tDecodeCStrTo
(
&
decoder
,
pFunc
)
<
0
)
return
-
1
;
if
(
taosArrayPush
(
pReq
->
pFuncs
,
pFunc
)
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
}
if
(
pReq
->
commentLen
>
0
)
{
if
(
pReq
->
commentLen
>
0
)
{
pReq
->
c
omment
=
taosMemoryMalloc
(
pReq
->
commentLen
+
1
);
pReq
->
pC
omment
=
taosMemoryMalloc
(
pReq
->
commentLen
+
1
);
if
(
pReq
->
c
omment
==
NULL
)
return
-
1
;
if
(
pReq
->
pC
omment
==
NULL
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
c
omment
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
pC
omment
)
<
0
)
return
-
1
;
}
}
if
(
pReq
->
ast1Len
>
0
)
{
if
(
pReq
->
ast1Len
>
0
)
{
...
@@ -614,23 +624,7 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
...
@@ -614,23 +624,7 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
pAst2
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
pAst2
)
<
0
)
return
-
1
;
}
}
int32_t
numOfFuncs
=
0
;
if
(
tDecodeI32
(
&
decoder
,
&
numOfFuncs
)
<
0
)
return
-
1
;
if
(
numOfFuncs
>
0
)
{
pReq
->
pFuncs
=
taosArrayInit
(
numOfFuncs
,
TSDB_FUNC_NAME_LEN
);
if
(
NULL
==
pReq
->
pFuncs
)
return
-
1
;
}
for
(
int32_t
i
=
0
;
i
<
numOfFuncs
;
++
i
)
{
char
pFunc
[
TSDB_FUNC_NAME_LEN
]
=
{
0
};
if
(
tDecodeCStrTo
(
&
decoder
,
pFunc
)
<
0
)
return
-
1
;
if
(
taosArrayPush
(
pReq
->
pFuncs
,
pFunc
)
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
}
tEndDecode
(
&
decoder
);
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
tDecoderClear
(
&
decoder
);
return
0
;
return
0
;
}
}
...
@@ -638,10 +632,10 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
...
@@ -638,10 +632,10 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
void
tFreeSMCreateStbReq
(
SMCreateStbReq
*
pReq
)
{
void
tFreeSMCreateStbReq
(
SMCreateStbReq
*
pReq
)
{
taosArrayDestroy
(
pReq
->
pColumns
);
taosArrayDestroy
(
pReq
->
pColumns
);
taosArrayDestroy
(
pReq
->
pTags
);
taosArrayDestroy
(
pReq
->
pTags
);
taosMemoryFreeClear
(
pReq
->
comment
);
taosArrayDestroy
(
pReq
->
pFuncs
);
taosMemoryFreeClear
(
pReq
->
pComment
);
taosMemoryFreeClear
(
pReq
->
pAst1
);
taosMemoryFreeClear
(
pReq
->
pAst1
);
taosMemoryFreeClear
(
pReq
->
pAst2
);
taosMemoryFreeClear
(
pReq
->
pAst2
);
taosArrayDestroy
(
pReq
->
pFuncs
);
}
}
int32_t
tSerializeSMDropStbReq
(
void
*
buf
,
int32_t
bufLen
,
SMDropStbReq
*
pReq
)
{
int32_t
tSerializeSMDropStbReq
(
void
*
buf
,
int32_t
bufLen
,
SMDropStbReq
*
pReq
)
{
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
1b3fde4a
...
@@ -341,11 +341,12 @@ typedef struct {
...
@@ -341,11 +341,12 @@ typedef struct {
int32_t
colVer
;
int32_t
colVer
;
int32_t
smaVer
;
int32_t
smaVer
;
int32_t
nextColId
;
int32_t
nextColId
;
int64_t
watermark
[
2
];
int64_t
maxdelay
[
2
];
int64_t
maxdelay
[
2
];
int64_t
watermark
[
2
];
int32_t
ttl
;
int32_t
ttl
;
int32_t
numOfColumns
;
int32_t
numOfColumns
;
int32_t
numOfTags
;
int32_t
numOfTags
;
int32_t
numOfFuncs
;
int32_t
commentLen
;
int32_t
commentLen
;
int32_t
ast1Len
;
int32_t
ast1Len
;
int32_t
ast2Len
;
int32_t
ast2Len
;
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
1b3fde4a
...
@@ -78,7 +78,7 @@ void mndCleanupStb(SMnode *pMnode) {}
...
@@ -78,7 +78,7 @@ void mndCleanupStb(SMnode *pMnode) {}
SSdbRaw
*
mndStbActionEncode
(
SStbObj
*
pStb
)
{
SSdbRaw
*
mndStbActionEncode
(
SStbObj
*
pStb
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
int32_t
size
=
sizeof
(
SStbObj
)
+
(
pStb
->
numOfColumns
+
pStb
->
numOfTags
)
*
sizeof
(
SSchema
)
+
+
pStb
->
commentLen
+
int32_t
size
=
sizeof
(
SStbObj
)
+
(
pStb
->
numOfColumns
+
pStb
->
numOfTags
)
*
sizeof
(
SSchema
)
+
pStb
->
commentLen
+
pStb
->
ast1Len
+
pStb
->
ast2Len
+
STB_RESERVE_SIZE
+
taosArrayGetSize
(
pStb
->
pFuncs
)
*
TSDB_FUNC_NAME_LEN
;
pStb
->
ast1Len
+
pStb
->
ast2Len
+
STB_RESERVE_SIZE
+
taosArrayGetSize
(
pStb
->
pFuncs
)
*
TSDB_FUNC_NAME_LEN
;
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_STB
,
STB_VER_NUMBER
,
size
);
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_STB
,
STB_VER_NUMBER
,
size
);
if
(
pRaw
==
NULL
)
goto
_OVER
;
if
(
pRaw
==
NULL
)
goto
_OVER
;
...
@@ -92,6 +92,7 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
...
@@ -92,6 +92,7 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
SDB_SET_INT64
(
pRaw
,
dataPos
,
pStb
->
dbUid
,
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pStb
->
dbUid
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
tagVer
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
tagVer
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
colVer
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
colVer
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
smaVer
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
nextColId
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
nextColId
,
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pStb
->
maxdelay
[
0
],
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pStb
->
maxdelay
[
0
],
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pStb
->
maxdelay
[
1
],
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pStb
->
maxdelay
[
1
],
_OVER
)
...
@@ -100,17 +101,11 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
...
@@ -100,17 +101,11 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
ttl
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
ttl
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfColumns
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfColumns
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfTags
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfTags
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfFuncs
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
commentLen
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
commentLen
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
ast1Len
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
ast1Len
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
ast2Len
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
ast2Len
,
_OVER
)
int32_t
funcNum
=
taosArrayGetSize
(
pStb
->
pFuncs
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
funcNum
,
_OVER
)
for
(
int32_t
i
=
0
;
i
<
funcNum
;
++
i
)
{
char
*
func
=
taosArrayGet
(
pStb
->
pFuncs
,
i
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
func
,
TSDB_FUNC_NAME_LEN
,
_OVER
)
}
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfColumns
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfColumns
;
++
i
)
{
SSchema
*
pSchema
=
&
pStb
->
pColumns
[
i
];
SSchema
*
pSchema
=
&
pStb
->
pColumns
[
i
];
SDB_SET_INT8
(
pRaw
,
dataPos
,
pSchema
->
type
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pSchema
->
type
,
_OVER
)
...
@@ -129,15 +124,23 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
...
@@ -129,15 +124,23 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
_OVER
)
}
}
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfFuncs
;
++
i
)
{
char
*
func
=
taosArrayGet
(
pStb
->
pFuncs
,
i
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
func
,
TSDB_FUNC_NAME_LEN
,
_OVER
)
}
if
(
pStb
->
commentLen
>
0
)
{
if
(
pStb
->
commentLen
>
0
)
{
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pStb
->
comment
,
pStb
->
commentLen
+
1
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pStb
->
comment
,
pStb
->
commentLen
+
1
,
_OVER
)
}
}
if
(
pStb
->
ast1Len
>
0
)
{
if
(
pStb
->
ast1Len
>
0
)
{
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pStb
->
pAst1
,
pStb
->
ast1Len
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pStb
->
pAst1
,
pStb
->
ast1Len
,
_OVER
)
}
}
if
(
pStb
->
ast2Len
>
0
)
{
if
(
pStb
->
ast2Len
>
0
)
{
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pStb
->
pAst2
,
pStb
->
ast2Len
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pStb
->
pAst2
,
pStb
->
ast2Len
,
_OVER
)
}
}
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
STB_RESERVE_SIZE
,
_OVER
)
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
STB_RESERVE_SIZE
,
_OVER
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
_OVER
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
_OVER
)
...
@@ -180,6 +183,7 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
...
@@ -180,6 +183,7 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pStb
->
dbUid
,
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pStb
->
dbUid
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
tagVer
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
tagVer
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
colVer
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
colVer
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
smaVer
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
nextColId
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
nextColId
,
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pStb
->
maxdelay
[
0
],
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pStb
->
maxdelay
[
0
],
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pStb
->
maxdelay
[
1
],
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pStb
->
maxdelay
[
1
],
_OVER
)
...
@@ -188,27 +192,15 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
...
@@ -188,27 +192,15 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
ttl
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
ttl
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
numOfColumns
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
numOfColumns
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
numOfTags
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
numOfTags
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
numOfFuncs
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
commentLen
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
commentLen
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
ast1Len
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
ast1Len
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
ast2Len
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
ast2Len
,
_OVER
)
int32_t
funcNum
=
0
;
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
funcNum
,
_OVER
)
if
(
funcNum
>
0
)
{
pStb
->
pFuncs
=
taosArrayInit
(
funcNum
,
TSDB_FUNC_NAME_LEN
);
if
(
NULL
==
pStb
->
pFuncs
)
{
goto
_OVER
;
}
char
funcName
[
TSDB_FUNC_NAME_LEN
];
for
(
int32_t
i
=
0
;
i
<
funcNum
;
++
i
)
{
SDB_GET_BINARY
(
pRaw
,
dataPos
,
funcName
,
TSDB_FUNC_NAME_LEN
,
_OVER
)
taosArrayPush
(
pStb
->
pFuncs
,
funcName
);
}
}
pStb
->
pColumns
=
taosMemoryCalloc
(
pStb
->
numOfColumns
,
sizeof
(
SSchema
));
pStb
->
pColumns
=
taosMemoryCalloc
(
pStb
->
numOfColumns
,
sizeof
(
SSchema
));
pStb
->
pTags
=
taosMemoryCalloc
(
pStb
->
numOfTags
,
sizeof
(
SSchema
));
pStb
->
pTags
=
taosMemoryCalloc
(
pStb
->
numOfTags
,
sizeof
(
SSchema
));
if
(
pStb
->
pColumns
==
NULL
||
pStb
->
pTags
==
NULL
)
{
pStb
->
pFuncs
=
taosMemoryCalloc
(
pStb
->
numOfFuncs
,
TSDB_FUNC_NAME_LEN
);
if
(
pStb
->
pColumns
==
NULL
||
pStb
->
pTags
==
NULL
||
pStb
->
pFuncs
==
NULL
)
{
goto
_OVER
;
goto
_OVER
;
}
}
...
@@ -230,16 +222,24 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
...
@@ -230,16 +222,24 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
_OVER
)
}
}
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfFuncs
;
++
i
)
{
char
funcName
[
TSDB_FUNC_NAME_LEN
]
=
{
0
};
SDB_GET_BINARY
(
pRaw
,
dataPos
,
funcName
,
TSDB_FUNC_NAME_LEN
,
_OVER
)
taosArrayPush
(
pStb
->
pFuncs
,
funcName
);
}
if
(
pStb
->
commentLen
>
0
)
{
if
(
pStb
->
commentLen
>
0
)
{
pStb
->
comment
=
taosMemoryCalloc
(
pStb
->
commentLen
+
1
,
1
);
pStb
->
comment
=
taosMemoryCalloc
(
pStb
->
commentLen
+
1
,
1
);
if
(
pStb
->
comment
==
NULL
)
goto
_OVER
;
if
(
pStb
->
comment
==
NULL
)
goto
_OVER
;
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pStb
->
comment
,
pStb
->
commentLen
+
1
,
_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pStb
->
comment
,
pStb
->
commentLen
+
1
,
_OVER
)
}
}
if
(
pStb
->
ast1Len
>
0
)
{
if
(
pStb
->
ast1Len
>
0
)
{
pStb
->
pAst1
=
taosMemoryCalloc
(
pStb
->
ast1Len
,
1
);
pStb
->
pAst1
=
taosMemoryCalloc
(
pStb
->
ast1Len
,
1
);
if
(
pStb
->
pAst1
==
NULL
)
goto
_OVER
;
if
(
pStb
->
pAst1
==
NULL
)
goto
_OVER
;
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pStb
->
pAst1
,
pStb
->
ast1Len
,
_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pStb
->
pAst1
,
pStb
->
ast1Len
,
_OVER
)
}
}
if
(
pStb
->
ast2Len
>
0
)
{
if
(
pStb
->
ast2Len
>
0
)
{
pStb
->
pAst2
=
taosMemoryCalloc
(
pStb
->
ast2Len
,
1
);
pStb
->
pAst2
=
taosMemoryCalloc
(
pStb
->
ast2Len
,
1
);
if
(
pStb
->
pAst2
==
NULL
)
goto
_OVER
;
if
(
pStb
->
pAst2
==
NULL
)
goto
_OVER
;
...
@@ -273,6 +273,7 @@ static int32_t mndStbActionDelete(SSdb *pSdb, SStbObj *pStb) {
...
@@ -273,6 +273,7 @@ static int32_t mndStbActionDelete(SSdb *pSdb, SStbObj *pStb) {
taosMemoryFreeClear
(
pStb
->
pColumns
);
taosMemoryFreeClear
(
pStb
->
pColumns
);
taosMemoryFreeClear
(
pStb
->
pTags
);
taosMemoryFreeClear
(
pStb
->
pTags
);
taosMemoryFreeClear
(
pStb
->
comment
);
taosMemoryFreeClear
(
pStb
->
comment
);
taosMemoryFreeClear
(
pStb
->
pFuncs
);
taosMemoryFreeClear
(
pStb
->
pAst1
);
taosMemoryFreeClear
(
pStb
->
pAst1
);
taosMemoryFreeClear
(
pStb
->
pAst2
);
taosMemoryFreeClear
(
pStb
->
pAst2
);
taosArrayDestroy
(
pStb
->
pFuncs
);
taosArrayDestroy
(
pStb
->
pFuncs
);
...
@@ -319,10 +320,9 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
...
@@ -319,10 +320,9 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
taosWUnLockLatch
(
&
pOld
->
lock
);
taosWUnLockLatch
(
&
pOld
->
lock
);
}
}
}
}
pOld
->
commentLen
=
pNew
->
commentLen
;
if
(
pOld
->
ast1Len
<
pNew
->
ast1Len
)
{
if
(
pOld
->
ast1Len
<
pNew
->
ast1Len
)
{
void
*
pAst1
=
taosMemoryMalloc
(
pNew
->
ast1Len
);
void
*
pAst1
=
taosMemoryMalloc
(
pNew
->
ast1Len
+
1
);
if
(
pAst1
!=
NULL
)
{
if
(
pAst1
!=
NULL
)
{
taosMemoryFree
(
pOld
->
pAst1
);
taosMemoryFree
(
pOld
->
pAst1
);
pOld
->
pAst1
=
pAst1
;
pOld
->
pAst1
=
pAst1
;
...
@@ -334,7 +334,7 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
...
@@ -334,7 +334,7 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
}
}
if
(
pOld
->
ast2Len
<
pNew
->
ast2Len
)
{
if
(
pOld
->
ast2Len
<
pNew
->
ast2Len
)
{
void
*
pAst2
=
taosMemoryMalloc
(
pNew
->
ast2Len
);
void
*
pAst2
=
taosMemoryMalloc
(
pNew
->
ast2Len
+
1
);
if
(
pAst2
!=
NULL
)
{
if
(
pAst2
!=
NULL
)
{
taosMemoryFree
(
pOld
->
pAst2
);
taosMemoryFree
(
pOld
->
pAst2
);
pOld
->
pAst2
=
pAst2
;
pOld
->
pAst2
=
pAst2
;
...
@@ -361,12 +361,15 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
...
@@ -361,12 +361,15 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
}
}
if
(
pNew
->
commentLen
>
0
)
{
if
(
pNew
->
commentLen
>
0
)
{
memcpy
(
pOld
->
comment
,
pNew
->
comment
,
pNew
->
commentLen
+
1
);
memcpy
(
pOld
->
comment
,
pNew
->
comment
,
pNew
->
commentLen
+
1
);
pOld
->
commentLen
=
pNew
->
commentLen
;
}
}
if
(
pNew
->
ast1Len
!=
0
)
{
if
(
pNew
->
ast1Len
!=
0
)
{
memcpy
(
pOld
->
pAst1
,
pNew
->
pAst1
,
pNew
->
ast1Len
);
memcpy
(
pOld
->
pAst1
,
pNew
->
pAst1
,
pNew
->
ast1Len
);
pOld
->
ast1Len
=
pNew
->
ast1Len
;
}
}
if
(
pNew
->
ast2Len
!=
0
)
{
if
(
pNew
->
ast2Len
!=
0
)
{
memcpy
(
pOld
->
pAst2
,
pNew
->
pAst2
,
pNew
->
ast2Len
);
memcpy
(
pOld
->
pAst2
,
pNew
->
pAst2
,
pNew
->
ast2Len
);
pOld
->
ast2Len
=
pNew
->
ast2Len
;
}
}
taosWUnLockLatch
(
&
pOld
->
lock
);
taosWUnLockLatch
(
&
pOld
->
lock
);
return
0
;
return
0
;
...
@@ -575,7 +578,10 @@ int32_t mndCheckCreateStbReq(SMCreateStbReq *pCreate) {
...
@@ -575,7 +578,10 @@ int32_t mndCheckCreateStbReq(SMCreateStbReq *pCreate) {
static
int32_t
mndSetCreateStbRedoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SStbObj
*
pStb
)
{
static
int32_t
mndSetCreateStbRedoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SStbObj
*
pStb
)
{
SSdbRaw
*
pRedoRaw
=
mndStbActionEncode
(
pStb
);
SSdbRaw
*
pRedoRaw
=
mndStbActionEncode
(
pStb
);
if
(
pRedoRaw
==
NULL
)
return
-
1
;
if
(
pRedoRaw
==
NULL
)
return
-
1
;
if
(
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
)
!=
0
)
return
-
1
;
if
(
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
)
!=
0
)
{
sdbFreeRaw
(
pRedoRaw
);
return
-
1
;
}
if
(
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_CREATING
)
!=
0
)
return
-
1
;
if
(
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_CREATING
)
!=
0
)
return
-
1
;
return
0
;
return
0
;
...
@@ -584,7 +590,10 @@ static int32_t mndSetCreateStbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *p
...
@@ -584,7 +590,10 @@ static int32_t mndSetCreateStbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *p
static
int32_t
mndSetCreateStbUndoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SStbObj
*
pStb
)
{
static
int32_t
mndSetCreateStbUndoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SStbObj
*
pStb
)
{
SSdbRaw
*
pUndoRaw
=
mndStbActionEncode
(
pStb
);
SSdbRaw
*
pUndoRaw
=
mndStbActionEncode
(
pStb
);
if
(
pUndoRaw
==
NULL
)
return
-
1
;
if
(
pUndoRaw
==
NULL
)
return
-
1
;
if
(
mndTransAppendUndolog
(
pTrans
,
pUndoRaw
)
!=
0
)
return
-
1
;
if
(
mndTransAppendUndolog
(
pTrans
,
pUndoRaw
)
!=
0
)
{
sdbFreeRaw
(
pUndoRaw
);
return
-
1
;
}
if
(
sdbSetRawStatus
(
pUndoRaw
,
SDB_STATUS_DROPPED
)
!=
0
)
return
-
1
;
if
(
sdbSetRawStatus
(
pUndoRaw
,
SDB_STATUS_DROPPED
)
!=
0
)
return
-
1
;
return
0
;
return
0
;
...
@@ -593,7 +602,10 @@ static int32_t mndSetCreateStbUndoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *p
...
@@ -593,7 +602,10 @@ static int32_t mndSetCreateStbUndoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *p
static
int32_t
mndSetCreateStbCommitLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SStbObj
*
pStb
)
{
static
int32_t
mndSetCreateStbCommitLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SStbObj
*
pStb
)
{
SSdbRaw
*
pCommitRaw
=
mndStbActionEncode
(
pStb
);
SSdbRaw
*
pCommitRaw
=
mndStbActionEncode
(
pStb
);
if
(
pCommitRaw
==
NULL
)
return
-
1
;
if
(
pCommitRaw
==
NULL
)
return
-
1
;
if
(
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
return
-
1
;
if
(
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
{
sdbFreeRaw
(
pCommitRaw
);
return
-
1
;
}
if
(
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_READY
)
!=
0
)
return
-
1
;
if
(
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_READY
)
!=
0
)
return
-
1
;
return
0
;
return
0
;
...
@@ -697,6 +709,7 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
...
@@ -697,6 +709,7 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
pDst
->
dbUid
=
pDb
->
uid
;
pDst
->
dbUid
=
pDb
->
uid
;
pDst
->
tagVer
=
1
;
pDst
->
tagVer
=
1
;
pDst
->
colVer
=
1
;
pDst
->
colVer
=
1
;
pDst
->
smaVer
=
1
;
pDst
->
nextColId
=
1
;
pDst
->
nextColId
=
1
;
pDst
->
maxdelay
[
0
]
=
pCreate
->
delay1
;
pDst
->
maxdelay
[
0
]
=
pCreate
->
delay1
;
pDst
->
maxdelay
[
1
]
=
pCreate
->
delay2
;
pDst
->
maxdelay
[
1
]
=
pCreate
->
delay2
;
...
@@ -705,6 +718,7 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
...
@@ -705,6 +718,7 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
pDst
->
ttl
=
pCreate
->
ttl
;
pDst
->
ttl
=
pCreate
->
ttl
;
pDst
->
numOfColumns
=
pCreate
->
numOfColumns
;
pDst
->
numOfColumns
=
pCreate
->
numOfColumns
;
pDst
->
numOfTags
=
pCreate
->
numOfTags
;
pDst
->
numOfTags
=
pCreate
->
numOfTags
;
pDst
->
numOfFuncs
=
pCreate
->
numOfFuncs
;
pDst
->
commentLen
=
pCreate
->
commentLen
;
pDst
->
commentLen
=
pCreate
->
commentLen
;
pDst
->
pFuncs
=
pCreate
->
pFuncs
;
pDst
->
pFuncs
=
pCreate
->
pFuncs
;
pCreate
->
pFuncs
=
NULL
;
pCreate
->
pFuncs
=
NULL
;
...
@@ -715,7 +729,7 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
...
@@ -715,7 +729,7 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
memcpy
(
pDst
->
comment
,
pCreate
->
c
omment
,
pDst
->
commentLen
+
1
);
memcpy
(
pDst
->
comment
,
pCreate
->
pC
omment
,
pDst
->
commentLen
+
1
);
}
}
pDst
->
ast1Len
=
pCreate
->
ast1Len
;
pDst
->
ast1Len
=
pCreate
->
ast1Len
;
...
@@ -770,20 +784,15 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
...
@@ -770,20 +784,15 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
static
int32_t
mndCreateStb
(
SMnode
*
pMnode
,
SRpcMsg
*
pReq
,
SMCreateStbReq
*
pCreate
,
SDbObj
*
pDb
)
{
static
int32_t
mndCreateStb
(
SMnode
*
pMnode
,
SRpcMsg
*
pReq
,
SMCreateStbReq
*
pCreate
,
SDbObj
*
pDb
)
{
SStbObj
stbObj
=
{
0
};
SStbObj
stbObj
=
{
0
};
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_CONFLICT_DB_INSIDE
,
pReq
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_CONFLICT_DB_INSIDE
,
pReq
);
if
(
pTrans
==
NULL
)
goto
_OVER
;
if
(
pTrans
==
NULL
)
goto
_OVER
;
mDebug
(
"trans:%d, used to create stb:%s"
,
pTrans
->
id
,
pCreate
->
name
);
mDebug
(
"trans:%d, used to create stb:%s"
,
pTrans
->
id
,
pCreate
->
name
);
if
(
mndBuildStbFromReq
(
pMnode
,
&
stbObj
,
pCreate
,
pDb
)
!=
0
)
goto
_OVER
;
if
(
mndBuildStbFromReq
(
pMnode
,
&
stbObj
,
pCreate
,
pDb
)
!=
0
)
goto
_OVER
;
if
(
mndAddStbToTrans
(
pMnode
,
pTrans
,
pDb
,
&
stbObj
)
<
0
)
goto
_OVER
;
if
(
mndAddStbToTrans
(
pMnode
,
pTrans
,
pDb
,
&
stbObj
)
<
0
)
goto
_OVER
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
code
=
0
;
code
=
0
;
_OVER:
_OVER:
...
@@ -906,7 +915,8 @@ _OVER:
...
@@ -906,7 +915,8 @@ _OVER:
}
}
static
int32_t
mndCheckAlterStbReq
(
SMAlterStbReq
*
pAlter
)
{
static
int32_t
mndCheckAlterStbReq
(
SMAlterStbReq
*
pAlter
)
{
if
(
pAlter
->
commentLen
>=
0
||
pAlter
->
ttl
!=
0
)
return
0
;
if
(
pAlter
->
commentLen
>=
0
)
return
0
;
if
(
pAlter
->
ttl
!=
0
)
return
0
;
if
(
pAlter
->
numOfFields
<
1
||
pAlter
->
numOfFields
!=
(
int32_t
)
taosArrayGetSize
(
pAlter
->
pFields
))
{
if
(
pAlter
->
numOfFields
<
1
||
pAlter
->
numOfFields
!=
(
int32_t
)
taosArrayGetSize
(
pAlter
->
pFields
))
{
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
...
@@ -969,6 +979,7 @@ static int32_t mndUpdateStbCommentAndTTL(const SStbObj *pOld, SStbObj *pNew, cha
...
@@ -969,6 +979,7 @@ static int32_t mndUpdateStbCommentAndTTL(const SStbObj *pOld, SStbObj *pNew, cha
memcpy
(
pNew
->
comment
,
pComment
,
commentLen
+
1
);
memcpy
(
pNew
->
comment
,
pComment
,
commentLen
+
1
);
}
else
if
(
commentLen
==
0
)
{
}
else
if
(
commentLen
==
0
)
{
pNew
->
commentLen
=
0
;
pNew
->
commentLen
=
0
;
}
else
{
}
}
if
(
ttl
>=
0
)
{
if
(
ttl
>=
0
)
{
...
@@ -1245,7 +1256,10 @@ static int32_t mndAlterStbColumnBytes(SMnode *pMnode, const SStbObj *pOld, SStbO
...
@@ -1245,7 +1256,10 @@ static int32_t mndAlterStbColumnBytes(SMnode *pMnode, const SStbObj *pOld, SStbO
static
int32_t
mndSetAlterStbRedoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SStbObj
*
pStb
)
{
static
int32_t
mndSetAlterStbRedoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SStbObj
*
pStb
)
{
SSdbRaw
*
pRedoRaw
=
mndStbActionEncode
(
pStb
);
SSdbRaw
*
pRedoRaw
=
mndStbActionEncode
(
pStb
);
if
(
pRedoRaw
==
NULL
)
return
-
1
;
if
(
pRedoRaw
==
NULL
)
return
-
1
;
if
(
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
)
!=
0
)
return
-
1
;
if
(
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
)
!=
0
)
{
sdbFreeRaw
(
pRedoRaw
);
return
-
1
;
}
if
(
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_READY
)
!=
0
)
return
-
1
;
if
(
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_READY
)
!=
0
)
return
-
1
;
return
0
;
return
0
;
...
@@ -1254,7 +1268,10 @@ static int32_t mndSetAlterStbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pD
...
@@ -1254,7 +1268,10 @@ static int32_t mndSetAlterStbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pD
static
int32_t
mndSetAlterStbCommitLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SStbObj
*
pStb
)
{
static
int32_t
mndSetAlterStbCommitLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SStbObj
*
pStb
)
{
SSdbRaw
*
pCommitRaw
=
mndStbActionEncode
(
pStb
);
SSdbRaw
*
pCommitRaw
=
mndStbActionEncode
(
pStb
);
if
(
pCommitRaw
==
NULL
)
return
-
1
;
if
(
pCommitRaw
==
NULL
)
return
-
1
;
if
(
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
return
-
1
;
if
(
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
{
sdbFreeRaw
(
pCommitRaw
);
return
-
1
;
}
if
(
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_READY
)
!=
0
)
return
-
1
;
if
(
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_READY
)
!=
0
)
return
-
1
;
return
0
;
return
0
;
...
@@ -1626,7 +1643,10 @@ _OVER:
...
@@ -1626,7 +1643,10 @@ _OVER:
static
int32_t
mndSetDropStbRedoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SStbObj
*
pStb
)
{
static
int32_t
mndSetDropStbRedoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SStbObj
*
pStb
)
{
SSdbRaw
*
pRedoRaw
=
mndStbActionEncode
(
pStb
);
SSdbRaw
*
pRedoRaw
=
mndStbActionEncode
(
pStb
);
if
(
pRedoRaw
==
NULL
)
return
-
1
;
if
(
pRedoRaw
==
NULL
)
return
-
1
;
if
(
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
)
!=
0
)
return
-
1
;
if
(
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
)
!=
0
)
{
sdbFreeRaw
(
pRedoRaw
);
return
-
1
;
}
if
(
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_DROPPING
)
!=
0
)
return
-
1
;
if
(
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_DROPPING
)
!=
0
)
return
-
1
;
return
0
;
return
0
;
...
@@ -1635,7 +1655,10 @@ static int32_t mndSetDropStbRedoLogs(SMnode *pMnode, STrans *pTrans, SStbObj *pS
...
@@ -1635,7 +1655,10 @@ static int32_t mndSetDropStbRedoLogs(SMnode *pMnode, STrans *pTrans, SStbObj *pS
static
int32_t
mndSetDropStbCommitLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SStbObj
*
pStb
)
{
static
int32_t
mndSetDropStbCommitLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SStbObj
*
pStb
)
{
SSdbRaw
*
pCommitRaw
=
mndStbActionEncode
(
pStb
);
SSdbRaw
*
pCommitRaw
=
mndStbActionEncode
(
pStb
);
if
(
pCommitRaw
==
NULL
)
return
-
1
;
if
(
pCommitRaw
==
NULL
)
return
-
1
;
if
(
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
return
-
1
;
if
(
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
{
sdbFreeRaw
(
pCommitRaw
);
return
-
1
;
}
if
(
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_DROPPED
)
!=
0
)
return
-
1
;
if
(
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_DROPPED
)
!=
0
)
return
-
1
;
return
0
;
return
0
;
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
1b3fde4a
...
@@ -784,12 +784,12 @@ static EDealRes translateValueImpl(STranslateContext* pCxt, SValueNode* pVal, SD
...
@@ -784,12 +784,12 @@ static EDealRes translateValueImpl(STranslateContext* pCxt, SValueNode* pVal, SD
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
if
(
TSDB_DATA_TYPE_NULL
==
pVal
->
node
.
resType
.
type
)
{
if
(
TSDB_DATA_TYPE_NULL
==
pVal
->
node
.
resType
.
type
)
{
// TODO
// TODO
//pVal->node.resType = targetDt;
//
pVal->node.resType = targetDt;
pVal
->
translate
=
true
;
pVal
->
translate
=
true
;
pVal
->
isNull
=
true
;
pVal
->
isNull
=
true
;
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
if
(
pVal
->
isDuration
)
{
if
(
pVal
->
isDuration
)
{
if
(
parseNatualDuration
(
pVal
->
literal
,
strlen
(
pVal
->
literal
),
&
pVal
->
datum
.
i
,
&
pVal
->
unit
,
precision
)
!=
if
(
parseNatualDuration
(
pVal
->
literal
,
strlen
(
pVal
->
literal
),
&
pVal
->
datum
.
i
,
&
pVal
->
unit
,
precision
)
!=
TSDB_CODE_SUCCESS
)
{
TSDB_CODE_SUCCESS
)
{
...
@@ -3621,8 +3621,8 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm
...
@@ -3621,8 +3621,8 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm
pReq
->
numOfColumns
=
LIST_LENGTH
(
pStmt
->
pCols
);
pReq
->
numOfColumns
=
LIST_LENGTH
(
pStmt
->
pCols
);
pReq
->
numOfTags
=
LIST_LENGTH
(
pStmt
->
pTags
);
pReq
->
numOfTags
=
LIST_LENGTH
(
pStmt
->
pTags
);
if
(
pStmt
->
pOptions
->
commentNull
==
false
)
{
if
(
pStmt
->
pOptions
->
commentNull
==
false
)
{
pReq
->
c
omment
=
strdup
(
pStmt
->
pOptions
->
comment
);
pReq
->
pC
omment
=
strdup
(
pStmt
->
pOptions
->
comment
);
if
(
NULL
==
pReq
->
c
omment
)
{
if
(
NULL
==
pReq
->
pC
omment
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
pReq
->
commentLen
=
strlen
(
pStmt
->
pOptions
->
comment
);
pReq
->
commentLen
=
strlen
(
pStmt
->
pOptions
->
comment
);
...
@@ -3630,6 +3630,7 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm
...
@@ -3630,6 +3630,7 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm
pReq
->
commentLen
=
-
1
;
pReq
->
commentLen
=
-
1
;
}
}
buildRollupFuncs
(
pStmt
->
pOptions
->
pRollupFuncs
,
&
pReq
->
pFuncs
);
buildRollupFuncs
(
pStmt
->
pOptions
->
pRollupFuncs
,
&
pReq
->
pFuncs
);
pReq
->
numOfFuncs
=
taosArrayGetSize
(
pReq
->
pFuncs
);
SName
tableName
;
SName
tableName
;
tNameExtractFullName
(
toName
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
tableName
),
pReq
->
name
);
tNameExtractFullName
(
toName
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
tableName
),
pReq
->
name
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录