Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
18299bf0
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
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看板
提交
18299bf0
编写于
2月 09, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test for update stb
上级
17c8f8b1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
65 addition
and
14 deletion
+65
-14
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+10
-10
source/dnode/mnode/impl/test/stb/stb.cpp
source/dnode/mnode/impl/test/stb/stb.cpp
+55
-4
未找到文件。
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
18299bf0
...
...
@@ -735,11 +735,6 @@ static int32_t mndAlterStbTagBytes(const SStbObj *pOld, SStbObj *pNew, const SSc
return
-
1
;
}
if
(
!
(
pSchema
->
type
==
TSDB_DATA_TYPE_BINARY
||
pSchema
->
type
==
TSDB_DATA_TYPE_NCHAR
))
{
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
return
-
1
;
}
if
(
mndAllocStbSchemas
(
pOld
,
pNew
)
!=
0
)
{
return
-
1
;
}
...
...
@@ -750,6 +745,11 @@ static int32_t mndAlterStbTagBytes(const SStbObj *pOld, SStbObj *pNew, const SSc
return
-
1
;
}
if
(
!
(
pTag
->
type
==
TSDB_DATA_TYPE_BINARY
||
pTag
->
type
==
TSDB_DATA_TYPE_NCHAR
))
{
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
return
-
1
;
}
pTag
->
bytes
=
pSchema
->
bytes
;
pNew
->
version
++
;
...
...
@@ -819,11 +819,6 @@ static int32_t mndAlterStbColumnBytes(const SStbObj *pOld, SStbObj *pNew, const
return
-
1
;
}
if
(
!
(
pSchema
->
type
==
TSDB_DATA_TYPE_BINARY
||
pSchema
->
type
==
TSDB_DATA_TYPE_NCHAR
))
{
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
return
-
1
;
}
uint32_t
nLen
=
0
;
for
(
int32_t
i
=
0
;
i
<
pOld
->
numOfColumns
;
++
i
)
{
nLen
+=
(
pOld
->
pColumns
[
i
].
colId
==
col
)
?
pSchema
->
bytes
:
pOld
->
pColumns
[
i
].
bytes
;
...
...
@@ -844,6 +839,11 @@ static int32_t mndAlterStbColumnBytes(const SStbObj *pOld, SStbObj *pNew, const
return
-
1
;
}
if
(
!
(
pCol
->
type
==
TSDB_DATA_TYPE_BINARY
||
pCol
->
type
==
TSDB_DATA_TYPE_NCHAR
))
{
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
return
-
1
;
}
pCol
->
bytes
=
pSchema
->
bytes
;
pNew
->
version
++
;
...
...
source/dnode/mnode/impl/test/stb/stb.cpp
浏览文件 @
18299bf0
...
...
@@ -28,7 +28,7 @@ class MndTestStb : public ::testing::Test {
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
*
BuildAlterStb
D
UpdateTagBytesReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
bytes
,
SMAltertbReq
*
BuildAlterStbUpdateTagBytesReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
bytes
,
int32_t
*
pContLen
);
};
...
...
@@ -314,13 +314,13 @@ SMAltertbReq* MndTestStb::BuildAlterStbUpdateTagNameReq(const char* stbname, con
return
pReq
;
}
SMAltertbReq
*
MndTestStb
::
BuildAlterStb
D
UpdateTagBytesReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
bytes
,
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_
DROP_TAG
;
pReq
->
alterType
=
TSDB_ALTER_TABLE_
UPDATE_TAG_BYTES
;
SSchema
*
pSchema
=
&
pReq
->
pSchemas
[
0
];
pSchema
->
bytes
=
htonl
(
bytes
);
...
...
@@ -432,7 +432,7 @@ TEST_F(MndTestStb, 03_Alter_Stb_DropTag) {
}
}
TEST_F
(
MndTestStb
,
04
_Alter_Stb_A
dd
TagName
)
{
TEST_F
(
MndTestStb
,
04
_Alter_Stb_A
lter
TagName
)
{
const
char
*
dbname
=
"1.d4"
;
const
char
*
stbname
=
"1.d4.stb"
;
int32_t
contLen
=
0
;
...
...
@@ -484,6 +484,57 @@ TEST_F(MndTestStb, 04_Alter_Stb_AddTagName) {
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
);
}
}
TEST_F
(
MndTestStb
,
04
_Alter_Stb_AlterTagBytes
)
{
const
char
*
dbname
=
"1.d5"
;
const
char
*
stbname
=
"1.d5.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
=
BuildAlterStbUpdateTagBytesReq
(
stbname
,
"tag5"
,
12
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_TAG_NOT_EXIST
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateTagBytesReq
(
stbname
,
"tag1"
,
13
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_STB_OPTION
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateTagBytesReq
(
stbname
,
"tag3"
,
8
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_ROW_BYTES
);
}
{
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
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录