Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
099f6f9e
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
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看板
未验证
提交
099f6f9e
编写于
2月 10, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
2月 10, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10181 from taosdata/feature/mnode
alter stb
上级
12968ebf
a87d56c5
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
382 addition
and
282 deletion
+382
-282
include/common/tmsg.h
include/common/tmsg.h
+5
-2
source/common/src/tmsg.c
source/common/src/tmsg.c
+42
-0
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+93
-79
source/dnode/mnode/impl/test/stb/stb.cpp
source/dnode/mnode/impl/test/stb/stb.cpp
+242
-201
未找到文件。
include/common/tmsg.h
浏览文件 @
099f6f9e
...
@@ -278,10 +278,13 @@ void* tDeserializeSMDropStbReq(void* buf, SMDropStbReq* pReq);
...
@@ -278,10 +278,13 @@ void* tDeserializeSMDropStbReq(void* buf, SMDropStbReq* pReq);
typedef
struct
{
typedef
struct
{
char
name
[
TSDB_TABLE_FNAME_LEN
];
char
name
[
TSDB_TABLE_FNAME_LEN
];
int8_t
alterType
;
int8_t
alterType
;
int32_t
numOf
Schema
s
;
int32_t
numOf
Field
s
;
S
Schema
pSchemas
[]
;
S
Array
*
pFields
;
}
SMAltertbReq
;
}
SMAltertbReq
;
int32_t
tSerializeSMAlterStbReq
(
void
**
buf
,
SMAltertbReq
*
pReq
);
void
*
tDeserializeSMAlterStbReq
(
void
*
buf
,
SMAltertbReq
*
pReq
);
typedef
struct
{
typedef
struct
{
int32_t
pid
;
int32_t
pid
;
char
app
[
TSDB_APP_NAME_LEN
];
char
app
[
TSDB_APP_NAME_LEN
];
...
...
source/common/src/tmsg.c
浏览文件 @
099f6f9e
...
@@ -415,3 +415,45 @@ void *tDeserializeSMDropStbReq(void *buf, SMDropStbReq *pReq) {
...
@@ -415,3 +415,45 @@ void *tDeserializeSMDropStbReq(void *buf, SMDropStbReq *pReq) {
return
buf
;
return
buf
;
}
}
int32_t
tSerializeSMAlterStbReq
(
void
**
buf
,
SMAltertbReq
*
pReq
)
{
int32_t
tlen
=
0
;
tlen
+=
taosEncodeString
(
buf
,
pReq
->
name
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
alterType
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pReq
->
numOfFields
);
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfFields
;
++
i
)
{
SField
*
pField
=
taosArrayGet
(
pReq
->
pFields
,
i
);
tlen
+=
taosEncodeFixedU8
(
buf
,
pField
->
type
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pField
->
bytes
);
tlen
+=
taosEncodeString
(
buf
,
pField
->
name
);
}
return
tlen
;
}
void
*
tDeserializeSMAlterStbReq
(
void
*
buf
,
SMAltertbReq
*
pReq
)
{
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
name
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pReq
->
alterType
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pReq
->
numOfFields
);
pReq
->
pFields
=
taosArrayInit
(
pReq
->
numOfFields
,
sizeof
(
SField
));
if
(
pReq
->
pFields
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfFields
;
++
i
)
{
SField
field
=
{
0
};
buf
=
taosDecodeFixedU8
(
buf
,
&
field
.
type
);
buf
=
taosDecodeFixedI32
(
buf
,
&
field
.
bytes
);
buf
=
taosDecodeStringTo
(
buf
,
field
.
name
);
if
(
taosArrayPush
(
pReq
->
pFields
,
&
field
)
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
}
return
buf
;
}
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
099f6f9e
...
@@ -601,26 +601,23 @@ static int32_t mndProcessVCreateStbRsp(SMnodeMsg *pRsp) {
...
@@ -601,26 +601,23 @@ static int32_t mndProcessVCreateStbRsp(SMnodeMsg *pRsp) {
}
}
static
int32_t
mndCheckAlterStbReq
(
SMAltertbReq
*
pAlter
)
{
static
int32_t
mndCheckAlterStbReq
(
SMAltertbReq
*
pAlter
)
{
pAlter
->
numOfSchemas
=
htonl
(
pAlter
->
numOfSchemas
);
if
(
pAlter
->
numOfFields
<
1
||
pAlter
->
numOfFields
!=
(
int32_t
)
taosArrayGetSize
(
pAlter
->
pFields
))
{
for
(
int32_t
i
=
0
;
i
<
pAlter
->
numOfSchemas
;
++
i
)
{
SSchema
*
pSchema
=
&
pAlter
->
pSchemas
[
i
];
pSchema
->
colId
=
htonl
(
pSchema
->
colId
);
pSchema
->
bytes
=
htonl
(
pSchema
->
bytes
);
if
(
pSchema
->
type
<=
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
return
-
1
;
return
-
1
;
}
}
if
(
pSchema
->
colId
<
0
||
pSchema
->
colId
>=
(
TSDB_MAX_COLUMNS
+
TSDB_MAX_TAGS
))
{
for
(
int32_t
i
=
0
;
i
<
pAlter
->
numOfFields
;
++
i
)
{
SField
*
pField
=
taosArrayGet
(
pAlter
->
pFields
,
i
);
if
(
pField
->
type
<=
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
return
-
1
;
return
-
1
;
}
}
if
(
p
Schema
->
bytes
<=
0
)
{
if
(
p
Field
->
bytes
<=
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
return
-
1
;
return
-
1
;
}
}
if
(
p
Schema
->
name
[
0
]
==
0
)
{
if
(
p
Field
->
name
[
0
]
==
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
return
-
1
;
return
-
1
;
}
}
...
@@ -662,7 +659,7 @@ static int32_t mndAllocStbSchemas(const SStbObj *pOld, SStbObj *pNew) {
...
@@ -662,7 +659,7 @@ static int32_t mndAllocStbSchemas(const SStbObj *pOld, SStbObj *pNew) {
return
0
;
return
0
;
}
}
static
int32_t
mndAddSuperTableTag
(
const
SStbObj
*
pOld
,
SStbObj
*
pNew
,
const
SSchema
*
pSchema
s
,
int32_t
ntags
)
{
static
int32_t
mndAddSuperTableTag
(
const
SStbObj
*
pOld
,
SStbObj
*
pNew
,
SArray
*
pField
s
,
int32_t
ntags
)
{
if
(
pOld
->
numOfTags
+
ntags
>
TSDB_MAX_TAGS
)
{
if
(
pOld
->
numOfTags
+
ntags
>
TSDB_MAX_TAGS
)
{
terrno
=
TSDB_CODE_MND_TOO_MANY_TAGS
;
terrno
=
TSDB_CODE_MND_TOO_MANY_TAGS
;
return
-
1
;
return
-
1
;
...
@@ -673,33 +670,34 @@ static int32_t mndAddSuperTableTag(const SStbObj *pOld, SStbObj *pNew, const SSc
...
@@ -673,33 +670,34 @@ static int32_t mndAddSuperTableTag(const SStbObj *pOld, SStbObj *pNew, const SSc
return
-
1
;
return
-
1
;
}
}
for
(
int32_t
i
=
0
;
i
<
ntags
;
i
++
)
{
pNew
->
numOfTags
=
pNew
->
numOfTags
+
ntags
;
if
(
mndFindSuperTableColumnIndex
(
pOld
,
pSchemas
[
i
].
name
)
>
0
)
{
if
(
mndAllocStbSchemas
(
pOld
,
pNew
)
!=
0
)
{
terrno
=
TSDB_CODE_MND_COLUMN_ALREADY_EXIST
;
return
-
1
;
return
-
1
;
}
}
if
(
mndFindSuperTableTagIndex
(
pOld
,
pSchemas
[
i
].
name
)
>
0
)
{
for
(
int32_t
i
=
0
;
i
<
ntags
;
i
++
)
{
terrno
=
TSDB_CODE_MND_TAG_ALREADY_EXIST
;
SField
*
pField
=
taosArrayGet
(
pFields
,
i
);
if
(
mndFindSuperTableColumnIndex
(
pOld
,
pField
->
name
)
>
0
)
{
terrno
=
TSDB_CODE_MND_COLUMN_ALREADY_EXIST
;
return
-
1
;
return
-
1
;
}
}
}
pNew
->
numOfTags
=
pNew
->
numOfTags
+
ntags
;
if
(
mndFindSuperTableTagIndex
(
pOld
,
pField
->
name
)
>
0
)
{
if
(
mndAllocStbSchemas
(
pOld
,
pNew
)
!=
0
)
{
terrno
=
TSDB_CODE_MND_TAG_ALREADY_EXIST
;
return
-
1
;
return
-
1
;
}
}
memcpy
(
pNew
->
pTags
+
pOld
->
numOfTags
,
pSchemas
,
sizeof
(
SSchema
)
*
ntags
)
;
SSchema
*
pSchema
=
&
pNew
->
pTags
[
pOld
->
numOfTags
+
i
]
;
pSchema
->
bytes
=
pField
->
bytes
;
for
(
int32_t
i
=
pOld
->
numOfTags
;
i
<
pNew
->
numOfTags
;
i
++
)
{
pSchema
->
type
=
pField
->
type
;
SSchema
*
pSchema
=
&
pNew
->
pTags
[
i
]
;
memcpy
(
pSchema
->
name
,
pField
->
name
,
TSDB_COL_NAME_LEN
)
;
pSchema
->
colId
=
pNew
->
nextColId
;
pSchema
->
colId
=
pNew
->
nextColId
;
pNew
->
nextColId
++
;
pNew
->
nextColId
++
;
mDebug
(
"stb:%s, start to add tag %s"
,
pNew
->
name
,
pSchema
->
name
);
}
}
pNew
->
version
++
;
pNew
->
version
++
;
mDebug
(
"stb:%s, start to add tag %s"
,
pNew
->
name
,
pSchemas
[
0
].
name
);
return
0
;
return
0
;
}
}
...
@@ -722,7 +720,18 @@ static int32_t mndDropSuperTableTag(const SStbObj *pOld, SStbObj *pNew, const ch
...
@@ -722,7 +720,18 @@ static int32_t mndDropSuperTableTag(const SStbObj *pOld, SStbObj *pNew, const ch
return
0
;
return
0
;
}
}
static
int32_t
mndAlterStbTagName
(
const
SStbObj
*
pOld
,
SStbObj
*
pNew
,
const
char
*
oldTagName
,
const
char
*
newTagName
)
{
static
int32_t
mndAlterStbTagName
(
const
SStbObj
*
pOld
,
SStbObj
*
pNew
,
SArray
*
pFields
)
{
if
((
int32_t
)
taosArrayGetSize
(
pFields
)
!=
2
)
{
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
return
-
1
;
}
SField
*
pField0
=
taosArrayGet
(
pFields
,
0
);
SField
*
pField1
=
taosArrayGet
(
pFields
,
1
);
const
char
*
oldTagName
=
pField0
->
name
;
const
char
*
newTagName
=
pField1
->
name
;
int32_t
tag
=
mndFindSuperTableTagIndex
(
pOld
,
oldTagName
);
int32_t
tag
=
mndFindSuperTableTagIndex
(
pOld
,
oldTagName
);
if
(
tag
<
0
)
{
if
(
tag
<
0
)
{
terrno
=
TSDB_CODE_MND_TAG_NOT_EXIST
;
terrno
=
TSDB_CODE_MND_TAG_NOT_EXIST
;
...
@@ -751,8 +760,8 @@ static int32_t mndAlterStbTagName(const SStbObj *pOld, SStbObj *pNew, const char
...
@@ -751,8 +760,8 @@ static int32_t mndAlterStbTagName(const SStbObj *pOld, SStbObj *pNew, const char
return
0
;
return
0
;
}
}
static
int32_t
mndAlterStbTagBytes
(
const
SStbObj
*
pOld
,
SStbObj
*
pNew
,
const
S
Schema
*
pSchema
)
{
static
int32_t
mndAlterStbTagBytes
(
const
SStbObj
*
pOld
,
SStbObj
*
pNew
,
const
S
Field
*
pField
)
{
int32_t
tag
=
mndFindSuperTableTagIndex
(
pOld
,
p
Schema
->
name
);
int32_t
tag
=
mndFindSuperTableTagIndex
(
pOld
,
p
Field
->
name
);
if
(
tag
<
0
)
{
if
(
tag
<
0
)
{
terrno
=
TSDB_CODE_MND_TAG_NOT_EXIST
;
terrno
=
TSDB_CODE_MND_TAG_NOT_EXIST
;
return
-
1
;
return
-
1
;
...
@@ -769,51 +778,52 @@ static int32_t mndAlterStbTagBytes(const SStbObj *pOld, SStbObj *pNew, const SSc
...
@@ -769,51 +778,52 @@ static int32_t mndAlterStbTagBytes(const SStbObj *pOld, SStbObj *pNew, const SSc
return
-
1
;
return
-
1
;
}
}
if
(
p
Schema
->
bytes
<=
pTag
->
bytes
)
{
if
(
p
Field
->
bytes
<=
pTag
->
bytes
)
{
terrno
=
TSDB_CODE_MND_INVALID_ROW_BYTES
;
terrno
=
TSDB_CODE_MND_INVALID_ROW_BYTES
;
return
-
1
;
return
-
1
;
}
}
pTag
->
bytes
=
p
Schema
->
bytes
;
pTag
->
bytes
=
p
Field
->
bytes
;
pNew
->
version
++
;
pNew
->
version
++
;
mDebug
(
"stb:%s, start to modify tag len %s to %d"
,
pNew
->
name
,
p
Schema
->
name
,
pSchema
->
bytes
);
mDebug
(
"stb:%s, start to modify tag len %s to %d"
,
pNew
->
name
,
p
Field
->
name
,
pField
->
bytes
);
return
0
;
return
0
;
}
}
static
int32_t
mndAddSuperTableColumn
(
const
SStbObj
*
pOld
,
SStbObj
*
pNew
,
const
SSchema
*
pSchema
s
,
int32_t
ncols
)
{
static
int32_t
mndAddSuperTableColumn
(
const
SStbObj
*
pOld
,
SStbObj
*
pNew
,
SArray
*
pField
s
,
int32_t
ncols
)
{
if
(
pOld
->
numOfColumns
+
ncols
+
pOld
->
numOfTags
>
TSDB_MAX_COLUMNS
)
{
if
(
pOld
->
numOfColumns
+
ncols
+
pOld
->
numOfTags
>
TSDB_MAX_COLUMNS
)
{
terrno
=
TSDB_CODE_MND_TOO_MANY_COLUMNS
;
terrno
=
TSDB_CODE_MND_TOO_MANY_COLUMNS
;
return
-
1
;
return
-
1
;
}
}
for
(
int32_t
i
=
0
;
i
<
ncols
;
i
++
)
{
pNew
->
numOfColumns
=
pNew
->
numOfColumns
+
ncols
;
if
(
mndFindSuperTableColumnIndex
(
pOld
,
pSchemas
[
i
].
name
)
>
0
)
{
if
(
mndAllocStbSchemas
(
pOld
,
pNew
)
!=
0
)
{
terrno
=
TSDB_CODE_MND_COLUMN_ALREADY_EXIST
;
return
-
1
;
return
-
1
;
}
}
if
(
mndFindSuperTableTagIndex
(
pOld
,
pSchemas
[
i
].
name
)
>
0
)
{
for
(
int32_t
i
=
0
;
i
<
ncols
;
i
++
)
{
terrno
=
TSDB_CODE_MND_TAG_ALREADY_EXIST
;
SField
*
pField
=
taosArrayGet
(
pFields
,
i
);
if
(
mndFindSuperTableColumnIndex
(
pOld
,
pField
->
name
)
>
0
)
{
terrno
=
TSDB_CODE_MND_COLUMN_ALREADY_EXIST
;
return
-
1
;
return
-
1
;
}
}
}
pNew
->
numOfColumns
=
pNew
->
numOfColumns
+
ncols
;
if
(
mndFindSuperTableTagIndex
(
pOld
,
pField
->
name
)
>
0
)
{
if
(
mndAllocStbSchemas
(
pOld
,
pNew
)
!=
0
)
{
terrno
=
TSDB_CODE_MND_TAG_ALREADY_EXIST
;
return
-
1
;
return
-
1
;
}
}
memcpy
(
pNew
->
pColumns
+
pOld
->
numOfColumns
,
pSchemas
,
sizeof
(
SSchema
)
*
ncols
)
;
SSchema
*
pSchema
=
&
pNew
->
pColumns
[
pOld
->
numOfColumns
+
i
]
;
pSchema
->
bytes
=
pField
->
bytes
;
for
(
int32_t
i
=
pOld
->
numOfColumns
;
i
<
pNew
->
numOfColumns
;
i
++
)
{
pSchema
->
type
=
pField
->
type
;
SSchema
*
pSchema
=
&
pNew
->
pColumns
[
i
]
;
memcpy
(
pSchema
->
name
,
pField
->
name
,
TSDB_COL_NAME_LEN
)
;
pSchema
->
colId
=
pNew
->
nextColId
;
pSchema
->
colId
=
pNew
->
nextColId
;
pNew
->
nextColId
++
;
pNew
->
nextColId
++
;
mDebug
(
"stb:%s, start to add column %s"
,
pNew
->
name
,
pSchema
->
name
);
}
}
pNew
->
version
++
;
pNew
->
version
++
;
mDebug
(
"stb:%s, start to add column %s"
,
pNew
->
name
,
pSchemas
[
0
].
name
);
return
0
;
return
0
;
}
}
...
@@ -846,8 +856,8 @@ static int32_t mndDropSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, const
...
@@ -846,8 +856,8 @@ static int32_t mndDropSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, const
return
0
;
return
0
;
}
}
static
int32_t
mndAlterStbColumnBytes
(
const
SStbObj
*
pOld
,
SStbObj
*
pNew
,
const
S
Schema
*
pSchema
)
{
static
int32_t
mndAlterStbColumnBytes
(
const
SStbObj
*
pOld
,
SStbObj
*
pNew
,
const
S
Field
*
pField
)
{
int32_t
col
=
mndFindSuperTableColumnIndex
(
pOld
,
p
Schema
->
name
);
int32_t
col
=
mndFindSuperTableColumnIndex
(
pOld
,
p
Field
->
name
);
if
(
col
<
0
)
{
if
(
col
<
0
)
{
terrno
=
TSDB_CODE_MND_COLUMN_NOT_EXIST
;
terrno
=
TSDB_CODE_MND_COLUMN_NOT_EXIST
;
return
-
1
;
return
-
1
;
...
@@ -855,7 +865,7 @@ static int32_t mndAlterStbColumnBytes(const SStbObj *pOld, SStbObj *pNew, const
...
@@ -855,7 +865,7 @@ static int32_t mndAlterStbColumnBytes(const SStbObj *pOld, SStbObj *pNew, const
uint32_t
nLen
=
0
;
uint32_t
nLen
=
0
;
for
(
int32_t
i
=
0
;
i
<
pOld
->
numOfColumns
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pOld
->
numOfColumns
;
++
i
)
{
nLen
+=
(
pOld
->
pColumns
[
i
].
colId
==
col
)
?
p
Schema
->
bytes
:
pOld
->
pColumns
[
i
].
bytes
;
nLen
+=
(
pOld
->
pColumns
[
i
].
colId
==
col
)
?
p
Field
->
bytes
:
pOld
->
pColumns
[
i
].
bytes
;
}
}
if
(
nLen
>
TSDB_MAX_BYTES_PER_ROW
)
{
if
(
nLen
>
TSDB_MAX_BYTES_PER_ROW
)
{
...
@@ -873,15 +883,15 @@ static int32_t mndAlterStbColumnBytes(const SStbObj *pOld, SStbObj *pNew, const
...
@@ -873,15 +883,15 @@ static int32_t mndAlterStbColumnBytes(const SStbObj *pOld, SStbObj *pNew, const
return
-
1
;
return
-
1
;
}
}
if
(
p
Schema
->
bytes
<=
pCol
->
bytes
)
{
if
(
p
Field
->
bytes
<=
pCol
->
bytes
)
{
terrno
=
TSDB_CODE_MND_INVALID_ROW_BYTES
;
terrno
=
TSDB_CODE_MND_INVALID_ROW_BYTES
;
return
-
1
;
return
-
1
;
}
}
pCol
->
bytes
=
p
Schema
->
bytes
;
pCol
->
bytes
=
p
Field
->
bytes
;
pNew
->
version
++
;
pNew
->
version
++
;
mDebug
(
"stb:%s, start to modify col len %s to %d"
,
pNew
->
name
,
p
Schema
->
name
,
pSchema
->
bytes
);
mDebug
(
"stb:%s, start to modify col len %s to %d"
,
pNew
->
name
,
p
Field
->
name
,
pField
->
bytes
);
return
0
;
return
0
;
}
}
...
@@ -950,28 +960,29 @@ static int32_t mndAlterStb(SMnode *pMnode, SMnodeMsg *pReq, const SMAltertbReq *
...
@@ -950,28 +960,29 @@ static int32_t mndAlterStb(SMnode *pMnode, SMnodeMsg *pReq, const SMAltertbReq *
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
STrans
*
pTrans
=
NULL
;
STrans
*
pTrans
=
NULL
;
SField
*
pField0
=
taosArrayGet
(
pAlter
->
pFields
,
0
);
switch
(
pAlter
->
alterType
)
{
switch
(
pAlter
->
alterType
)
{
case
TSDB_ALTER_TABLE_ADD_TAG
:
case
TSDB_ALTER_TABLE_ADD_TAG
:
code
=
mndAddSuperTableTag
(
pOld
,
&
stbObj
,
pAlter
->
p
Schemas
,
1
);
code
=
mndAddSuperTableTag
(
pOld
,
&
stbObj
,
pAlter
->
p
Fields
,
pAlter
->
numOfFields
);
break
;
break
;
case
TSDB_ALTER_TABLE_DROP_TAG
:
case
TSDB_ALTER_TABLE_DROP_TAG
:
code
=
mndDropSuperTableTag
(
pOld
,
&
stbObj
,
p
Alter
->
pSchemas
[
0
].
name
);
code
=
mndDropSuperTableTag
(
pOld
,
&
stbObj
,
p
Field0
->
name
);
break
;
break
;
case
TSDB_ALTER_TABLE_UPDATE_TAG_NAME
:
case
TSDB_ALTER_TABLE_UPDATE_TAG_NAME
:
code
=
mndAlterStbTagName
(
pOld
,
&
stbObj
,
pAlter
->
p
Schemas
[
0
].
name
,
pAlter
->
pSchemas
[
1
].
name
);
code
=
mndAlterStbTagName
(
pOld
,
&
stbObj
,
pAlter
->
p
Fields
);
break
;
break
;
case
TSDB_ALTER_TABLE_UPDATE_TAG_BYTES
:
case
TSDB_ALTER_TABLE_UPDATE_TAG_BYTES
:
code
=
mndAlterStbTagBytes
(
pOld
,
&
stbObj
,
&
pAlter
->
pSchemas
[
0
]
);
code
=
mndAlterStbTagBytes
(
pOld
,
&
stbObj
,
pField0
);
break
;
break
;
case
TSDB_ALTER_TABLE_ADD_COLUMN
:
case
TSDB_ALTER_TABLE_ADD_COLUMN
:
code
=
mndAddSuperTableColumn
(
pOld
,
&
stbObj
,
pAlter
->
p
Schemas
,
1
);
code
=
mndAddSuperTableColumn
(
pOld
,
&
stbObj
,
pAlter
->
p
Fields
,
pAlter
->
numOfFields
);
break
;
break
;
case
TSDB_ALTER_TABLE_DROP_COLUMN
:
case
TSDB_ALTER_TABLE_DROP_COLUMN
:
code
=
mndDropSuperTableColumn
(
pOld
,
&
stbObj
,
p
Alter
->
pSchemas
[
0
].
name
);
code
=
mndDropSuperTableColumn
(
pOld
,
&
stbObj
,
p
Field0
->
name
);
break
;
break
;
case
TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
:
case
TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
:
code
=
mndAlterStbColumnBytes
(
pOld
,
&
stbObj
,
&
pAlter
->
pSchemas
[
0
]
);
code
=
mndAlterStbColumnBytes
(
pOld
,
&
stbObj
,
pField0
);
break
;
break
;
default:
default:
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
...
@@ -1002,39 +1013,42 @@ ALTER_STB_OVER:
...
@@ -1002,39 +1013,42 @@ ALTER_STB_OVER:
static
int32_t
mndProcessMAlterStbReq
(
SMnodeMsg
*
pReq
)
{
static
int32_t
mndProcessMAlterStbReq
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
pMnode
;
SMnode
*
pMnode
=
pReq
->
pMnode
;
SMAltertbReq
*
pAlter
=
pReq
->
rpcMsg
.
pCont
;
int32_t
code
=
-
1
;
SDbObj
*
pDb
=
NULL
;
SStbObj
*
pStb
=
NULL
;
SMAltertbReq
alterReq
=
{
0
};
mDebug
(
"stb:%s, start to alter"
,
pAlter
->
name
)
;
if
(
tDeserializeSMAlterStbReq
(
pReq
->
rpcMsg
.
pCont
,
&
alterReq
)
==
NULL
)
goto
ALTER_STB_OVER
;
if
(
mndCheckAlterStbReq
(
pAlter
)
!=
0
)
{
mDebug
(
"stb:%s, start to alter"
,
alterReq
.
name
);
mError
(
"stb:%s, failed to alter since %s"
,
pAlter
->
name
,
terrstr
());
if
(
mndCheckAlterStbReq
(
&
alterReq
)
!=
0
)
goto
ALTER_STB_OVER
;
return
-
1
;
}
SDbObj
*
pDb
=
mndAcquireDbByStb
(
pMnode
,
pAlter
->
name
);
pDb
=
mndAcquireDbByStb
(
pMnode
,
alterReq
.
name
);
if
(
pDb
==
NULL
)
{
if
(
pDb
==
NULL
)
{
terrno
=
TSDB_CODE_MND_INVALID_DB
;
terrno
=
TSDB_CODE_MND_INVALID_DB
;
mError
(
"stb:%s, failed to alter since %s"
,
pAlter
->
name
,
terrstr
());
goto
ALTER_STB_OVER
;
return
-
1
;
}
}
SStbObj
*
pStb
=
mndAcquireStb
(
pMnode
,
pAlter
->
name
);
pStb
=
mndAcquireStb
(
pMnode
,
alterReq
.
name
);
if
(
pStb
==
NULL
)
{
if
(
pStb
==
NULL
)
{
mndReleaseDb
(
pMnode
,
pDb
);
terrno
=
TSDB_CODE_MND_STB_NOT_EXIST
;
terrno
=
TSDB_CODE_MND_STB_NOT_EXIST
;
mError
(
"stb:%s, failed to alter since %s"
,
pAlter
->
name
,
terrstr
());
goto
ALTER_STB_OVER
;
return
-
1
;
}
}
int32_t
code
=
mndAlterStb
(
pMnode
,
pReq
,
pAlter
,
pDb
,
pStb
);
code
=
mndAlterStb
(
pMnode
,
pReq
,
&
alterReq
,
pDb
,
pStb
);
mndReleaseStb
(
pMnode
,
pStb
);
ALTER_STB_OVER:
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
mError
(
"stb:%s, failed to alter since %s"
,
pAlter
->
name
,
terrstr
());
mError
(
"stb:%s, failed to alter since %s"
,
alterReq
.
name
,
terrstr
());
return
code
;
}
else
{
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
mndReleaseStb
(
pMnode
,
pStb
);
mndReleaseDb
(
pMnode
,
pDb
);
taosArrayClear
(
alterReq
.
pFields
);
return
code
;
}
}
static
int32_t
mndProcessVAlterStbRsp
(
SMnodeMsg
*
pRsp
)
{
static
int32_t
mndProcessVAlterStbRsp
(
SMnodeMsg
*
pRsp
)
{
...
...
source/dnode/mnode/impl/test/stb/stb.cpp
浏览文件 @
099f6f9e
...
@@ -22,24 +22,22 @@ class MndTestStb : public ::testing::Test {
...
@@ -22,24 +22,22 @@ class MndTestStb : public ::testing::Test {
void
SetUp
()
override
{}
void
SetUp
()
override
{}
void
TearDown
()
override
{}
void
TearDown
()
override
{}
SCreateDbReq
*
BuildCreateDbReq
(
const
char
*
dbname
,
int32_t
*
pContLen
);
void
*
BuildCreateDbReq
(
const
char
*
dbname
,
int32_t
*
pContLen
);
SDropDbReq
*
BuildDropDbReq
(
const
char
*
dbname
,
int32_t
*
pContLen
);
void
*
BuildDropDbReq
(
const
char
*
dbname
,
int32_t
*
pContLen
);
void
*
BuildCreateStbReq
(
const
char
*
stbname
,
int32_t
*
pContLen
);
void
*
BuildCreateStbReq
(
const
char
*
stbname
,
int32_t
*
pContLen
);
SMAltertbReq
*
BuildAlterStbAddTagReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
*
pContLen
);
void
*
BuildAlterStbAddTagReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
*
pContLen
);
SMAltertbReq
*
BuildAlterStbDropTagReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
*
pContLen
);
void
*
BuildAlterStbDropTagReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
*
pContLen
);
SMAltertbReq
*
BuildAlterStbUpdateTagNameReq
(
const
char
*
stbname
,
const
char
*
tagname
,
const
char
*
newtagname
,
void
*
BuildAlterStbUpdateTagNameReq
(
const
char
*
stbname
,
const
char
*
tagname
,
const
char
*
newtagname
,
int32_t
*
pContLen
);
SMAltertbReq
*
BuildAlterStbUpdateTagBytesReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
bytes
,
int32_t
*
pContLen
);
SMAltertbReq
*
BuildAlterStbAddColumnReq
(
const
char
*
stbname
,
const
char
*
colname
,
int32_t
*
pContLen
);
SMAltertbReq
*
BuildAlterStbDropColumnReq
(
const
char
*
stbname
,
const
char
*
colname
,
int32_t
*
pContLen
);
SMAltertbReq
*
BuildAlterStbUpdateColumnBytesReq
(
const
char
*
stbname
,
const
char
*
colname
,
int32_t
bytes
,
int32_t
*
pContLen
);
int32_t
*
pContLen
);
void
*
BuildAlterStbUpdateTagBytesReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
bytes
,
int32_t
*
pContLen
);
void
*
BuildAlterStbAddColumnReq
(
const
char
*
stbname
,
const
char
*
colname
,
int32_t
*
pContLen
);
void
*
BuildAlterStbDropColumnReq
(
const
char
*
stbname
,
const
char
*
colname
,
int32_t
*
pContLen
);
void
*
BuildAlterStbUpdateColumnBytesReq
(
const
char
*
stbname
,
const
char
*
colname
,
int32_t
bytes
,
int32_t
*
pContLen
);
};
};
Testbase
MndTestStb
::
test
;
Testbase
MndTestStb
::
test
;
SCreateDbReq
*
MndTestStb
::
BuildCreateDbReq
(
const
char
*
dbname
,
int32_t
*
pContLen
)
{
void
*
MndTestStb
::
BuildCreateDbReq
(
const
char
*
dbname
,
int32_t
*
pContLen
)
{
int32_t
contLen
=
sizeof
(
SCreateDbReq
);
int32_t
contLen
=
sizeof
(
SCreateDbReq
);
SCreateDbReq
*
pReq
=
(
SCreateDbReq
*
)
rpcMallocCont
(
contLen
);
SCreateDbReq
*
pReq
=
(
SCreateDbReq
*
)
rpcMallocCont
(
contLen
);
...
@@ -68,7 +66,7 @@ SCreateDbReq* MndTestStb::BuildCreateDbReq(const char* dbname, int32_t* pContLen
...
@@ -68,7 +66,7 @@ SCreateDbReq* MndTestStb::BuildCreateDbReq(const char* dbname, int32_t* pContLen
return
pReq
;
return
pReq
;
}
}
SDropDbReq
*
MndTestStb
::
BuildDropDbReq
(
const
char
*
dbname
,
int32_t
*
pContLen
)
{
void
*
MndTestStb
::
BuildDropDbReq
(
const
char
*
dbname
,
int32_t
*
pContLen
)
{
int32_t
contLen
=
sizeof
(
SDropDbReq
);
int32_t
contLen
=
sizeof
(
SDropDbReq
);
SDropDbReq
*
pReq
=
(
SDropDbReq
*
)
rpcMallocCont
(
contLen
);
SDropDbReq
*
pReq
=
(
SDropDbReq
*
)
rpcMallocCont
(
contLen
);
...
@@ -136,124 +134,167 @@ void* MndTestStb::BuildCreateStbReq(const char* stbname, int32_t* pContLen) {
...
@@ -136,124 +134,167 @@ void* MndTestStb::BuildCreateStbReq(const char* stbname, int32_t* pContLen) {
return
pHead
;
return
pHead
;
}
}
SMAltertbReq
*
MndTestStb
::
BuildAlterStbAddTagReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
*
pContLen
)
{
void
*
MndTestStb
::
BuildAlterStbAddTagReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
*
pContLen
)
{
int32_t
contLen
=
sizeof
(
SMAltertbReq
)
+
sizeof
(
SSchema
);
SMAltertbReq
req
=
{
0
};
SMAltertbReq
*
pReq
=
(
SMAltertbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
req
.
name
,
stbname
);
strcpy
(
pReq
->
name
,
stbname
);
req
.
numOfFields
=
1
;
pReq
->
numOfSchemas
=
htonl
(
1
);
req
.
pFields
=
taosArrayInit
(
1
,
sizeof
(
SField
));
pReq
->
alterType
=
TSDB_ALTER_TABLE_ADD_TAG
;
req
.
alterType
=
TSDB_ALTER_TABLE_ADD_TAG
;
SField
field
=
{
0
};
field
.
bytes
=
12
;
field
.
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
field
.
name
,
tagname
);
taosArrayPush
(
req
.
pFields
,
&
field
);
SSchema
*
pSchema
=
&
pReq
->
pSchemas
[
0
]
;
int32_t
contLen
=
tSerializeSMAlterStbReq
(
NULL
,
&
req
)
;
pSchema
->
bytes
=
htonl
(
12
);
void
*
pHead
=
rpcMallocCont
(
contLen
);
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
void
*
pBuf
=
pHead
;
strcpy
(
pSchema
->
name
,
tagname
);
tSerializeSMAlterStbReq
(
&
pBuf
,
&
req
);
*
pContLen
=
contLen
;
*
pContLen
=
contLen
;
return
p
Req
;
return
p
Head
;
}
}
SMAltertbReq
*
MndTestStb
::
BuildAlterStbDropTagReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
*
pContLen
)
{
void
*
MndTestStb
::
BuildAlterStbDropTagReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
*
pContLen
)
{
int32_t
contLen
=
sizeof
(
SMAltertbReq
)
+
sizeof
(
SSchema
)
;
SMAltertbReq
req
=
{
0
}
;
SMAltertbReq
*
pReq
=
(
SMAltertbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
req
.
name
,
stbname
);
strcpy
(
pReq
->
name
,
stbname
)
;
req
.
numOfFields
=
1
;
pReq
->
numOfSchemas
=
htonl
(
1
);
req
.
pFields
=
taosArrayInit
(
1
,
sizeof
(
SField
)
);
pReq
->
alterType
=
TSDB_ALTER_TABLE_DROP_TAG
;
req
.
alterType
=
TSDB_ALTER_TABLE_DROP_TAG
;
SSchema
*
pSchema
=
&
pReq
->
pSchemas
[
0
];
SField
field
=
{
0
};
pSchema
->
bytes
=
htonl
(
12
);
field
.
bytes
=
12
;
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
field
.
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
->
name
,
tagname
);
strcpy
(
field
.
name
,
tagname
);
taosArrayPush
(
req
.
pFields
,
&
field
);
int32_t
contLen
=
tSerializeSMAlterStbReq
(
NULL
,
&
req
);
void
*
pHead
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pHead
;
tSerializeSMAlterStbReq
(
&
pBuf
,
&
req
);
*
pContLen
=
contLen
;
*
pContLen
=
contLen
;
return
p
Req
;
return
p
Head
;
}
}
SMAltertbReq
*
MndTestStb
::
BuildAlterStbUpdateTagNameReq
(
const
char
*
stbname
,
const
char
*
tagname
,
void
*
MndTestStb
::
BuildAlterStbUpdateTagNameReq
(
const
char
*
stbname
,
const
char
*
tagname
,
const
char
*
newtagname
,
const
char
*
newtagname
,
int32_t
*
pContLen
)
{
int32_t
*
pContLen
)
{
int32_t
contLen
=
sizeof
(
SMAltertbReq
)
+
2
*
sizeof
(
SSchema
);
SMAltertbReq
req
=
{
0
};
SMAltertbReq
*
pReq
=
(
SMAltertbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
req
.
name
,
stbname
);
strcpy
(
pReq
->
name
,
stbname
);
req
.
numOfFields
=
2
;
pReq
->
numOfSchemas
=
htonl
(
1
);
req
.
pFields
=
taosArrayInit
(
2
,
sizeof
(
SField
));
pReq
->
alterType
=
TSDB_ALTER_TABLE_UPDATE_TAG_NAME
;
req
.
alterType
=
TSDB_ALTER_TABLE_UPDATE_TAG_NAME
;
SField
field
=
{
0
};
field
.
bytes
=
12
;
field
.
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
field
.
name
,
tagname
);
taosArrayPush
(
req
.
pFields
,
&
field
);
SSchema
*
pSchema
=
&
pReq
->
pSchemas
[
0
];
SField
field2
=
{
0
};
pSchema
->
bytes
=
htonl
(
12
);
field2
.
bytes
=
12
;
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
field2
.
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
->
name
,
tagname
);
strcpy
(
field2
.
name
,
newtagname
);
taosArrayPush
(
req
.
pFields
,
&
field2
);
pSchema
=
&
pReq
->
pSchemas
[
1
]
;
int32_t
contLen
=
tSerializeSMAlterStbReq
(
NULL
,
&
req
)
;
pSchema
->
bytes
=
htonl
(
12
);
void
*
pHead
=
rpcMallocCont
(
contLen
);
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
void
*
pBuf
=
pHead
;
strcpy
(
pSchema
->
name
,
newtagname
);
tSerializeSMAlterStbReq
(
&
pBuf
,
&
req
);
*
pContLen
=
contLen
;
*
pContLen
=
contLen
;
return
p
Req
;
return
p
Head
;
}
}
SMAltertbReq
*
MndTestStb
::
BuildAlterStbUpdateTagBytesReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
bytes
,
void
*
MndTestStb
::
BuildAlterStbUpdateTagBytesReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
bytes
,
int32_t
*
pContLen
)
{
int32_t
*
pContLen
)
{
int32_t
contLen
=
sizeof
(
SMAltertbReq
)
+
sizeof
(
SSchema
)
;
SMAltertbReq
req
=
{
0
}
;
SMAltertbReq
*
pReq
=
(
SMAltertbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
req
.
name
,
stbname
);
strcpy
(
pReq
->
name
,
stbname
)
;
req
.
numOfFields
=
1
;
pReq
->
numOfSchemas
=
htonl
(
1
);
req
.
pFields
=
taosArrayInit
(
1
,
sizeof
(
SField
)
);
pReq
->
alterType
=
TSDB_ALTER_TABLE_UPDATE_TAG_BYTES
;
req
.
alterType
=
TSDB_ALTER_TABLE_UPDATE_TAG_BYTES
;
SSchema
*
pSchema
=
&
pReq
->
pSchemas
[
0
];
SField
field
=
{
0
};
pSchema
->
bytes
=
htonl
(
bytes
);
field
.
bytes
=
bytes
;
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
field
.
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
->
name
,
tagname
);
strcpy
(
field
.
name
,
tagname
);
taosArrayPush
(
req
.
pFields
,
&
field
);
int32_t
contLen
=
tSerializeSMAlterStbReq
(
NULL
,
&
req
);
void
*
pHead
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pHead
;
tSerializeSMAlterStbReq
(
&
pBuf
,
&
req
);
*
pContLen
=
contLen
;
*
pContLen
=
contLen
;
return
p
Req
;
return
p
Head
;
}
}
SMAltertbReq
*
MndTestStb
::
BuildAlterStbAddColumnReq
(
const
char
*
stbname
,
const
char
*
colname
,
int32_t
*
pContLen
)
{
void
*
MndTestStb
::
BuildAlterStbAddColumnReq
(
const
char
*
stbname
,
const
char
*
colname
,
int32_t
*
pContLen
)
{
int32_t
contLen
=
sizeof
(
SMAltertbReq
)
+
sizeof
(
SSchema
);
SMAltertbReq
req
=
{
0
};
SMAltertbReq
*
pReq
=
(
SMAltertbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
req
.
name
,
stbname
);
strcpy
(
pReq
->
name
,
stbname
);
req
.
numOfFields
=
1
;
pReq
->
numOfSchemas
=
htonl
(
1
);
req
.
pFields
=
taosArrayInit
(
1
,
sizeof
(
SField
));
pReq
->
alterType
=
TSDB_ALTER_TABLE_ADD_COLUMN
;
req
.
alterType
=
TSDB_ALTER_TABLE_ADD_COLUMN
;
SField
field
=
{
0
};
field
.
bytes
=
12
;
field
.
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
field
.
name
,
colname
);
taosArrayPush
(
req
.
pFields
,
&
field
);
SSchema
*
pSchema
=
&
pReq
->
pSchemas
[
0
]
;
int32_t
contLen
=
tSerializeSMAlterStbReq
(
NULL
,
&
req
)
;
pSchema
->
bytes
=
htonl
(
12
);
void
*
pHead
=
rpcMallocCont
(
contLen
);
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
void
*
pBuf
=
pHead
;
strcpy
(
pSchema
->
name
,
colname
);
tSerializeSMAlterStbReq
(
&
pBuf
,
&
req
);
*
pContLen
=
contLen
;
*
pContLen
=
contLen
;
return
p
Req
;
return
p
Head
;
}
}
SMAltertbReq
*
MndTestStb
::
BuildAlterStbDropColumnReq
(
const
char
*
stbname
,
const
char
*
colname
,
int32_t
*
pContLen
)
{
void
*
MndTestStb
::
BuildAlterStbDropColumnReq
(
const
char
*
stbname
,
const
char
*
colname
,
int32_t
*
pContLen
)
{
int32_t
contLen
=
sizeof
(
SMAltertbReq
)
+
sizeof
(
SSchema
);
SMAltertbReq
req
=
{
0
};
SMAltertbReq
*
pReq
=
(
SMAltertbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
req
.
name
,
stbname
);
strcpy
(
pReq
->
name
,
stbname
);
req
.
numOfFields
=
1
;
pReq
->
numOfSchemas
=
htonl
(
1
);
req
.
pFields
=
taosArrayInit
(
1
,
sizeof
(
SField
));
pReq
->
alterType
=
TSDB_ALTER_TABLE_DROP_COLUMN
;
req
.
alterType
=
TSDB_ALTER_TABLE_DROP_COLUMN
;
SField
field
=
{
0
};
field
.
bytes
=
12
;
field
.
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
field
.
name
,
colname
);
taosArrayPush
(
req
.
pFields
,
&
field
);
SSchema
*
pSchema
=
&
pReq
->
pSchemas
[
0
]
;
int32_t
contLen
=
tSerializeSMAlterStbReq
(
NULL
,
&
req
)
;
pSchema
->
bytes
=
htonl
(
12
);
void
*
pHead
=
rpcMallocCont
(
contLen
);
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
void
*
pBuf
=
pHead
;
strcpy
(
pSchema
->
name
,
colname
);
tSerializeSMAlterStbReq
(
&
pBuf
,
&
req
);
*
pContLen
=
contLen
;
*
pContLen
=
contLen
;
return
p
Req
;
return
p
Head
;
}
}
SMAltertbReq
*
MndTestStb
::
BuildAlterStbUpdateColumnBytesReq
(
const
char
*
stbname
,
const
char
*
colname
,
int32_t
bytes
,
void
*
MndTestStb
::
BuildAlterStbUpdateColumnBytesReq
(
const
char
*
stbname
,
const
char
*
colname
,
int32_t
bytes
,
int32_t
*
pContLen
)
{
int32_t
*
pContLen
)
{
int32_t
contLen
=
sizeof
(
SMAltertbReq
)
+
sizeof
(
SSchema
)
;
SMAltertbReq
req
=
{
0
}
;
SMAltertbReq
*
pReq
=
(
SMAltertbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
req
.
name
,
stbname
);
strcpy
(
pReq
->
name
,
stbname
)
;
req
.
numOfFields
=
1
;
pReq
->
numOfSchemas
=
htonl
(
1
);
req
.
pFields
=
taosArrayInit
(
1
,
sizeof
(
SField
)
);
pReq
->
alterType
=
TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
;
req
.
alterType
=
TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
;
SSchema
*
pSchema
=
&
pReq
->
pSchemas
[
0
];
SField
field
=
{
0
};
pSchema
->
bytes
=
htonl
(
bytes
);
field
.
bytes
=
bytes
;
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
field
.
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
->
name
,
colname
);
strcpy
(
field
.
name
,
colname
);
taosArrayPush
(
req
.
pFields
,
&
field
);
int32_t
contLen
=
tSerializeSMAlterStbReq
(
NULL
,
&
req
);
void
*
pHead
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pHead
;
tSerializeSMAlterStbReq
(
&
pBuf
,
&
req
);
*
pContLen
=
contLen
;
*
pContLen
=
contLen
;
return
p
Req
;
return
p
Head
;
}
}
TEST_F
(
MndTestStb
,
01
_Create_Show_Meta_Drop_Restart_Stb
)
{
TEST_F
(
MndTestStb
,
01
_Create_Show_Meta_Drop_Restart_Stb
)
{
...
@@ -262,7 +303,7 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
...
@@ -262,7 +303,7 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
{
{
int32_t
contLen
=
0
;
int32_t
contLen
=
0
;
SCreateDbReq
*
pReq
=
BuildCreateDbReq
(
dbname
,
&
contLen
);
void
*
pReq
=
BuildCreateDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
...
@@ -410,7 +451,7 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
...
@@ -410,7 +451,7 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
{
{
int32_t
contLen
=
0
;
int32_t
contLen
=
0
;
SDropDbReq
*
pReq
=
BuildDropDbReq
(
dbname
,
&
contLen
);
void
*
pReq
=
BuildDropDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
...
@@ -423,7 +464,7 @@ TEST_F(MndTestStb, 02_Alter_Stb_AddTag) {
...
@@ -423,7 +464,7 @@ TEST_F(MndTestStb, 02_Alter_Stb_AddTag) {
int32_t
contLen
=
0
;
int32_t
contLen
=
0
;
{
{
SCreateDbReq
*
pReq
=
BuildCreateDbReq
(
dbname
,
&
contLen
);
void
*
pReq
=
BuildCreateDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
...
@@ -437,31 +478,31 @@ TEST_F(MndTestStb, 02_Alter_Stb_AddTag) {
...
@@ -437,31 +478,31 @@ TEST_F(MndTestStb, 02_Alter_Stb_AddTag) {
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbAddTagReq
(
"1.d3.stb"
,
"tag4"
,
&
contLen
);
void
*
pReq
=
BuildAlterStbAddTagReq
(
"1.d3.stb"
,
"tag4"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_DB
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_DB
);
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbAddTagReq
(
"1.d2.stb3"
,
"tag4"
,
&
contLen
);
void
*
pReq
=
BuildAlterStbAddTagReq
(
"1.d2.stb3"
,
"tag4"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_STB_NOT_EXIST
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_STB_NOT_EXIST
);
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbAddTagReq
(
stbname
,
"tag3"
,
&
contLen
);
void
*
pReq
=
BuildAlterStbAddTagReq
(
stbname
,
"tag3"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_TAG_ALREADY_EXIST
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_TAG_ALREADY_EXIST
);
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbAddTagReq
(
stbname
,
"col1"
,
&
contLen
);
void
*
pReq
=
BuildAlterStbAddTagReq
(
stbname
,
"col1"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_COLUMN_ALREADY_EXIST
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_COLUMN_ALREADY_EXIST
);
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbAddTagReq
(
stbname
,
"tag4"
,
&
contLen
);
void
*
pReq
=
BuildAlterStbAddTagReq
(
stbname
,
"tag4"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
...
@@ -476,7 +517,7 @@ TEST_F(MndTestStb, 02_Alter_Stb_AddTag) {
...
@@ -476,7 +517,7 @@ TEST_F(MndTestStb, 02_Alter_Stb_AddTag) {
}
}
{
{
SDropDbReq
*
pReq
=
BuildDropDbReq
(
dbname
,
&
contLen
);
void
*
pReq
=
BuildDropDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
...
@@ -489,7 +530,7 @@ TEST_F(MndTestStb, 03_Alter_Stb_DropTag) {
...
@@ -489,7 +530,7 @@ TEST_F(MndTestStb, 03_Alter_Stb_DropTag) {
int32_t
contLen
=
0
;
int32_t
contLen
=
0
;
{
{
SCreateDbReq
*
pReq
=
BuildCreateDbReq
(
dbname
,
&
contLen
);
void
*
pReq
=
BuildCreateDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
}
...
@@ -501,13 +542,13 @@ TEST_F(MndTestStb, 03_Alter_Stb_DropTag) {
...
@@ -501,13 +542,13 @@ TEST_F(MndTestStb, 03_Alter_Stb_DropTag) {
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbDropTagReq
(
stbname
,
"tag5"
,
&
contLen
);
void
*
pReq
=
BuildAlterStbDropTagReq
(
stbname
,
"tag5"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_TAG_NOT_EXIST
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_TAG_NOT_EXIST
);
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbDropTagReq
(
stbname
,
"tag3"
,
&
contLen
);
void
*
pReq
=
BuildAlterStbDropTagReq
(
stbname
,
"tag3"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
...
@@ -522,7 +563,7 @@ TEST_F(MndTestStb, 03_Alter_Stb_DropTag) {
...
@@ -522,7 +563,7 @@ TEST_F(MndTestStb, 03_Alter_Stb_DropTag) {
}
}
{
{
SDropDbReq
*
pReq
=
BuildDropDbReq
(
dbname
,
&
contLen
);
void
*
pReq
=
BuildDropDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
...
@@ -535,7 +576,7 @@ TEST_F(MndTestStb, 04_Alter_Stb_AlterTagName) {
...
@@ -535,7 +576,7 @@ TEST_F(MndTestStb, 04_Alter_Stb_AlterTagName) {
int32_t
contLen
=
0
;
int32_t
contLen
=
0
;
{
{
SCreateDbReq
*
pReq
=
BuildCreateDbReq
(
dbname
,
&
contLen
);
void
*
pReq
=
BuildCreateDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
}
...
@@ -547,36 +588,36 @@ TEST_F(MndTestStb, 04_Alter_Stb_AlterTagName) {
...
@@ -547,36 +588,36 @@ TEST_F(MndTestStb, 04_Alter_Stb_AlterTagName) {
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateTagNameReq
(
stbname
,
"tag5"
,
"tag6"
,
&
contLen
);
void
*
pReq
=
BuildAlterStbUpdateTagNameReq
(
stbname
,
"tag5"
,
"tag6"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_TAG_NOT_EXIST
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_TAG_NOT_EXIST
);
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateTagNameReq
(
stbname
,
"col1"
,
"tag6"
,
&
contLen
);
void
*
pReq
=
BuildAlterStbUpdateTagNameReq
(
stbname
,
"col1"
,
"tag6"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_TAG_NOT_EXIST
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_TAG_NOT_EXIST
);
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateTagNameReq
(
stbname
,
"tag3"
,
"col1"
,
&
contLen
);
void
*
pReq
=
BuildAlterStbUpdateTagNameReq
(
stbname
,
"tag3"
,
"col1"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_COLUMN_ALREADY_EXIST
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_COLUMN_ALREADY_EXIST
);
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateTagNameReq
(
stbname
,
"tag3"
,
"tag2"
,
&
contLen
);
void
*
pReq
=
BuildAlterStbUpdateTagNameReq
(
stbname
,
"tag3"
,
"tag2"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_TAG_ALREADY_EXIST
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_TAG_ALREADY_EXIST
);
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateTagNameReq
(
stbname
,
"tag3"
,
"tag2"
,
&
contLen
);
void
*
pReq
=
BuildAlterStbUpdateTagNameReq
(
stbname
,
"tag3"
,
"tag2"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_TAG_ALREADY_EXIST
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_TAG_ALREADY_EXIST
);
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateTagNameReq
(
stbname
,
"tag3"
,
"tag4"
,
&
contLen
);
void
*
pReq
=
BuildAlterStbUpdateTagNameReq
(
stbname
,
"tag3"
,
"tag4"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
...
@@ -591,7 +632,7 @@ TEST_F(MndTestStb, 04_Alter_Stb_AlterTagName) {
...
@@ -591,7 +632,7 @@ TEST_F(MndTestStb, 04_Alter_Stb_AlterTagName) {
}
}
{
{
SDropDbReq
*
pReq
=
BuildDropDbReq
(
dbname
,
&
contLen
);
void
*
pReq
=
BuildDropDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
...
@@ -604,7 +645,7 @@ TEST_F(MndTestStb, 05_Alter_Stb_AlterTagBytes) {
...
@@ -604,7 +645,7 @@ TEST_F(MndTestStb, 05_Alter_Stb_AlterTagBytes) {
int32_t
contLen
=
0
;
int32_t
contLen
=
0
;
{
{
SCreateDbReq
*
pReq
=
BuildCreateDbReq
(
dbname
,
&
contLen
);
void
*
pReq
=
BuildCreateDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
}
...
@@ -616,25 +657,25 @@ TEST_F(MndTestStb, 05_Alter_Stb_AlterTagBytes) {
...
@@ -616,25 +657,25 @@ TEST_F(MndTestStb, 05_Alter_Stb_AlterTagBytes) {
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateTagBytesReq
(
stbname
,
"tag5"
,
12
,
&
contLen
);
void
*
pReq
=
BuildAlterStbUpdateTagBytesReq
(
stbname
,
"tag5"
,
12
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_TAG_NOT_EXIST
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_TAG_NOT_EXIST
);
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateTagBytesReq
(
stbname
,
"tag1"
,
13
,
&
contLen
);
void
*
pReq
=
BuildAlterStbUpdateTagBytesReq
(
stbname
,
"tag1"
,
13
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_STB_OPTION
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_STB_OPTION
);
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateTagBytesReq
(
stbname
,
"tag3"
,
8
,
&
contLen
);
void
*
pReq
=
BuildAlterStbUpdateTagBytesReq
(
stbname
,
"tag3"
,
8
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_ROW_BYTES
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_ROW_BYTES
);
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateTagBytesReq
(
stbname
,
"tag3"
,
20
,
&
contLen
);
void
*
pReq
=
BuildAlterStbUpdateTagBytesReq
(
stbname
,
"tag3"
,
20
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
...
@@ -648,7 +689,7 @@ TEST_F(MndTestStb, 05_Alter_Stb_AlterTagBytes) {
...
@@ -648,7 +689,7 @@ TEST_F(MndTestStb, 05_Alter_Stb_AlterTagBytes) {
}
}
{
{
SDropDbReq
*
pReq
=
BuildDropDbReq
(
dbname
,
&
contLen
);
void
*
pReq
=
BuildDropDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
...
@@ -661,7 +702,7 @@ TEST_F(MndTestStb, 06_Alter_Stb_AddColumn) {
...
@@ -661,7 +702,7 @@ TEST_F(MndTestStb, 06_Alter_Stb_AddColumn) {
int32_t
contLen
=
0
;
int32_t
contLen
=
0
;
{
{
SCreateDbReq
*
pReq
=
BuildCreateDbReq
(
dbname
,
&
contLen
);
void
*
pReq
=
BuildCreateDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
...
@@ -675,31 +716,31 @@ TEST_F(MndTestStb, 06_Alter_Stb_AddColumn) {
...
@@ -675,31 +716,31 @@ TEST_F(MndTestStb, 06_Alter_Stb_AddColumn) {
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbAddColumnReq
(
"1.d7.stb"
,
"tag4"
,
&
contLen
);
void
*
pReq
=
BuildAlterStbAddColumnReq
(
"1.d7.stb"
,
"tag4"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_DB
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_DB
);
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbAddColumnReq
(
"1.d6.stb3"
,
"tag4"
,
&
contLen
);
void
*
pReq
=
BuildAlterStbAddColumnReq
(
"1.d6.stb3"
,
"tag4"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_STB_NOT_EXIST
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_STB_NOT_EXIST
);
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbAddColumnReq
(
stbname
,
"tag3"
,
&
contLen
);
void
*
pReq
=
BuildAlterStbAddColumnReq
(
stbname
,
"tag3"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_TAG_ALREADY_EXIST
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_TAG_ALREADY_EXIST
);
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbAddColumnReq
(
stbname
,
"col1"
,
&
contLen
);
void
*
pReq
=
BuildAlterStbAddColumnReq
(
stbname
,
"col1"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_COLUMN_ALREADY_EXIST
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_COLUMN_ALREADY_EXIST
);
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbAddColumnReq
(
stbname
,
"col2"
,
&
contLen
);
void
*
pReq
=
BuildAlterStbAddColumnReq
(
stbname
,
"col2"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
...
@@ -714,7 +755,7 @@ TEST_F(MndTestStb, 06_Alter_Stb_AddColumn) {
...
@@ -714,7 +755,7 @@ TEST_F(MndTestStb, 06_Alter_Stb_AddColumn) {
}
}
{
{
SDropDbReq
*
pReq
=
BuildDropDbReq
(
dbname
,
&
contLen
);
void
*
pReq
=
BuildDropDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
...
@@ -727,7 +768,7 @@ TEST_F(MndTestStb, 07_Alter_Stb_DropColumn) {
...
@@ -727,7 +768,7 @@ TEST_F(MndTestStb, 07_Alter_Stb_DropColumn) {
int32_t
contLen
=
0
;
int32_t
contLen
=
0
;
{
{
SCreateDbReq
*
pReq
=
BuildCreateDbReq
(
dbname
,
&
contLen
);
void
*
pReq
=
BuildCreateDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
}
...
@@ -739,32 +780,32 @@ TEST_F(MndTestStb, 07_Alter_Stb_DropColumn) {
...
@@ -739,32 +780,32 @@ TEST_F(MndTestStb, 07_Alter_Stb_DropColumn) {
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbDropColumnReq
(
stbname
,
"col4"
,
&
contLen
);
void
*
pReq
=
BuildAlterStbDropColumnReq
(
stbname
,
"col4"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_COLUMN_NOT_EXIST
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_COLUMN_NOT_EXIST
);
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbDropColumnReq
(
stbname
,
"col1"
,
&
contLen
);
void
*
pReq
=
BuildAlterStbDropColumnReq
(
stbname
,
"col1"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_STB_ALTER_OPTION
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_STB_ALTER_OPTION
);
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbDropColumnReq
(
stbname
,
"ts"
,
&
contLen
);
void
*
pReq
=
BuildAlterStbDropColumnReq
(
stbname
,
"ts"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_STB_ALTER_OPTION
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_STB_ALTER_OPTION
);
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbAddColumnReq
(
stbname
,
"col2"
,
&
contLen
);
void
*
pReq
=
BuildAlterStbAddColumnReq
(
stbname
,
"col2"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbDropColumnReq
(
stbname
,
"col1"
,
&
contLen
);
void
*
pReq
=
BuildAlterStbDropColumnReq
(
stbname
,
"col1"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
...
@@ -779,7 +820,7 @@ TEST_F(MndTestStb, 07_Alter_Stb_DropColumn) {
...
@@ -779,7 +820,7 @@ TEST_F(MndTestStb, 07_Alter_Stb_DropColumn) {
}
}
{
{
SDropDbReq
*
pReq
=
BuildDropDbReq
(
dbname
,
&
contLen
);
void
*
pReq
=
BuildDropDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
...
@@ -792,7 +833,7 @@ TEST_F(MndTestStb, 08_Alter_Stb_AlterTagBytes) {
...
@@ -792,7 +833,7 @@ TEST_F(MndTestStb, 08_Alter_Stb_AlterTagBytes) {
int32_t
contLen
=
0
;
int32_t
contLen
=
0
;
{
{
SCreateDbReq
*
pReq
=
BuildCreateDbReq
(
dbname
,
&
contLen
);
void
*
pReq
=
BuildCreateDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
}
...
@@ -804,31 +845,31 @@ TEST_F(MndTestStb, 08_Alter_Stb_AlterTagBytes) {
...
@@ -804,31 +845,31 @@ TEST_F(MndTestStb, 08_Alter_Stb_AlterTagBytes) {
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateColumnBytesReq
(
stbname
,
"col5"
,
12
,
&
contLen
);
void
*
pReq
=
BuildAlterStbUpdateColumnBytesReq
(
stbname
,
"col5"
,
12
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_COLUMN_NOT_EXIST
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_COLUMN_NOT_EXIST
);
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateColumnBytesReq
(
stbname
,
"ts"
,
8
,
&
contLen
);
void
*
pReq
=
BuildAlterStbUpdateColumnBytesReq
(
stbname
,
"ts"
,
8
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_STB_OPTION
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_STB_OPTION
);
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateColumnBytesReq
(
stbname
,
"col1"
,
8
,
&
contLen
);
void
*
pReq
=
BuildAlterStbUpdateColumnBytesReq
(
stbname
,
"col1"
,
8
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_ROW_BYTES
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_ROW_BYTES
);
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateColumnBytesReq
(
stbname
,
"col1"
,
TSDB_MAX_BYTES_PER_ROW
,
&
contLen
);
void
*
pReq
=
BuildAlterStbUpdateColumnBytesReq
(
stbname
,
"col1"
,
TSDB_MAX_BYTES_PER_ROW
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_ROW_BYTES
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_ROW_BYTES
);
}
}
{
{
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateColumnBytesReq
(
stbname
,
"col1"
,
20
,
&
contLen
);
void
*
pReq
=
BuildAlterStbUpdateColumnBytesReq
(
stbname
,
"col1"
,
20
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
...
@@ -842,7 +883,7 @@ TEST_F(MndTestStb, 08_Alter_Stb_AlterTagBytes) {
...
@@ -842,7 +883,7 @@ TEST_F(MndTestStb, 08_Alter_Stb_AlterTagBytes) {
}
}
{
{
SDropDbReq
*
pReq
=
BuildDropDbReq
(
dbname
,
&
contLen
);
void
*
pReq
=
BuildDropDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录