Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cf7b4593
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看板
提交
cf7b4593
编写于
5月 16, 2023
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: add drop dnode unsafe command
上级
72c54356
变更
12
展开全部
隐藏空白更改
内联
并排
Showing
12 changed file
with
4865 addition
and
5640 deletion
+4865
-5640
include/common/tmsg.h
include/common/tmsg.h
+1
-0
include/common/ttokendef.h
include/common/ttokendef.h
+282
-280
include/libs/nodes/cmdnodes.h
include/libs/nodes/cmdnodes.h
+1
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+2
-0
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+7
-0
source/libs/parser/inc/parAst.h
source/libs/parser/inc/parAst.h
+1
-1
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+8
-2
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+2
-1
source/libs/parser/src/parTokenizer.c
source/libs/parser/src/parTokenizer.c
+1
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+1
-0
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+4542
-5354
source/libs/parser/test/parInitialDTest.cpp
source/libs/parser/test/parInitialDTest.cpp
+17
-2
未找到文件。
include/common/tmsg.h
浏览文件 @
cf7b4593
...
...
@@ -1629,6 +1629,7 @@ typedef struct {
char
fqdn
[
TSDB_FQDN_LEN
];
int32_t
port
;
int8_t
force
;
int8_t
unsafe
;
}
SDropDnodeReq
;
int32_t
tSerializeSDropDnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SDropDnodeReq
*
pReq
);
...
...
include/common/ttokendef.h
浏览文件 @
cf7b4593
此差异已折叠。
点击以展开。
include/libs/nodes/cmdnodes.h
浏览文件 @
cf7b4593
...
...
@@ -249,6 +249,7 @@ typedef struct SDropDnodeStmt {
char
fqdn
[
TSDB_FQDN_LEN
];
int32_t
port
;
bool
force
;
bool
unsafe
;
}
SDropDnodeStmt
;
typedef
struct
SAlterDnodeStmt
{
...
...
source/common/src/tmsg.c
浏览文件 @
cf7b4593
...
...
@@ -1701,6 +1701,7 @@ int32_t tSerializeSDropDnodeReq(void *buf, int32_t bufLen, SDropDnodeReq *pReq)
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
fqdn
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
port
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
force
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
unsafe
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
...
...
@@ -1717,6 +1718,7 @@ int32_t tDeserializeSDropDnodeReq(void *buf, int32_t bufLen, SDropDnodeReq *pReq
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
fqdn
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
port
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
force
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
unsafe
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
cf7b4593
...
...
@@ -5510,6 +5510,7 @@ static const char* jkDropDnodeStmtDnodeId = "DnodeId";
static
const
char
*
jkDropDnodeStmtFqdn
=
"Fqdn"
;
static
const
char
*
jkDropDnodeStmtPort
=
"Port"
;
static
const
char
*
jkDropDnodeStmtForce
=
"Force"
;
static
const
char
*
jkDropDnodeStmtUnsafe
=
"Unsafe"
;
static
int32_t
dropDnodeStmtToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SDropDnodeStmt
*
pNode
=
(
const
SDropDnodeStmt
*
)
pObj
;
...
...
@@ -5524,6 +5525,9 @@ static int32_t dropDnodeStmtToJson(const void* pObj, SJson* pJson) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddBoolToObject
(
pJson
,
jkDropDnodeStmtForce
,
pNode
->
force
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddBoolToObject
(
pJson
,
jkDropDnodeStmtUnsafe
,
pNode
->
unsafe
);
}
return
code
;
}
...
...
@@ -5541,6 +5545,9 @@ static int32_t jsonToDropDnodeStmt(const SJson* pJson, void* pObj) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetBoolValue
(
pJson
,
jkDropDnodeStmtForce
,
&
pNode
->
force
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetBoolValue
(
pJson
,
jkDropDnodeStmtUnsafe
,
&
pNode
->
unsafe
);
}
return
code
;
}
...
...
source/libs/parser/inc/parAst.h
浏览文件 @
cf7b4593
...
...
@@ -192,7 +192,7 @@ SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const ST
SNode
*
createAlterUserStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pUserName
,
int8_t
alterType
,
const
SToken
*
pVal
);
SNode
*
createDropUserStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pUserName
);
SNode
*
createCreateDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pFqdn
,
const
SToken
*
pPort
);
SNode
*
createDropDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnode
,
bool
force
);
SNode
*
createDropDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnode
,
bool
force
,
bool
unsafe
);
SNode
*
createAlterDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnode
,
const
SToken
*
pConfig
,
const
SToken
*
pValue
);
SNode
*
createRealTableNodeForIndexName
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
,
SToken
*
pIndexName
);
SNode
*
createCreateIndexStmt
(
SAstCreateContext
*
pCxt
,
EIndexType
type
,
bool
ignoreExists
,
SNode
*
pIndexName
,
...
...
source/libs/parser/inc/sql.y
浏览文件 @
cf7b4593
...
...
@@ -126,8 +126,10 @@ with_opt(A) ::= WITH search_condition(B).
/************************************************ create/drop/alter/restore dnode *********************************************/
cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL); }
cmd ::= CREATE DNODE dnode_endpoint(A) PORT NK_INTEGER(B). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, &B); }
cmd ::= DROP DNODE NK_INTEGER(A) force_opt(B). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A, B); }
cmd ::= DROP DNODE dnode_endpoint(A) force_opt(B). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A, B); }
cmd ::= DROP DNODE NK_INTEGER(A) force_opt(B). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A, B, false); }
cmd ::= DROP DNODE dnode_endpoint(A) force_opt(B). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A, B, false); }
cmd ::= DROP DNODE NK_INTEGER(A) unsafe_opt(B). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A, false, B); }
cmd ::= DROP DNODE dnode_endpoint(A) unsafe_opt(B). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A, false, B); }
cmd ::= ALTER DNODE NK_INTEGER(A) NK_STRING(B). { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &A, &B, NULL); }
cmd ::= ALTER DNODE NK_INTEGER(A) NK_STRING(B) NK_STRING(C). { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &A, &B, &C); }
cmd ::= ALTER ALL DNODES NK_STRING(A). { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &A, NULL); }
...
...
@@ -145,6 +147,10 @@ dnode_endpoint(A) ::= NK_IPTOKEN(B).
force_opt(A) ::= . { A = false; }
force_opt(A) ::= FORCE. { A = true; }
%type unsafe_opt { bool }
%destructor unsafe_opt { }
unsafe_opt(A) ::= UNSAFE. { A = true; }
/************************************************ alter local *********************************************************/
cmd ::= ALTER LOCAL NK_STRING(A). { pCxt->pRootNode = createAlterLocalStmt(pCxt, &A, NULL); }
cmd ::= ALTER LOCAL NK_STRING(A) NK_STRING(B). { pCxt->pRootNode = createAlterLocalStmt(pCxt, &A, &B); }
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
cf7b4593
...
...
@@ -1576,7 +1576,7 @@ SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const
return
(
SNode
*
)
pStmt
;
}
SNode
*
createDropDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnode
,
bool
force
)
{
SNode
*
createDropDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnode
,
bool
force
,
bool
unsafe
)
{
CHECK_PARSER_STATUS
(
pCxt
);
SDropDnodeStmt
*
pStmt
=
(
SDropDnodeStmt
*
)
nodesMakeNode
(
QUERY_NODE_DROP_DNODE_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
...
...
@@ -1589,6 +1589,7 @@ SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, bool f
}
}
pStmt
->
force
=
force
;
pStmt
->
unsafe
=
unsafe
;
return
(
SNode
*
)
pStmt
;
}
...
...
source/libs/parser/src/parTokenizer.c
浏览文件 @
cf7b4593
...
...
@@ -241,6 +241,7 @@ static SKeyword keywordTable[] = {
{
"TSERIES"
,
TK_TSERIES
},
{
"TTL"
,
TK_TTL
},
{
"UNION"
,
TK_UNION
},
{
"UNSAFE"
,
TK_UNSAFE
},
{
"UNSIGNED"
,
TK_UNSIGNED
},
{
"UNTREATED"
,
TK_UNTREATED
},
{
"UPDATE"
,
TK_UPDATE
},
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
cf7b4593
...
...
@@ -5517,6 +5517,7 @@ static int32_t translateDropDnode(STranslateContext* pCxt, SDropDnodeStmt* pStmt
strcpy
(
dropReq
.
fqdn
,
pStmt
->
fqdn
);
dropReq
.
port
=
pStmt
->
port
;
dropReq
.
force
=
pStmt
->
force
;
dropReq
.
unsafe
=
pStmt
->
unsafe
;
return
buildCmdMsg
(
pCxt
,
TDMT_MND_DROP_DNODE
,
(
FSerializeFunc
)
tSerializeSDropDnodeReq
,
&
dropReq
);
}
...
...
source/libs/parser/src/sql.c
浏览文件 @
cf7b4593
此差异已折叠。
点击以展开。
source/libs/parser/test/parInitialDTest.cpp
浏览文件 @
cf7b4593
...
...
@@ -94,15 +94,17 @@ TEST_F(ParserInitialDTest, dropDnode) {
auto
clearDropDnodeReq
=
[
&
]()
{
memset
(
&
expect
,
0
,
sizeof
(
SDropDnodeReq
));
};
auto
setDropDnodeReqById
=
[
&
](
int32_t
dnodeId
,
bool
force
=
false
)
{
auto
setDropDnodeReqById
=
[
&
](
int32_t
dnodeId
,
bool
force
=
false
,
bool
unsafe
=
false
)
{
expect
.
dnodeId
=
dnodeId
;
expect
.
force
=
force
;
expect
.
unsafe
=
unsafe
;
};
auto
setDropDnodeReqByEndpoint
=
[
&
](
const
char
*
pFqdn
,
int32_t
port
=
tsServerPort
,
bool
force
=
false
)
{
auto
setDropDnodeReqByEndpoint
=
[
&
](
const
char
*
pFqdn
,
int32_t
port
=
tsServerPort
,
bool
force
=
false
,
bool
unsafe
=
false
)
{
strcpy
(
expect
.
fqdn
,
pFqdn
);
expect
.
port
=
port
;
expect
.
force
=
force
;
expect
.
unsafe
=
unsafe
;
};
setCheckDdlFunc
([
&
](
const
SQuery
*
pQuery
,
ParserStage
stage
)
{
...
...
@@ -114,6 +116,7 @@ TEST_F(ParserInitialDTest, dropDnode) {
ASSERT_EQ
(
std
::
string
(
req
.
fqdn
),
std
::
string
(
expect
.
fqdn
));
ASSERT_EQ
(
req
.
port
,
expect
.
port
);
ASSERT_EQ
(
req
.
force
,
expect
.
force
);
ASSERT_EQ
(
req
.
unsafe
,
expect
.
unsafe
);
});
setDropDnodeReqById
(
1
);
...
...
@@ -124,6 +127,10 @@ TEST_F(ParserInitialDTest, dropDnode) {
run
(
"DROP DNODE 2 FORCE"
);
clearDropDnodeReq
();
setDropDnodeReqById
(
2
,
false
,
true
);
run
(
"DROP DNODE 2 UNSAFE"
);
clearDropDnodeReq
();
setDropDnodeReqByEndpoint
(
"host1"
,
7030
);
run
(
"DROP DNODE 'host1:7030'"
);
clearDropDnodeReq
();
...
...
@@ -132,6 +139,10 @@ TEST_F(ParserInitialDTest, dropDnode) {
run
(
"DROP DNODE 'host2:8030' FORCE"
);
clearDropDnodeReq
();
setDropDnodeReqByEndpoint
(
"host2"
,
8030
,
false
,
true
);
run
(
"DROP DNODE 'host2:8030' UNSAFE"
);
clearDropDnodeReq
();
setDropDnodeReqByEndpoint
(
"host1"
);
run
(
"DROP DNODE host1"
);
clearDropDnodeReq
();
...
...
@@ -139,6 +150,10 @@ TEST_F(ParserInitialDTest, dropDnode) {
setDropDnodeReqByEndpoint
(
"host2"
,
tsServerPort
,
true
);
run
(
"DROP DNODE host2 FORCE"
);
clearDropDnodeReq
();
setDropDnodeReqByEndpoint
(
"host2"
,
tsServerPort
,
false
,
true
);
run
(
"DROP DNODE host2 UNSAFE"
);
clearDropDnodeReq
();
}
// todo DROP function
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录