Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
564a91bc
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
未验证
提交
564a91bc
编写于
2月 09, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
2月 09, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10180 from taosdata/feature/mnode
drop stb
上级
2c66ca69
5703d292
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
60 addition
and
28 deletion
+60
-28
include/common/tmsg.h
include/common/tmsg.h
+3
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+16
-0
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+12
-10
source/dnode/mnode/impl/test/stb/stb.cpp
source/dnode/mnode/impl/test/stb/stb.cpp
+7
-4
source/libs/parser/inc/astToMsg.h
source/libs/parser/inc/astToMsg.h
+2
-2
source/libs/parser/src/astToMsg.c
source/libs/parser/src/astToMsg.c
+18
-10
source/libs/parser/src/dCDAstProcess.c
source/libs/parser/src/dCDAstProcess.c
+2
-2
未找到文件。
include/common/tmsg.h
浏览文件 @
564a91bc
...
...
@@ -272,6 +272,9 @@ typedef struct {
int8_t
igNotExists
;
}
SMDropStbReq
;
int32_t
tSerializeSMDropStbReq
(
void
**
buf
,
SMDropStbReq
*
pReq
);
void
*
tDeserializeSMDropStbReq
(
void
*
buf
,
SMDropStbReq
*
pReq
);
typedef
struct
{
char
name
[
TSDB_TABLE_FNAME_LEN
];
int8_t
alterType
;
...
...
source/common/src/tmsg.c
浏览文件 @
564a91bc
...
...
@@ -399,3 +399,19 @@ void *tDeserializeSMCreateStbReq(void *buf, SMCreateStbReq *pReq) {
return
buf
;
}
int32_t
tSerializeSMDropStbReq
(
void
**
buf
,
SMDropStbReq
*
pReq
)
{
int32_t
tlen
=
0
;
tlen
+=
taosEncodeString
(
buf
,
pReq
->
name
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
igNotExists
);
return
tlen
;
}
void
*
tDeserializeSMDropStbReq
(
void
*
buf
,
SMDropStbReq
*
pReq
)
{
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
name
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pReq
->
igNotExists
);
return
buf
;
}
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
564a91bc
...
...
@@ -1119,27 +1119,29 @@ DROP_STB_OVER:
static
int32_t
mndProcessMDropStbReq
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
pMnode
;
SMDropStbReq
*
pDrop
=
pReq
->
rpcMsg
.
pCont
;
mDebug
(
"stb:%s, start to drop"
,
pDrop
->
name
);
SMDropStbReq
dropReq
=
{
0
};
tDeserializeSMDropStbReq
(
pReq
->
rpcMsg
.
pCont
,
&
dropReq
);
SStbObj
*
pStb
=
mndAcquireStb
(
pMnode
,
pDrop
->
name
);
mDebug
(
"stb:%s, start to drop"
,
dropReq
.
name
);
SStbObj
*
pStb
=
mndAcquireStb
(
pMnode
,
dropReq
.
name
);
if
(
pStb
==
NULL
)
{
if
(
pDrop
->
igNotExists
)
{
mDebug
(
"stb:%s, not exist, ignore not exist is set"
,
pDrop
->
name
);
if
(
dropReq
.
igNotExists
)
{
mDebug
(
"stb:%s, not exist, ignore not exist is set"
,
dropReq
.
name
);
return
0
;
}
else
{
terrno
=
TSDB_CODE_MND_STB_NOT_EXIST
;
mError
(
"stb:%s, failed to drop since %s"
,
pDrop
->
name
,
terrstr
());
mError
(
"stb:%s, failed to drop since %s"
,
dropReq
.
name
,
terrstr
());
return
-
1
;
}
}
SDbObj
*
pDb
=
mndAcquireDbByStb
(
pMnode
,
pDrop
->
name
);
SDbObj
*
pDb
=
mndAcquireDbByStb
(
pMnode
,
dropReq
.
name
);
if
(
pDb
==
NULL
)
{
mndReleaseStb
(
pMnode
,
pStb
);
terrno
=
TSDB_CODE_MND_DB_NOT_SELECTED
;
mError
(
"stb:%s, failed to drop since %s"
,
pDrop
->
name
,
terrstr
());
mError
(
"stb:%s, failed to drop since %s"
,
dropReq
.
name
,
terrstr
());
return
-
1
;
}
...
...
@@ -1148,7 +1150,7 @@ static int32_t mndProcessMDropStbReq(SMnodeMsg *pReq) {
mndReleaseStb
(
pMnode
,
pStb
);
if
(
code
!=
0
)
{
mError
(
"stb:%s, failed to drop since %s"
,
pDrop
->
name
,
terrstr
());
mError
(
"stb:%s, failed to drop since %s"
,
dropReq
.
name
,
terrstr
());
return
-
1
;
}
...
...
source/dnode/mnode/impl/test/stb/stb.cpp
浏览文件 @
564a91bc
...
...
@@ -388,12 +388,15 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
}
{
int32_t
contLen
=
sizeof
(
SMDropStbReq
);
SMDropStbReq
dropReq
=
{
0
};
strcpy
(
dropReq
.
name
,
stbname
);
SMDropStbReq
*
pReq
=
(
SMDropStbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
name
,
stbname
);
int32_t
contLen
=
tSerializeSMDropStbReq
(
NULL
,
&
dropReq
);
void
*
pHead
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pHead
;
tSerializeSMDropStbReq
(
&
pBuf
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_STB
,
p
Req
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_STB
,
p
Head
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
...
...
source/libs/parser/inc/astToMsg.h
浏览文件 @
564a91bc
...
...
@@ -10,8 +10,8 @@ SCreateAcctReq* buildAcctManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, in
SDropUserReq
*
buildDropUserMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
);
SShowReq
*
buildShowMsg
(
SShowInfo
*
pShowInfo
,
SParseContext
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
SCreateDbReq
*
buildCreateDbMsg
(
SCreateDbInfo
*
pCreateDbInfo
,
SParseContext
*
pCtx
,
SMsgBuf
*
pMsgBuf
);
SMCreateStbReq
*
buildCreateStbMsg
(
SCreateTableSql
*
pCreateTableSql
,
int32_t
*
len
,
SParseContext
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
SMDropStbReq
*
buildDropStableMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SParseContext
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
char
*
buildCreateStbReq
(
SCreateTableSql
*
pCreateTableSql
,
int32_t
*
len
,
SParseContext
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
char
*
buildDropStableReq
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SParseContext
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
SCreateDnodeReq
*
buildCreateDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
);
SDropDnodeReq
*
buildDropDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
);
...
...
source/libs/parser/src/astToMsg.c
浏览文件 @
564a91bc
...
...
@@ -249,8 +249,7 @@ SCreateDbReq* buildCreateDbMsg(SCreateDbInfo* pCreateDbInfo, SParseContext *pCtx
return
pCreateMsg
;
}
SMCreateStbReq
*
buildCreateStbMsg
(
SCreateTableSql
*
pCreateTableSql
,
int32_t
*
len
,
SParseContext
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
)
{
char
*
buildCreateStbReq
(
SCreateTableSql
*
pCreateTableSql
,
int32_t
*
len
,
SParseContext
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
)
{
SMCreateStbReq
createReq
=
{
0
};
createReq
.
igExists
=
pCreateTableSql
->
existCheck
?
1
:
0
;
createReq
.
pColumns
=
pCreateTableSql
->
colInfo
.
pColumns
;
...
...
@@ -275,13 +274,13 @@ SMCreateStbReq* buildCreateStbMsg(SCreateTableSql* pCreateTableSql, int32_t* len
return
NULL
;
}
void
*
buf
=
req
;
void
*
buf
=
req
;
tSerializeSMCreateStbReq
(
&
buf
,
&
createReq
);
*
len
=
tlen
;
return
req
;
}
SMDropStbReq
*
buildDropStableMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SParseContext
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
)
{
char
*
buildDropStableReq
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SParseContext
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
)
{
SToken
*
tableName
=
taosArrayGet
(
pInfo
->
pMiscInfo
->
a
,
0
);
SName
name
=
{
0
};
...
...
@@ -291,14 +290,23 @@ SMDropStbReq* buildDropStableMsg(SSqlInfo* pInfo, int32_t* len, SParseContext* p
return
NULL
;
}
SMDropStbReq
*
pDropTableMsg
=
(
SMDropStbReq
*
)
calloc
(
1
,
sizeof
(
SMDropStbReq
));
SMDropStbReq
dropReq
=
{
0
};
code
=
tNameExtractFullName
(
&
name
,
dropReq
.
name
);
code
=
tNameExtractFullName
(
&
name
,
pDropTableMsg
->
name
);
assert
(
code
==
TSDB_CODE_SUCCESS
&&
name
.
type
==
TSDB_TABLE_NAME_T
);
dropReq
.
igNotExists
=
pInfo
->
pMiscInfo
->
existsCheck
?
1
:
0
;
pDropTableMsg
->
igNotExists
=
pInfo
->
pMiscInfo
->
existsCheck
?
1
:
0
;
*
len
=
sizeof
(
SMDropStbReq
);
return
pDropTableMsg
;
int32_t
tlen
=
tSerializeSMDropStbReq
(
NULL
,
&
dropReq
);
void
*
req
=
malloc
(
tlen
);
if
(
req
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
void
*
buf
=
req
;
tSerializeSMDropStbReq
(
&
buf
,
&
dropReq
);
*
len
=
tlen
;
return
req
;
}
SCreateDnodeReq
*
buildCreateDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
)
{
...
...
source/libs/parser/src/dCDAstProcess.c
浏览文件 @
564a91bc
...
...
@@ -924,13 +924,13 @@ SDclStmtInfo* qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseContext* pCtx, ch
goto
_error
;
}
pDcl
->
pMsg
=
(
char
*
)
buildCreateStbMsg
(
pCreateTable
,
&
pDcl
->
msgLen
,
pCtx
,
pMsgBuf
);
pDcl
->
pMsg
=
buildCreateStbReq
(
pCreateTable
,
&
pDcl
->
msgLen
,
pCtx
,
pMsgBuf
);
pDcl
->
msgType
=
TDMT_MND_CREATE_STB
;
break
;
}
case
TSDB_SQL_DROP_TABLE
:
{
pDcl
->
pMsg
=
(
char
*
)
buildDropStableMsg
(
pInfo
,
&
pDcl
->
msgLen
,
pCtx
,
pMsgBuf
);
pDcl
->
pMsg
=
buildDropStableReq
(
pInfo
,
&
pDcl
->
msgLen
,
pCtx
,
pMsgBuf
);
if
(
pDcl
->
pMsg
==
NULL
)
{
goto
_error
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录