Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9a164f48
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9a164f48
编写于
2月 09, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test cases for stb
上级
18299bf0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
418 addition
and
112 deletion
+418
-112
include/util/taoserror.h
include/util/taoserror.h
+13
-12
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+22
-11
source/dnode/mnode/impl/test/stb/stb.cpp
source/dnode/mnode/impl/test/stb/stb.cpp
+379
-87
source/util/src/terror.c
source/util/src/terror.c
+4
-2
未找到文件。
include/util/taoserror.h
浏览文件 @
9a164f48
...
...
@@ -218,18 +218,19 @@ int32_t* taosGetErrno();
// mnode-stable
#define TSDB_CODE_MND_STB_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A0)
#define TSDB_CODE_MND_STB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A1)
#define TSDB_CODE_MND_TOO_MANY_STBS TAOS_DEF_ERROR_CODE(0, 0x03A2)
#define TSDB_CODE_MND_INVALID_STB TAOS_DEF_ERROR_CODE(0, 0x03A3)
#define TSDB_CODE_MND_INVALID_STB_OPTION TAOS_DEF_ERROR_CODE(0, 0x03A4)
#define TSDB_CODE_MND_STB_OPTION_UNCHNAGED TAOS_DEF_ERROR_CODE(0, 0x03A5)
#define TSDB_CODE_MND_TOO_MANY_TAGS TAOS_DEF_ERROR_CODE(0, 0x03A6)
#define TSDB_CODE_MND_TAG_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A7)
#define TSDB_CODE_MND_TAG_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A8)
#define TSDB_CODE_MND_TOO_MANY_COLUMNS TAOS_DEF_ERROR_CODE(0, 0x03A9)
#define TSDB_CODE_MND_COLUMN_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AA)
#define TSDB_CODE_MND_COLUMN_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AB)
#define TSDB_CODE_MND_INVALID_ROW_BYTES TAOS_DEF_ERROR_CODE(0, 0x03AC)
#define TSDB_CODE_MND_NAME_CONFLICT_WITH_TOPIC TAOS_DEF_ERROR_CODE(0, 0x03AD)
#define TSDB_CODE_MND_NAME_CONFLICT_WITH_TOPIC TAOS_DEF_ERROR_CODE(0, 0x03A2)
#define TSDB_CODE_MND_TOO_MANY_STBS TAOS_DEF_ERROR_CODE(0, 0x03A3)
#define TSDB_CODE_MND_INVALID_STB TAOS_DEF_ERROR_CODE(0, 0x03A4)
#define TSDB_CODE_MND_INVALID_STB_OPTION TAOS_DEF_ERROR_CODE(0, 0x03A5)
#define TSDB_CODE_MND_INVALID_STB_ALTER_OPTION TAOS_DEF_ERROR_CODE(0, 0x03A6)
#define TSDB_CODE_MND_STB_OPTION_UNCHNAGED TAOS_DEF_ERROR_CODE(0, 0x03A7)
#define TSDB_CODE_MND_INVALID_ROW_BYTES TAOS_DEF_ERROR_CODE(0, 0x03A8)
#define TSDB_CODE_MND_TOO_MANY_TAGS TAOS_DEF_ERROR_CODE(0, 0x03A9)
#define TSDB_CODE_MND_TAG_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AA)
#define TSDB_CODE_MND_TAG_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AB)
#define TSDB_CODE_MND_TOO_MANY_COLUMNS TAOS_DEF_ERROR_CODE(0, 0x03AC)
#define TSDB_CODE_MND_COLUMN_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AD)
#define TSDB_CODE_MND_COLUMN_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AE)
// mnode-func
#define TSDB_CODE_MND_FUNC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03C0)
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
9a164f48
...
...
@@ -740,16 +740,17 @@ static int32_t mndAlterStbTagBytes(const SStbObj *pOld, SStbObj *pNew, const SSc
}
SSchema
*
pTag
=
pNew
->
pTags
+
tag
;
if
(
pSchema
->
bytes
<=
pTag
->
bytes
)
{
terrno
=
TSDB_CODE_MND_INVALID_ROW_BYTES
;
return
-
1
;
}
if
(
!
(
pTag
->
type
==
TSDB_DATA_TYPE_BINARY
||
pTag
->
type
==
TSDB_DATA_TYPE_NCHAR
))
{
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
return
-
1
;
}
if
(
pSchema
->
bytes
<=
pTag
->
bytes
)
{
terrno
=
TSDB_CODE_MND_INVALID_ROW_BYTES
;
return
-
1
;
}
pTag
->
bytes
=
pSchema
->
bytes
;
pNew
->
version
++
;
...
...
@@ -765,12 +766,12 @@ static int32_t mndAddSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, const
for
(
int32_t
i
=
0
;
i
<
ncols
;
i
++
)
{
if
(
mndFindSuperTableColumnIndex
(
pOld
,
pSchemas
[
i
].
name
)
>
0
)
{
terrno
=
TSDB_CODE_MND_
TAG
_ALREADY_EXIST
;
terrno
=
TSDB_CODE_MND_
COLUMN
_ALREADY_EXIST
;
return
-
1
;
}
if
(
mndFindSuperTableTagIndex
(
pOld
,
pSchemas
[
i
].
name
)
>
0
)
{
terrno
=
TSDB_CODE_MND_
COLUMN
_ALREADY_EXIST
;
terrno
=
TSDB_CODE_MND_
TAG
_ALREADY_EXIST
;
return
-
1
;
}
}
...
...
@@ -795,11 +796,21 @@ static int32_t mndAddSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, const
static
int32_t
mndDropSuperTableColumn
(
const
SStbObj
*
pOld
,
SStbObj
*
pNew
,
const
char
*
colName
)
{
int32_t
col
=
mndFindSuperTableColumnIndex
(
pOld
,
colName
);
if
(
col
<
=
0
)
{
if
(
col
<
0
)
{
terrno
=
TSDB_CODE_MND_COLUMN_NOT_EXIST
;
return
-
1
;
}
if
(
col
==
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_STB_ALTER_OPTION
;
return
-
1
;
}
if
(
pOld
->
numOfColumns
==
2
)
{
terrno
=
TSDB_CODE_MND_INVALID_STB_ALTER_OPTION
;
return
-
1
;
}
if
(
mndAllocStbSchemas
(
pOld
,
pNew
)
!=
0
)
{
return
-
1
;
}
...
...
@@ -834,13 +845,13 @@ static int32_t mndAlterStbColumnBytes(const SStbObj *pOld, SStbObj *pNew, const
}
SSchema
*
pCol
=
pNew
->
pColumns
+
col
;
if
(
pSchema
->
bytes
<=
pCol
->
bytes
)
{
terrno
=
TSDB_CODE_MND_INVALID_
ROW_BYTES
;
if
(
!
(
pCol
->
type
==
TSDB_DATA_TYPE_BINARY
||
pCol
->
type
==
TSDB_DATA_TYPE_NCHAR
)
)
{
terrno
=
TSDB_CODE_MND_INVALID_
STB_OPTION
;
return
-
1
;
}
if
(
!
(
pCol
->
type
==
TSDB_DATA_TYPE_BINARY
||
pCol
->
type
==
TSDB_DATA_TYPE_NCHAR
)
)
{
terrno
=
TSDB_CODE_MND_INVALID_
STB_OPTION
;
if
(
pSchema
->
bytes
<=
pCol
->
bytes
)
{
terrno
=
TSDB_CODE_MND_INVALID_
ROW_BYTES
;
return
-
1
;
}
...
...
source/dnode/mnode/impl/test/stb/stb.cpp
浏览文件 @
9a164f48
...
...
@@ -23,13 +23,18 @@ class MndTestStb : public ::testing::Test {
void
TearDown
()
override
{}
SCreateDbReq
*
BuildCreateDbReq
(
const
char
*
dbname
,
int32_t
*
pContLen
);
SDropDbReq
*
BuildDropDbReq
(
const
char
*
dbname
,
int32_t
*
pContLen
);
SMCreateStbReq
*
BuildCreateStbReq
(
const
char
*
stbname
,
int32_t
*
pContLen
);
SMAltertbReq
*
BuildAlterStbAddTagReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
*
pContLen
);
SMAltertbReq
*
BuildAlterStbDropTagReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
*
pContLen
);
SMAltertbReq
*
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
);
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
);
};
Testbase
MndTestStb
::
test
;
...
...
@@ -63,6 +68,16 @@ SCreateDbReq* MndTestStb::BuildCreateDbReq(const char* dbname, int32_t* pContLen
return
pReq
;
}
SDropDbReq
*
MndTestStb
::
BuildDropDbReq
(
const
char
*
dbname
,
int32_t
*
pContLen
)
{
int32_t
contLen
=
sizeof
(
SDropDbReq
);
SDropDbReq
*
pReq
=
(
SDropDbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
db
,
dbname
);
*
pContLen
=
contLen
;
return
pReq
;
}
SMCreateStbReq
*
MndTestStb
::
BuildCreateStbReq
(
const
char
*
stbname
,
int32_t
*
pContLen
)
{
int32_t
cols
=
2
;
int32_t
tags
=
3
;
...
...
@@ -82,8 +97,8 @@ SMCreateStbReq* MndTestStb::BuildCreateStbReq(const char* stbname, int32_t* pCon
{
SSchema
*
pSchema
=
&
pReq
->
pSchemas
[
1
];
pSchema
->
bytes
=
htonl
(
4
);
pSchema
->
type
=
TSDB_DATA_TYPE_
INT
;
pSchema
->
bytes
=
htonl
(
12
);
pSchema
->
type
=
TSDB_DATA_TYPE_
BINARY
;
strcpy
(
pSchema
->
name
,
"col1"
);
}
...
...
@@ -112,6 +127,126 @@ SMCreateStbReq* MndTestStb::BuildCreateStbReq(const char* stbname, int32_t* pCon
return
pReq
;
}
SMAltertbReq
*
MndTestStb
::
BuildAlterStbAddTagReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
*
pContLen
)
{
int32_t
contLen
=
sizeof
(
SMAltertbReq
)
+
sizeof
(
SSchema
);
SMAltertbReq
*
pReq
=
(
SMAltertbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
name
,
stbname
);
pReq
->
numOfSchemas
=
htonl
(
1
);
pReq
->
alterType
=
TSDB_ALTER_TABLE_ADD_TAG
;
SSchema
*
pSchema
=
&
pReq
->
pSchemas
[
0
];
pSchema
->
bytes
=
htonl
(
12
);
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
->
name
,
tagname
);
*
pContLen
=
contLen
;
return
pReq
;
}
SMAltertbReq
*
MndTestStb
::
BuildAlterStbDropTagReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
*
pContLen
)
{
int32_t
contLen
=
sizeof
(
SMAltertbReq
)
+
sizeof
(
SSchema
);
SMAltertbReq
*
pReq
=
(
SMAltertbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
name
,
stbname
);
pReq
->
numOfSchemas
=
htonl
(
1
);
pReq
->
alterType
=
TSDB_ALTER_TABLE_DROP_TAG
;
SSchema
*
pSchema
=
&
pReq
->
pSchemas
[
0
];
pSchema
->
bytes
=
htonl
(
12
);
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
->
name
,
tagname
);
*
pContLen
=
contLen
;
return
pReq
;
}
SMAltertbReq
*
MndTestStb
::
BuildAlterStbUpdateTagNameReq
(
const
char
*
stbname
,
const
char
*
tagname
,
const
char
*
newtagname
,
int32_t
*
pContLen
)
{
int32_t
contLen
=
sizeof
(
SMAltertbReq
)
+
2
*
sizeof
(
SSchema
);
SMAltertbReq
*
pReq
=
(
SMAltertbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
name
,
stbname
);
pReq
->
numOfSchemas
=
htonl
(
1
);
pReq
->
alterType
=
TSDB_ALTER_TABLE_UPDATE_TAG_NAME
;
SSchema
*
pSchema
=
&
pReq
->
pSchemas
[
0
];
pSchema
->
bytes
=
htonl
(
12
);
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
->
name
,
tagname
);
pSchema
=
&
pReq
->
pSchemas
[
1
];
pSchema
->
bytes
=
htonl
(
12
);
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
->
name
,
newtagname
);
*
pContLen
=
contLen
;
return
pReq
;
}
SMAltertbReq
*
MndTestStb
::
BuildAlterStbUpdateTagBytesReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
bytes
,
int32_t
*
pContLen
)
{
int32_t
contLen
=
sizeof
(
SMAltertbReq
)
+
sizeof
(
SSchema
);
SMAltertbReq
*
pReq
=
(
SMAltertbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
name
,
stbname
);
pReq
->
numOfSchemas
=
htonl
(
1
);
pReq
->
alterType
=
TSDB_ALTER_TABLE_UPDATE_TAG_BYTES
;
SSchema
*
pSchema
=
&
pReq
->
pSchemas
[
0
];
pSchema
->
bytes
=
htonl
(
bytes
);
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
->
name
,
tagname
);
*
pContLen
=
contLen
;
return
pReq
;
}
SMAltertbReq
*
MndTestStb
::
BuildAlterStbAddColumnReq
(
const
char
*
stbname
,
const
char
*
colname
,
int32_t
*
pContLen
)
{
int32_t
contLen
=
sizeof
(
SMAltertbReq
)
+
sizeof
(
SSchema
);
SMAltertbReq
*
pReq
=
(
SMAltertbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
name
,
stbname
);
pReq
->
numOfSchemas
=
htonl
(
1
);
pReq
->
alterType
=
TSDB_ALTER_TABLE_ADD_COLUMN
;
SSchema
*
pSchema
=
&
pReq
->
pSchemas
[
0
];
pSchema
->
bytes
=
htonl
(
12
);
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
->
name
,
colname
);
*
pContLen
=
contLen
;
return
pReq
;
}
SMAltertbReq
*
MndTestStb
::
BuildAlterStbDropColumnReq
(
const
char
*
stbname
,
const
char
*
colname
,
int32_t
*
pContLen
)
{
int32_t
contLen
=
sizeof
(
SMAltertbReq
)
+
sizeof
(
SSchema
);
SMAltertbReq
*
pReq
=
(
SMAltertbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
name
,
stbname
);
pReq
->
numOfSchemas
=
htonl
(
1
);
pReq
->
alterType
=
TSDB_ALTER_TABLE_DROP_COLUMN
;
SSchema
*
pSchema
=
&
pReq
->
pSchemas
[
0
];
pSchema
->
bytes
=
htonl
(
12
);
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
->
name
,
colname
);
*
pContLen
=
contLen
;
return
pReq
;
}
SMAltertbReq
*
MndTestStb
::
BuildAlterStbUpdateColumnBytesReq
(
const
char
*
stbname
,
const
char
*
colname
,
int32_t
bytes
,
int32_t
*
pContLen
)
{
int32_t
contLen
=
sizeof
(
SMAltertbReq
)
+
sizeof
(
SSchema
);
SMAltertbReq
*
pReq
=
(
SMAltertbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
name
,
stbname
);
pReq
->
numOfSchemas
=
htonl
(
1
);
pReq
->
alterType
=
TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
;
SSchema
*
pSchema
=
&
pReq
->
pSchemas
[
0
];
pSchema
->
bytes
=
htonl
(
bytes
);
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
->
name
,
colname
);
*
pContLen
=
contLen
;
return
pReq
;
}
TEST_F
(
MndTestStb
,
01
_Create_Show_Meta_Drop_Restart_Stb
)
{
const
char
*
dbname
=
"1.d1"
;
const
char
*
stbname
=
"1.d1.stb"
;
...
...
@@ -197,9 +332,9 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
{
SSchema
*
pSchema
=
&
pRsp
->
pSchema
[
1
];
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_
INT
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_
BINARY
);
EXPECT_EQ
(
pSchema
->
colId
,
2
);
EXPECT_EQ
(
pSchema
->
bytes
,
4
);
EXPECT_EQ
(
pSchema
->
bytes
,
12
);
EXPECT_STREQ
(
pSchema
->
name
,
"col1"
);
}
...
...
@@ -254,89 +389,28 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_STB
,
dbname
);
CHECK_META
(
"show stables"
,
4
);
test
.
SendShowRetrieveReq
();
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
}
SMAltertbReq
*
MndTestStb
::
BuildAlterStbAddTagReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
*
pContLen
)
{
int32_t
contLen
=
sizeof
(
SMAltertbReq
)
+
sizeof
(
SSchema
);
SMAltertbReq
*
pReq
=
(
SMAltertbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
name
,
stbname
);
pReq
->
numOfSchemas
=
htonl
(
1
);
pReq
->
alterType
=
TSDB_ALTER_TABLE_ADD_TAG
;
SSchema
*
pSchema
=
&
pReq
->
pSchemas
[
0
];
pSchema
->
bytes
=
htonl
(
12
);
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
->
name
,
tagname
);
*
pContLen
=
contLen
;
return
pReq
;
}
SMAltertbReq
*
MndTestStb
::
BuildAlterStbDropTagReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
*
pContLen
)
{
int32_t
contLen
=
sizeof
(
SMAltertbReq
)
+
sizeof
(
SSchema
);
SMAltertbReq
*
pReq
=
(
SMAltertbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
name
,
stbname
);
pReq
->
numOfSchemas
=
htonl
(
1
);
pReq
->
alterType
=
TSDB_ALTER_TABLE_DROP_TAG
;
SSchema
*
pSchema
=
&
pReq
->
pSchemas
[
0
];
pSchema
->
bytes
=
htonl
(
12
);
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
->
name
,
tagname
);
*
pContLen
=
contLen
;
return
pReq
;
}
SMAltertbReq
*
MndTestStb
::
BuildAlterStbUpdateTagNameReq
(
const
char
*
stbname
,
const
char
*
tagname
,
const
char
*
newtagname
,
int32_t
*
pContLen
)
{
int32_t
contLen
=
sizeof
(
SMAltertbReq
)
+
2
*
sizeof
(
SSchema
);
SMAltertbReq
*
pReq
=
(
SMAltertbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
name
,
stbname
);
pReq
->
numOfSchemas
=
htonl
(
1
);
pReq
->
alterType
=
TSDB_ALTER_TABLE_UPDATE_TAG_NAME
;
SSchema
*
pSchema
=
&
pReq
->
pSchemas
[
0
];
pSchema
->
bytes
=
htonl
(
12
);
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
->
name
,
tagname
);
pSchema
=
&
pReq
->
pSchemas
[
1
];
pSchema
->
bytes
=
htonl
(
12
);
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
->
name
,
newtagname
);
*
pContLen
=
contLen
;
return
pReq
;
}
SMAltertbReq
*
MndTestStb
::
BuildAlterStbUpdateTagBytesReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
bytes
,
int32_t
*
pContLen
)
{
int32_t
contLen
=
sizeof
(
SMAltertbReq
)
+
sizeof
(
SSchema
);
SMAltertbReq
*
pReq
=
(
SMAltertbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
name
,
stbname
);
pReq
->
numOfSchemas
=
htonl
(
1
);
pReq
->
alterType
=
TSDB_ALTER_TABLE_UPDATE_TAG_BYTES
;
SSchema
*
pSchema
=
&
pReq
->
pSchemas
[
0
];
pSchema
->
bytes
=
htonl
(
bytes
);
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
->
name
,
tagname
);
{
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_STB
,
dbname
);
CHECK_META
(
"show stables"
,
4
);
test
.
SendShowRetrieveReq
();
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
}
*
pContLen
=
contLen
;
return
pReq
;
{
int32_t
contLen
=
0
;
SDropDbReq
*
pReq
=
BuildDropDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
}
TEST_F
(
MndTestStb
,
02
_Alter_Stb_AddTag
)
{
const
char
*
dbname
=
"1.d2"
;
const
char
*
stbname
=
"1.d2.stb"
;
int32_t
contLen
=
0
;
{
int32_t
contLen
=
0
;
SCreateDbReq
*
pReq
=
BuildCreateDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
...
@@ -344,15 +418,12 @@ TEST_F(MndTestStb, 02_Alter_Stb_AddTag) {
}
{
int32_t
contLen
=
0
;
SMCreateStbReq
*
pReq
=
BuildCreateStbReq
(
stbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_STB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
int32_t
contLen
=
0
;
{
SMAltertbReq
*
pReq
=
BuildAlterStbAddTagReq
(
"1.d3.stb"
,
"tag4"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
...
...
@@ -391,6 +462,13 @@ TEST_F(MndTestStb, 02_Alter_Stb_AddTag) {
CheckInt32
(
2
);
CheckInt32
(
4
);
}
{
SDropDbReq
*
pReq
=
BuildDropDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
}
TEST_F
(
MndTestStb
,
03
_Alter_Stb_DropTag
)
{
...
...
@@ -430,6 +508,13 @@ TEST_F(MndTestStb, 03_Alter_Stb_DropTag) {
CheckInt32
(
2
);
CheckInt32
(
2
);
}
{
SDropDbReq
*
pReq
=
BuildDropDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
}
TEST_F
(
MndTestStb
,
04
_Alter_Stb_AlterTagName
)
{
...
...
@@ -492,10 +577,16 @@ TEST_F(MndTestStb, 04_Alter_Stb_AlterTagName) {
CheckInt32
(
2
);
CheckInt32
(
3
);
}
}
{
SDropDbReq
*
pReq
=
BuildDropDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
}
TEST_F
(
MndTestStb
,
0
4
_Alter_Stb_AlterTagBytes
)
{
TEST_F
(
MndTestStb
,
0
5
_Alter_Stb_AlterTagBytes
)
{
const
char
*
dbname
=
"1.d5"
;
const
char
*
stbname
=
"1.d5.stb"
;
int32_t
contLen
=
0
;
...
...
@@ -534,7 +625,7 @@ TEST_F(MndTestStb, 04_Alter_Stb_AlterTagBytes) {
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateTagBytesReq
(
stbname
,
"tag3"
,
20
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_STB
,
dbname
);
test
.
SendShowRetrieveReq
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
...
...
@@ -543,4 +634,205 @@ TEST_F(MndTestStb, 04_Alter_Stb_AlterTagBytes) {
CheckInt32
(
2
);
CheckInt32
(
3
);
}
}
\ No newline at end of file
{
SDropDbReq
*
pReq
=
BuildDropDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
}
TEST_F
(
MndTestStb
,
06
_Alter_Stb_AddColumn
)
{
const
char
*
dbname
=
"1.d6"
;
const
char
*
stbname
=
"1.d6.stb"
;
int32_t
contLen
=
0
;
{
SCreateDbReq
*
pReq
=
BuildCreateDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
{
SMCreateStbReq
*
pReq
=
BuildCreateStbReq
(
stbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_STB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbAddColumnReq
(
"1.d7.stb"
,
"tag4"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_DB
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbAddColumnReq
(
"1.d6.stb3"
,
"tag4"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_STB_NOT_EXIST
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbAddColumnReq
(
stbname
,
"tag3"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_TAG_ALREADY_EXIST
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbAddColumnReq
(
stbname
,
"col1"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_COLUMN_ALREADY_EXIST
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbAddColumnReq
(
stbname
,
"col2"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_STB
,
dbname
);
test
.
SendShowRetrieveReq
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckBinary
(
"stb"
,
TSDB_TABLE_NAME_LEN
);
CheckTimestamp
();
CheckInt32
(
3
);
CheckInt32
(
3
);
}
{
SDropDbReq
*
pReq
=
BuildDropDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
}
TEST_F
(
MndTestStb
,
07
_Alter_Stb_DropColumn
)
{
const
char
*
dbname
=
"1.d7"
;
const
char
*
stbname
=
"1.d7.stb"
;
int32_t
contLen
=
0
;
{
SCreateDbReq
*
pReq
=
BuildCreateDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
{
SMCreateStbReq
*
pReq
=
BuildCreateStbReq
(
stbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbDropColumnReq
(
stbname
,
"col4"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_COLUMN_NOT_EXIST
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbDropColumnReq
(
stbname
,
"col1"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_STB_ALTER_OPTION
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbDropColumnReq
(
stbname
,
"ts"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_STB_ALTER_OPTION
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbAddColumnReq
(
stbname
,
"col2"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbDropColumnReq
(
stbname
,
"col1"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_STB
,
dbname
);
test
.
SendShowRetrieveReq
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckBinary
(
"stb"
,
TSDB_TABLE_NAME_LEN
);
CheckTimestamp
();
CheckInt32
(
2
);
CheckInt32
(
3
);
}
{
SDropDbReq
*
pReq
=
BuildDropDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
}
TEST_F
(
MndTestStb
,
08
_Alter_Stb_AlterTagBytes
)
{
const
char
*
dbname
=
"1.d8"
;
const
char
*
stbname
=
"1.d8.stb"
;
int32_t
contLen
=
0
;
{
SCreateDbReq
*
pReq
=
BuildCreateDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
{
SMCreateStbReq
*
pReq
=
BuildCreateStbReq
(
stbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateColumnBytesReq
(
stbname
,
"col5"
,
12
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_COLUMN_NOT_EXIST
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateColumnBytesReq
(
stbname
,
"ts"
,
8
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_STB_OPTION
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateColumnBytesReq
(
stbname
,
"col1"
,
8
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_ROW_BYTES
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateColumnBytesReq
(
stbname
,
"col1"
,
TSDB_MAX_BYTES_PER_ROW
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_ROW_BYTES
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateColumnBytesReq
(
stbname
,
"col1"
,
20
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_STB
,
dbname
);
test
.
SendShowRetrieveReq
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckBinary
(
"stb"
,
TSDB_TABLE_NAME_LEN
);
CheckTimestamp
();
CheckInt32
(
2
);
CheckInt32
(
3
);
}
{
SDropDbReq
*
pReq
=
BuildDropDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
}
source/util/src/terror.c
浏览文件 @
9a164f48
...
...
@@ -228,17 +228,19 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_VGROUP_NOT_EXIST, "VGroup does not exist
// mnode-stable
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_STB_ALREADY_EXIST
,
"Stable already exists"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_STB_NOT_EXIST
,
"Stable not exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_NAME_CONFLICT_WITH_TOPIC
,
"Stable confilct with topic"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TOO_MANY_STBS
,
"Too many stables"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_STB
,
"Invalid stable name"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_STB_OPTION
,
"Invalid stable options"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_STB_OPTION_UNCHNAGED
,
"Stable options not changed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_STB_ALTER_OPTION
,
"Invalid stable alter options"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_STB_OPTION_UNCHNAGED
,
"Stable option unchanged"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_ROW_BYTES
,
"Invalid row bytes"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TOO_MANY_TAGS
,
"Too many tags"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TAG_ALREADY_EXIST
,
"Tag already exists"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TAG_NOT_EXIST
,
"Tag does not exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TOO_MANY_COLUMNS
,
"Too many columns"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_COLUMN_ALREADY_EXIST
,
"Column already exists"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_COLUMN_NOT_EXIST
,
"Column does not exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_ROW_BYTES
,
"Invalid row bytes"
)
// mnode-func
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_FUNC_ALREADY_EXIST
,
"Func already exists"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录