Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7f9521b3
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
未验证
提交
7f9521b3
编写于
3月 15, 2022
作者:
X
Xiaoyu Wang
提交者:
GitHub
3月 15, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10763 from taosdata/feature/3.0_wxy
TD-14068 create qnode implement
上级
7b6346c1
4281664e
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
1769 addition
and
1710 deletion
+1769
-1710
include/common/ttokendef.h
include/common/ttokendef.h
+107
-105
include/libs/nodes/cmdnodes.h
include/libs/nodes/cmdnodes.h
+5
-0
include/libs/nodes/nodes.h
include/libs/nodes/nodes.h
+2
-0
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+3
-0
source/libs/parser/inc/parAst.h
source/libs/parser/inc/parAst.h
+1
-0
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+4
-0
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+7
-0
source/libs/parser/src/parTokenizer.c
source/libs/parser/src/parTokenizer.c
+2
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+26
-1
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+1605
-1604
source/libs/parser/test/parserAstTest.cpp
source/libs/parser/test/parserAstTest.cpp
+7
-0
未找到文件。
include/common/ttokendef.h
浏览文件 @
7f9521b3
...
...
@@ -48,111 +48,113 @@
#define TK_DNODES 30
#define TK_NK_ID 31
#define TK_NK_IPTOKEN 32
#define TK_DATABASE 33
#define TK_DATABASES 34
#define TK_USE 35
#define TK_IF 36
#define TK_NOT 37
#define TK_EXISTS 38
#define TK_BLOCKS 39
#define TK_CACHE 40
#define TK_CACHELAST 41
#define TK_COMP 42
#define TK_DAYS 43
#define TK_FSYNC 44
#define TK_MAXROWS 45
#define TK_MINROWS 46
#define TK_KEEP 47
#define TK_PRECISION 48
#define TK_QUORUM 49
#define TK_REPLICA 50
#define TK_TTL 51
#define TK_WAL 52
#define TK_VGROUPS 53
#define TK_SINGLE_STABLE 54
#define TK_STREAM_MODE 55
#define TK_TABLE 56
#define TK_NK_LP 57
#define TK_NK_RP 58
#define TK_STABLE 59
#define TK_TABLES 60
#define TK_STABLES 61
#define TK_USING 62
#define TK_TAGS 63
#define TK_NK_DOT 64
#define TK_NK_COMMA 65
#define TK_COMMENT 66
#define TK_BOOL 67
#define TK_TINYINT 68
#define TK_SMALLINT 69
#define TK_INT 70
#define TK_INTEGER 71
#define TK_BIGINT 72
#define TK_FLOAT 73
#define TK_DOUBLE 74
#define TK_BINARY 75
#define TK_TIMESTAMP 76
#define TK_NCHAR 77
#define TK_UNSIGNED 78
#define TK_JSON 79
#define TK_VARCHAR 80
#define TK_MEDIUMBLOB 81
#define TK_BLOB 82
#define TK_VARBINARY 83
#define TK_DECIMAL 84
#define TK_SMA 85
#define TK_INDEX 86
#define TK_ON 87
#define TK_FULLTEXT 88
#define TK_FUNCTION 89
#define TK_INTERVAL 90
#define TK_MNODES 91
#define TK_NK_FLOAT 92
#define TK_NK_BOOL 93
#define TK_NK_VARIABLE 94
#define TK_BETWEEN 95
#define TK_IS 96
#define TK_NULL 97
#define TK_NK_LT 98
#define TK_NK_GT 99
#define TK_NK_LE 100
#define TK_NK_GE 101
#define TK_NK_NE 102
#define TK_NK_EQ 103
#define TK_LIKE 104
#define TK_MATCH 105
#define TK_NMATCH 106
#define TK_IN 107
#define TK_FROM 108
#define TK_AS 109
#define TK_JOIN 110
#define TK_INNER 111
#define TK_SELECT 112
#define TK_DISTINCT 113
#define TK_WHERE 114
#define TK_PARTITION 115
#define TK_BY 116
#define TK_SESSION 117
#define TK_STATE_WINDOW 118
#define TK_SLIDING 119
#define TK_FILL 120
#define TK_VALUE 121
#define TK_NONE 122
#define TK_PREV 123
#define TK_LINEAR 124
#define TK_NEXT 125
#define TK_GROUP 126
#define TK_HAVING 127
#define TK_ORDER 128
#define TK_SLIMIT 129
#define TK_SOFFSET 130
#define TK_LIMIT 131
#define TK_OFFSET 132
#define TK_ASC 133
#define TK_DESC 134
#define TK_NULLS 135
#define TK_FIRST 136
#define TK_LAST 137
#define TK_QNODE 33
#define TK_ON 34
#define TK_QNODES 35
#define TK_DATABASE 36
#define TK_DATABASES 37
#define TK_USE 38
#define TK_IF 39
#define TK_NOT 40
#define TK_EXISTS 41
#define TK_BLOCKS 42
#define TK_CACHE 43
#define TK_CACHELAST 44
#define TK_COMP 45
#define TK_DAYS 46
#define TK_FSYNC 47
#define TK_MAXROWS 48
#define TK_MINROWS 49
#define TK_KEEP 50
#define TK_PRECISION 51
#define TK_QUORUM 52
#define TK_REPLICA 53
#define TK_TTL 54
#define TK_WAL 55
#define TK_VGROUPS 56
#define TK_SINGLE_STABLE 57
#define TK_STREAM_MODE 58
#define TK_TABLE 59
#define TK_NK_LP 60
#define TK_NK_RP 61
#define TK_STABLE 62
#define TK_TABLES 63
#define TK_STABLES 64
#define TK_USING 65
#define TK_TAGS 66
#define TK_NK_DOT 67
#define TK_NK_COMMA 68
#define TK_COMMENT 69
#define TK_BOOL 70
#define TK_TINYINT 71
#define TK_SMALLINT 72
#define TK_INT 73
#define TK_INTEGER 74
#define TK_BIGINT 75
#define TK_FLOAT 76
#define TK_DOUBLE 77
#define TK_BINARY 78
#define TK_TIMESTAMP 79
#define TK_NCHAR 80
#define TK_UNSIGNED 81
#define TK_JSON 82
#define TK_VARCHAR 83
#define TK_MEDIUMBLOB 84
#define TK_BLOB 85
#define TK_VARBINARY 86
#define TK_DECIMAL 87
#define TK_SMA 88
#define TK_INDEX 89
#define TK_FULLTEXT 90
#define TK_FUNCTION 91
#define TK_INTERVAL 92
#define TK_MNODES 93
#define TK_NK_FLOAT 94
#define TK_NK_BOOL 95
#define TK_NK_VARIABLE 96
#define TK_BETWEEN 97
#define TK_IS 98
#define TK_NULL 99
#define TK_NK_LT 100
#define TK_NK_GT 101
#define TK_NK_LE 102
#define TK_NK_GE 103
#define TK_NK_NE 104
#define TK_NK_EQ 105
#define TK_LIKE 106
#define TK_MATCH 107
#define TK_NMATCH 108
#define TK_IN 109
#define TK_FROM 110
#define TK_AS 111
#define TK_JOIN 112
#define TK_INNER 113
#define TK_SELECT 114
#define TK_DISTINCT 115
#define TK_WHERE 116
#define TK_PARTITION 117
#define TK_BY 118
#define TK_SESSION 119
#define TK_STATE_WINDOW 120
#define TK_SLIDING 121
#define TK_FILL 122
#define TK_VALUE 123
#define TK_NONE 124
#define TK_PREV 125
#define TK_LINEAR 126
#define TK_NEXT 127
#define TK_GROUP 128
#define TK_HAVING 129
#define TK_ORDER 130
#define TK_SLIMIT 131
#define TK_SOFFSET 132
#define TK_LIMIT 133
#define TK_OFFSET 134
#define TK_ASC 135
#define TK_DESC 136
#define TK_NULLS 137
#define TK_FIRST 138
#define TK_LAST 139
#define TK_NK_SPACE 300
#define TK_NK_COMMENT 301
...
...
include/libs/nodes/cmdnodes.h
浏览文件 @
7f9521b3
...
...
@@ -179,6 +179,11 @@ typedef struct SCreateIndexStmt {
SIndexOptions
*
pOptions
;
}
SCreateIndexStmt
;
typedef
struct
SCreateQnodeStmt
{
ENodeType
type
;
int32_t
dnodeId
;
}
SCreateQnodeStmt
;
#ifdef __cplusplus
}
#endif
...
...
include/libs/nodes/nodes.h
浏览文件 @
7f9521b3
...
...
@@ -96,7 +96,9 @@ typedef enum ENodeType {
QUERY_NODE_SHOW_DNODES_STMT
,
QUERY_NODE_SHOW_VGROUPS_STMT
,
QUERY_NODE_SHOW_MNODES_STMT
,
QUERY_NODE_SHOW_QNODES_STMT
,
QUERY_NODE_CREATE_INDEX_STMT
,
QUERY_NODE_CREATE_QNODE_STMT
,
// logic plan node
QUERY_NODE_LOGIC_PLAN_SCAN
,
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
7f9521b3
...
...
@@ -127,9 +127,12 @@ SNodeptr nodesMakeNode(ENodeType type) {
return
makeNode
(
type
,
sizeof
(
SShowStmt
));
case
QUERY_NODE_SHOW_VGROUPS_STMT
:
case
QUERY_NODE_SHOW_MNODES_STMT
:
case
QUERY_NODE_SHOW_QNODES_STMT
:
return
makeNode
(
type
,
sizeof
(
SShowStmt
));
case
QUERY_NODE_CREATE_INDEX_STMT
:
return
makeNode
(
type
,
sizeof
(
SCreateIndexStmt
));
case
QUERY_NODE_CREATE_QNODE_STMT
:
return
makeNode
(
type
,
sizeof
(
SCreateQnodeStmt
));
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
return
makeNode
(
type
,
sizeof
(
SScanLogicNode
));
case
QUERY_NODE_LOGIC_PLAN_JOIN
:
...
...
source/libs/parser/inc/parAst.h
浏览文件 @
7f9521b3
...
...
@@ -134,6 +134,7 @@ SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const
SNode
*
createDropDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnode
);
SNode
*
createCreateIndexStmt
(
SAstCreateContext
*
pCxt
,
EIndexType
type
,
const
SToken
*
pIndexName
,
const
SToken
*
pTableName
,
SNodeList
*
pCols
,
SNode
*
pOptions
);
SNode
*
createIndexOption
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pFuncs
,
SNode
*
pInterval
,
SNode
*
pOffset
,
SNode
*
pSliding
);
SNode
*
createCreateQnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnodeId
);
#ifdef __cplusplus
}
...
...
source/libs/parser/inc/sql.y
浏览文件 @
7f9521b3
...
...
@@ -64,6 +64,10 @@ dnode_endpoint(A) ::= NK_STRING(B).
dnode_host_name(A) ::= NK_ID(B). { A = B; }
dnode_host_name(A) ::= NK_IPTOKEN(B). { A = B; }
/************************************************ create qnode ********************************************************/
cmd ::= CREATE QNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createCreateQnodeStmt(pCxt, &A); }
cmd ::= SHOW QNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT, NULL); }
/************************************************ create/drop/show/use database ***************************************/
cmd ::= CREATE DATABASE not_exists_opt(A) db_name(B) db_options(C). { pCxt->pRootNode = createCreateDatabaseStmt(pCxt, A, &B, C);}
cmd ::= DROP DATABASE exists_opt(A) db_name(B). { pCxt->pRootNode = createDropDatabaseStmt(pCxt, A, &B); }
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
7f9521b3
...
...
@@ -1021,3 +1021,10 @@ SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInt
pOptions
->
pSliding
=
pSliding
;
return
(
SNode
*
)
pOptions
;
}
SNode
*
createCreateQnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnodeId
)
{
SCreateQnodeStmt
*
pStmt
=
nodesMakeNode
(
QUERY_NODE_CREATE_QNODE_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
pStmt
->
dnodeId
=
strtol
(
pDnodeId
->
z
,
NULL
,
10
);;
return
(
SNode
*
)
pStmt
;
}
source/libs/parser/src/parTokenizer.c
浏览文件 @
7f9521b3
...
...
@@ -99,6 +99,8 @@ static SKeyword keywordTable[] = {
{
"PRECISION"
,
TK_PRECISION
},
{
"PRIVILEGE"
,
TK_PRIVILEGE
},
{
"PREV"
,
TK_PREV
},
{
"QNODE"
,
TK_QNODE
},
{
"QNODES"
,
TK_QNODES
},
{
"QUORUM"
,
TK_QUORUM
},
{
"REPLICA"
,
TK_REPLICA
},
{
"SELECT"
,
TK_SELECT
},
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
7f9521b3
...
...
@@ -1077,6 +1077,8 @@ static int32_t nodeTypeToShowType(ENodeType nt) {
return
TSDB_MGMT_TABLE_VGROUP
;
case
QUERY_NODE_SHOW_MNODES_STMT
:
return
TSDB_MGMT_TABLE_MNODE
;
case
QUERY_NODE_SHOW_QNODES_STMT
:
return
TSDB_MGMT_TABLE_QNODE
;
default:
break
;
}
...
...
@@ -1185,7 +1187,7 @@ static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt
}
void
*
pBuf
=
pCxt
->
pCmdMsg
->
pMsg
;
tSerializeSVCreateTSmaReq
(
&
pBuf
,
&
createSmaReq
);
// todo clear SVCreateTSmaReq
tdDestroyTSma
(
&
createSmaReq
.
tSma
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1199,6 +1201,25 @@ static int32_t translateCreateIndex(STranslateContext* pCxt, SCreateIndexStmt* p
}
}
static
int32_t
translateCreateQnode
(
STranslateContext
*
pCxt
,
SCreateQnodeStmt
*
pStmt
)
{
SMCreateQnodeReq
createReq
=
{
.
dnodeId
=
pStmt
->
dnodeId
};
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pCxt
->
pCmdMsg
->
epSet
=
pCxt
->
pParseCxt
->
mgmtEpSet
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_DND_CREATE_QNODE
;
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
tSerializeSMCreateDropQSBNodeReq
(
pCxt
->
pCmdMsg
->
pMsg
,
pCxt
->
pCmdMsg
->
msgLen
,
&
createReq
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateQuery
(
STranslateContext
*
pCxt
,
SNode
*
pNode
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
switch
(
nodeType
(
pNode
))
{
...
...
@@ -1244,6 +1265,7 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
case
QUERY_NODE_SHOW_DNODES_STMT
:
case
QUERY_NODE_SHOW_VGROUPS_STMT
:
case
QUERY_NODE_SHOW_MNODES_STMT
:
case
QUERY_NODE_SHOW_QNODES_STMT
:
code
=
translateShow
(
pCxt
,
(
SShowStmt
*
)
pNode
);
break
;
case
QUERY_NODE_SHOW_TABLES_STMT
:
...
...
@@ -1252,6 +1274,9 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
case
QUERY_NODE_CREATE_INDEX_STMT
:
code
=
translateCreateIndex
(
pCxt
,
(
SCreateIndexStmt
*
)
pNode
);
break
;
case
QUERY_NODE_CREATE_QNODE_STMT
:
code
=
translateCreateQnode
(
pCxt
,
(
SCreateQnodeStmt
*
)
pNode
);
break
;
default:
break
;
}
...
...
source/libs/parser/src/sql.c
浏览文件 @
7f9521b3
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
source/libs/parser/test/parserAstTest.cpp
浏览文件 @
7f9521b3
...
...
@@ -405,3 +405,10 @@ TEST_F(ParserTest, createSmaIndex) {
bind
(
"create sma index index1 on t1 function(max(c1), min(c3 + 10), sum(c4)) INTERVAL(10s)"
);
ASSERT_TRUE
(
run
());
}
TEST_F
(
ParserTest
,
createQnode
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"create qnode on dnode 1"
);
ASSERT_TRUE
(
run
());
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录