Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1e7dd908
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
1e7dd908
编写于
5月 19, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: return success if version in alter request is smaller than the stb
上级
7002f32a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
28 addition
and
8 deletion
+28
-8
include/common/tmsg.h
include/common/tmsg.h
+1
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+2
-0
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+8
-1
source/dnode/mnode/impl/test/stb/stb.cpp
source/dnode/mnode/impl/test/stb/stb.cpp
+17
-7
未找到文件。
include/common/tmsg.h
浏览文件 @
1e7dd908
...
...
@@ -469,6 +469,7 @@ int32_t tDeserializeSMDropStbReq(void* buf, int32_t bufLen, SMDropStbReq* pReq);
typedef
struct
{
char
name
[
TSDB_TABLE_FNAME_LEN
];
int8_t
alterType
;
int32_t
verInBlock
;
int32_t
numOfFields
;
SArray
*
pFields
;
int32_t
ttl
;
...
...
source/common/src/tmsg.c
浏览文件 @
1e7dd908
...
...
@@ -600,6 +600,7 @@ int32_t tSerializeSMAlterStbReq(void *buf, int32_t bufLen, SMAlterStbReq *pReq)
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
alterType
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
verInBlock
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfFields
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfFields
;
++
i
)
{
SField
*
pField
=
taosArrayGet
(
pReq
->
pFields
,
i
);
...
...
@@ -626,6 +627,7 @@ int32_t tDeserializeSMAlterStbReq(void *buf, int32_t bufLen, SMAlterStbReq *pReq
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
alterType
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
verInBlock
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfFields
)
<
0
)
return
-
1
;
pReq
->
pFields
=
taosArrayInit
(
pReq
->
numOfFields
,
sizeof
(
SField
));
if
(
pReq
->
pFields
==
NULL
)
{
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
1e7dd908
...
...
@@ -323,7 +323,7 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
pOld
->
version
=
pNew
->
version
;
pOld
->
tagVer
=
pNew
->
tagVer
;
pOld
->
colVer
=
pNew
->
colVer
;
pOld
->
colVer
=
pNew
->
nextColId
;
pOld
->
nextColId
=
pNew
->
nextColId
;
pOld
->
ttl
=
pNew
->
ttl
;
pOld
->
numOfColumns
=
pNew
->
numOfColumns
;
pOld
->
numOfTags
=
pNew
->
numOfTags
;
...
...
@@ -1317,6 +1317,13 @@ static int32_t mndProcessMAlterStbReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
alterReq
.
verInBlock
>
0
&&
alterReq
.
verInBlock
<=
pStb
->
version
)
{
mDebug
(
"stb:%s, already exist, verInBlock:%d smaller than verInStb:%d, alter success"
,
alterReq
.
name
,
alterReq
.
verInBlock
,
pStb
->
version
);
code
=
0
;
goto
_OVER
;
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
goto
_OVER
;
...
...
source/dnode/mnode/impl/test/stb/stb.cpp
浏览文件 @
1e7dd908
...
...
@@ -32,7 +32,7 @@ class MndTestStb : public ::testing::Test {
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
);
void
*
BuildAlterStbUpdateColumnBytesReq
(
const
char
*
stbname
,
const
char
*
colname
,
int32_t
bytes
,
int32_t
*
pContLen
,
int32_t
verInBlock
);
};
Testbase
MndTestStb
::
test
;
...
...
@@ -271,12 +271,13 @@ void* MndTestStb::BuildAlterStbDropColumnReq(const char* stbname, const char* co
}
void
*
MndTestStb
::
BuildAlterStbUpdateColumnBytesReq
(
const
char
*
stbname
,
const
char
*
colname
,
int32_t
bytes
,
int32_t
*
pContLen
)
{
int32_t
*
pContLen
,
int32_t
verInBlock
)
{
SMAlterStbReq
req
=
{
0
};
strcpy
(
req
.
name
,
stbname
);
req
.
numOfFields
=
1
;
req
.
pFields
=
taosArrayInit
(
1
,
sizeof
(
SField
));
req
.
alterType
=
TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
;
req
.
verInBlock
=
verInBlock
;
SField
field
=
{
0
};
field
.
bytes
=
bytes
;
...
...
@@ -781,31 +782,40 @@ TEST_F(MndTestStb, 08_Alter_Stb_AlterTagBytes) {
}
{
void
*
pReq
=
BuildAlterStbUpdateColumnBytesReq
(
stbname
,
"col5"
,
12
,
&
contLen
);
void
*
pReq
=
BuildAlterStbUpdateColumnBytesReq
(
stbname
,
"col5"
,
12
,
&
contLen
,
0
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_COLUMN_NOT_EXIST
);
}
{
void
*
pReq
=
BuildAlterStbUpdateColumnBytesReq
(
stbname
,
"ts"
,
8
,
&
contLen
);
void
*
pReq
=
BuildAlterStbUpdateColumnBytesReq
(
stbname
,
"ts"
,
8
,
&
contLen
,
0
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_STB_OPTION
);
}
{
void
*
pReq
=
BuildAlterStbUpdateColumnBytesReq
(
stbname
,
"col1"
,
8
,
&
contLen
);
void
*
pReq
=
BuildAlterStbUpdateColumnBytesReq
(
stbname
,
"col1"
,
8
,
&
contLen
,
0
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_ROW_BYTES
);
}
{
void
*
pReq
=
BuildAlterStbUpdateColumnBytesReq
(
stbname
,
"col1"
,
TSDB_MAX_BYTES_PER_ROW
,
&
contLen
);
void
*
pReq
=
BuildAlterStbUpdateColumnBytesReq
(
stbname
,
"col1"
,
TSDB_MAX_BYTES_PER_ROW
,
&
contLen
,
0
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_ROW_BYTES
);
}
{
void
*
pReq
=
BuildAlterStbUpdateColumnBytesReq
(
stbname
,
"col1"
,
20
,
&
contLen
);
void
*
pReq
=
BuildAlterStbUpdateColumnBytesReq
(
stbname
,
"col1"
,
20
,
&
contLen
,
0
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
SendShowReq
(
TSDB_MGMT_TABLE_STB
,
"user_stables"
,
dbname
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
}
{
void
*
pReq
=
BuildAlterStbUpdateColumnBytesReq
(
stbname
,
"col_not_exist"
,
20
,
&
contLen
,
1
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录