Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
06f0f1d3
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
06f0f1d3
编写于
3月 08, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-13747 phase 1 function integration
上级
d3138fff
变更
12
展开全部
显示空白变更内容
内联
并排
Showing
12 changed file
with
1063 addition
and
865 deletion
+1063
-865
include/libs/nodes/cmdnodes.h
include/libs/nodes/cmdnodes.h
+12
-0
include/libs/nodes/nodes.h
include/libs/nodes/nodes.h
+1
-0
source/libs/nodes/src/nodesCloneFuncs.c
source/libs/nodes/src/nodesCloneFuncs.c
+102
-14
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+2
-1
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+7
-5
source/libs/parser/inc/astCreateFuncs.h
source/libs/parser/inc/astCreateFuncs.h
+2
-1
source/libs/parser/inc/new_sql.y
source/libs/parser/inc/new_sql.y
+10
-8
source/libs/parser/src/astCreateFuncs.c
source/libs/parser/src/astCreateFuncs.c
+21
-3
source/libs/parser/src/astTranslate.c
source/libs/parser/src/astTranslate.c
+63
-5
source/libs/parser/src/new_sql.c
source/libs/parser/src/new_sql.c
+835
-823
source/libs/planner/src/physicalPlan.c
source/libs/planner/src/physicalPlan.c
+7
-5
source/libs/planner/src/planner.c
source/libs/planner/src/planner.c
+1
-0
未找到文件。
include/libs/nodes/cmdnodes.h
浏览文件 @
06f0f1d3
...
...
@@ -112,6 +112,13 @@ typedef struct SDropTableStmt {
SNodeList
*
pTables
;
}
SDropTableStmt
;
typedef
struct
SDropSuperTableStmt
{
ENodeType
type
;
char
dbName
[
TSDB_DB_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
bool
ignoreNotExists
;
}
SDropSuperTableStmt
;
typedef
struct
SCreateUserStmt
{
ENodeType
type
;
char
useName
[
TSDB_USER_LEN
];
...
...
@@ -143,6 +150,11 @@ typedef struct SDropDnodeStmt {
int32_t
port
;
}
SDropDnodeStmt
;
typedef
struct
SShowStmt
{
ENodeType
type
;
char
dbName
[
TSDB_DB_NAME_LEN
];
}
SShowStmt
;
#ifdef __cplusplus
}
#endif
...
...
include/libs/nodes/nodes.h
浏览文件 @
06f0f1d3
...
...
@@ -79,6 +79,7 @@ typedef enum ENodeType {
QUERY_NODE_CREATE_MULTI_TABLE_STMT
,
QUERY_NODE_DROP_TABLE_CLAUSE
,
QUERY_NODE_DROP_TABLE_STMT
,
QUERY_NODE_DROP_SUPER_TABLE_STMT
,
QUERY_NODE_SHOW_TABLES_STMT
,
// temp
QUERY_NODE_SHOW_STABLES_STMT
,
QUERY_NODE_CREATE_USER_STMT
,
...
...
source/libs/nodes/src/nodesCloneFuncs.c
浏览文件 @
06f0f1d3
...
...
@@ -34,8 +34,11 @@
(pDst)->fldname = strdup((pSrc)->fldname); \
} while (0)
#define C
OPY
_NODE_FIELD(fldname) \
#define C
LONE
_NODE_FIELD(fldname) \
do { \
if (NULL == (pSrc)->fldname) { \
break; \
} \
(pDst)->fldname = nodesCloneNode((pSrc)->fldname); \
if (NULL == (pDst)->fldname) { \
nodesDestroyNode((SNode*)(pDst)); \
...
...
@@ -43,8 +46,11 @@
} \
} while (0)
#define C
OPY
_NODE_LIST_FIELD(fldname) \
#define C
LONE
_NODE_LIST_FIELD(fldname) \
do { \
if (NULL == (pSrc)->fldname) { \
break; \
} \
(pDst)->fldname = nodesCloneList((pSrc)->fldname); \
if (NULL == (pDst)->fldname) { \
nodesDestroyNode((SNode*)(pDst)); \
...
...
@@ -52,6 +58,22 @@
} \
} while (0)
#define CLONE_OBJECT_FIELD(fldname, cloneFunc) \
do { \
(pDst)->fldname = cloneFunc((pSrc)->fldname); \
if (NULL == (pDst)->fldname) { \
nodesDestroyNode((SNode*)(pDst)); \
return NULL; \
} \
} while (0)
#define COPY_BASE_OBJECT_FIELD(fldname, copyFunc) \
do { \
if (NULL == copyFunc(&((pSrc)->fldname), &((pDst)->fldname))) { \
return NULL; \
} \
} while (0)
static
void
dataTypeCopy
(
const
SDataType
*
pSrc
,
SDataType
*
pDst
)
{
COPY_SCALAR_FIELD
(
type
);
COPY_SCALAR_FIELD
(
precision
);
...
...
@@ -62,7 +84,7 @@ static void dataTypeCopy(const SDataType* pSrc, SDataType* pDst) {
static
void
exprNodeCopy
(
const
SExprNode
*
pSrc
,
SExprNode
*
pDst
)
{
dataTypeCopy
(
&
pSrc
->
resType
,
&
pDst
->
resType
);
COPY_CHAR_ARRAY_FIELD
(
aliasName
);
// C
OPY
_NODE_LIST_FIELD(pAssociationList);
// C
LONE
_NODE_LIST_FIELD(pAssociationList);
}
static
SNode
*
columnNodeCopy
(
const
SColumnNode
*
pSrc
,
SColumnNode
*
pDst
)
{
...
...
@@ -73,7 +95,7 @@ static SNode* columnNodeCopy(const SColumnNode* pSrc, SColumnNode* pDst) {
COPY_CHAR_ARRAY_FIELD
(
tableName
);
COPY_CHAR_ARRAY_FIELD
(
tableAlias
);
COPY_CHAR_ARRAY_FIELD
(
colName
);
// C
OPY
_NODE_FIELD(pProjectRef);
// C
LONE
_NODE_FIELD(pProjectRef);
COPY_SCALAR_FIELD
(
dataBlockId
);
COPY_SCALAR_FIELD
(
slotId
);
return
(
SNode
*
)
pDst
;
...
...
@@ -125,15 +147,15 @@ static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) {
static
SNode
*
operatorNodeCopy
(
const
SOperatorNode
*
pSrc
,
SOperatorNode
*
pDst
)
{
exprNodeCopy
((
const
SExprNode
*
)
pSrc
,
(
SExprNode
*
)
pDst
);
COPY_SCALAR_FIELD
(
opType
);
C
OPY
_NODE_FIELD
(
pLeft
);
C
OPY
_NODE_FIELD
(
pRight
);
C
LONE
_NODE_FIELD
(
pLeft
);
C
LONE
_NODE_FIELD
(
pRight
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
logicConditionNodeCopy
(
const
SLogicConditionNode
*
pSrc
,
SLogicConditionNode
*
pDst
)
{
exprNodeCopy
((
const
SExprNode
*
)
pSrc
,
(
SExprNode
*
)
pDst
);
COPY_SCALAR_FIELD
(
condType
);
C
OPY
_NODE_LIST_FIELD
(
pParameterList
);
C
LONE
_NODE_LIST_FIELD
(
pParameterList
);
return
(
SNode
*
)
pDst
;
}
...
...
@@ -142,32 +164,89 @@ static SNode* functionNodeCopy(const SFunctionNode* pSrc, SFunctionNode* pDst) {
COPY_CHAR_ARRAY_FIELD
(
functionName
);
COPY_SCALAR_FIELD
(
funcId
);
COPY_SCALAR_FIELD
(
funcType
);
C
OPY
_NODE_LIST_FIELD
(
pParameterList
);
C
LONE
_NODE_LIST_FIELD
(
pParameterList
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
targetNodeCopy
(
const
STargetNode
*
pSrc
,
STargetNode
*
pDst
)
{
COPY_SCALAR_FIELD
(
dataBlockId
);
COPY_SCALAR_FIELD
(
slotId
);
C
OPY
_NODE_FIELD
(
pExpr
);
C
LONE
_NODE_FIELD
(
pExpr
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
groupingSetNodeCopy
(
const
SGroupingSetNode
*
pSrc
,
SGroupingSetNode
*
pDst
)
{
COPY_SCALAR_FIELD
(
groupingSetType
);
COPY_NODE_LIST_FIELD
(
pParameterList
);
CLONE_NODE_LIST_FIELD
(
pParameterList
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
logicNodeCopy
(
const
SLogicNode
*
pSrc
,
SLogicNode
*
pDst
)
{
COPY_SCALAR_FIELD
(
id
);
CLONE_NODE_LIST_FIELD
(
pTargets
);
CLONE_NODE_FIELD
(
pConditions
);
CLONE_NODE_LIST_FIELD
(
pChildren
);
return
(
SNode
*
)
pDst
;
}
static
STableMeta
*
tableMetaClone
(
const
STableMeta
*
pSrc
)
{
int32_t
len
=
sizeof
(
STableMeta
)
+
(
pSrc
->
tableInfo
.
numOfTags
+
pSrc
->
tableInfo
.
numOfColumns
)
*
sizeof
(
SSchema
);
STableMeta
*
pDst
=
malloc
(
len
);
if
(
NULL
==
pDst
)
{
return
NULL
;
}
memcpy
(
pDst
,
pSrc
,
len
);
return
pDst
;
}
static
SVgroupsInfo
*
vgroupsInfoClone
(
const
SVgroupsInfo
*
pSrc
)
{
int32_t
len
=
sizeof
(
SVgroupsInfo
)
+
pSrc
->
numOfVgroups
*
sizeof
(
SVgroupInfo
);
SVgroupsInfo
*
pDst
=
malloc
(
len
);
if
(
NULL
==
pDst
)
{
return
NULL
;
}
memcpy
(
pDst
,
pSrc
,
len
);
return
pDst
;
}
static
SNode
*
logicScanCopy
(
const
SScanLogicNode
*
pSrc
,
SScanLogicNode
*
pDst
)
{
COPY_BASE_OBJECT_FIELD
(
node
,
logicNodeCopy
);
CLONE_NODE_LIST_FIELD
(
pScanCols
);
CLONE_OBJECT_FIELD
(
pMeta
,
tableMetaClone
);
CLONE_OBJECT_FIELD
(
pVgroupList
,
vgroupsInfoClone
);
COPY_SCALAR_FIELD
(
scanType
);
COPY_SCALAR_FIELD
(
scanFlag
);
COPY_SCALAR_FIELD
(
scanRange
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
logicAggCopy
(
const
SAggLogicNode
*
pSrc
,
SAggLogicNode
*
pDst
)
{
COPY_BASE_OBJECT_FIELD
(
node
,
logicNodeCopy
);
CLONE_NODE_LIST_FIELD
(
pGroupKeys
);
CLONE_NODE_LIST_FIELD
(
pAggFuncs
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
logicProjectCopy
(
const
SProjectLogicNode
*
pSrc
,
SProjectLogicNode
*
pDst
)
{
COPY_BASE_OBJECT_FIELD
(
node
,
logicNodeCopy
);
CLONE_NODE_LIST_FIELD
(
pProjections
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
logicVnodeModifCopy
(
const
SVnodeModifLogicNode
*
pSrc
,
SVnodeModifLogicNode
*
pDst
)
{
COPY_SCALAR_FIELD
(
msgType
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
logicSubplanCopy
(
const
SSubLogicPlan
*
pSrc
,
SSubLogicPlan
*
pDst
)
{
C
OPY
_NODE_FIELD
(
pNode
);
C
LONE
_NODE_FIELD
(
pNode
);
COPY_SCALAR_FIELD
(
subplanType
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
dataBlockDescCopy
(
const
SDataBlockDescNode
*
pSrc
,
SDataBlockDescNode
*
pDst
)
{
COPY_SCALAR_FIELD
(
dataBlockId
);
C
OPY
_NODE_LIST_FIELD
(
pSlots
);
C
LONE
_NODE_LIST_FIELD
(
pSlots
);
COPY_SCALAR_FIELD
(
resultRowSize
);
COPY_SCALAR_FIELD
(
precision
);
return
(
SNode
*
)
pDst
;
...
...
@@ -217,13 +296,22 @@ SNodeptr nodesCloneNode(const SNodeptr pNode) {
return
dataBlockDescCopy
((
const
SDataBlockDescNode
*
)
pNode
,
(
SDataBlockDescNode
*
)
pDst
);
case
QUERY_NODE_SLOT_DESC
:
return
slotDescCopy
((
const
SSlotDescNode
*
)
pNode
,
(
SSlotDescNode
*
)
pDst
);
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
return
logicScanCopy
((
const
SScanLogicNode
*
)
pNode
,
(
SScanLogicNode
*
)
pDst
);
case
QUERY_NODE_LOGIC_PLAN_AGG
:
return
logicAggCopy
((
const
SAggLogicNode
*
)
pNode
,
(
SAggLogicNode
*
)
pDst
);
case
QUERY_NODE_LOGIC_PLAN_PROJECT
:
return
logicProjectCopy
((
const
SProjectLogicNode
*
)
pNode
,
(
SProjectLogicNode
*
)
pDst
);
case
QUERY_NODE_LOGIC_PLAN_VNODE_MODIF
:
return
logicVnodeModifCopy
((
const
SVnodeModifLogicNode
*
)
pNode
,
(
SVnodeModifLogicNode
*
)
pDst
);
case
QUERY_NODE_LOGIC_SUBPLAN
:
return
logicSubplanCopy
((
const
SSubLogicPlan
*
)
pNode
,
(
SSubLogicPlan
*
)
pDst
);
default:
break
;
}
nodesWarn
(
"nodesCloneNode unknown node = %s"
,
nodesNodeName
(
nodeType
(
pNode
)));
return
pDst
;
nodesDestroyNode
(
pDst
);
nodesError
(
"nodesCloneNode unknown node = %s"
,
nodesNodeName
(
nodeType
(
pNode
)));
return
NULL
;
}
SNodeList
*
nodesCloneList
(
const
SNodeList
*
pList
)
{
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
06f0f1d3
...
...
@@ -1532,7 +1532,8 @@ static int32_t jsonToNodeObject(const SJson* pJson, const char* pName, SNode** p
int32_t
nodesNodeToString
(
const
SNodeptr
pNode
,
bool
format
,
char
**
pStr
,
int32_t
*
pLen
)
{
if
(
NULL
==
pNode
||
NULL
==
pStr
||
NULL
==
pLen
)
{
return
TSDB_CODE_SUCCESS
;
terrno
=
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
SJson
*
pJson
=
tjsonCreateObject
();
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
06f0f1d3
...
...
@@ -85,7 +85,7 @@ SNodeptr nodesMakeNode(ENodeType type) {
case
QUERY_NODE_DROP_DATABASE_STMT
:
return
makeNode
(
type
,
sizeof
(
SDropDatabaseStmt
));
case
QUERY_NODE_SHOW_DATABASES_STMT
:
return
makeNode
(
type
,
sizeof
(
S
Node
));
return
makeNode
(
type
,
sizeof
(
S
ShowStmt
));
case
QUERY_NODE_CREATE_TABLE_STMT
:
return
makeNode
(
type
,
sizeof
(
SCreateTableStmt
));
case
QUERY_NODE_CREATE_SUBTABLE_CLAUSE
:
...
...
@@ -96,9 +96,11 @@ SNodeptr nodesMakeNode(ENodeType type) {
return
makeNode
(
type
,
sizeof
(
SDropTableClause
));
case
QUERY_NODE_DROP_TABLE_STMT
:
return
makeNode
(
type
,
sizeof
(
SDropTableStmt
));
case
QUERY_NODE_DROP_SUPER_TABLE_STMT
:
return
makeNode
(
type
,
sizeof
(
SDropSuperTableStmt
));
case
QUERY_NODE_SHOW_TABLES_STMT
:
case
QUERY_NODE_SHOW_STABLES_STMT
:
return
makeNode
(
type
,
sizeof
(
S
Node
));
return
makeNode
(
type
,
sizeof
(
S
ShowStmt
));
case
QUERY_NODE_CREATE_USER_STMT
:
return
makeNode
(
type
,
sizeof
(
SCreateUserStmt
));
case
QUERY_NODE_ALTER_USER_STMT
:
...
...
@@ -106,7 +108,7 @@ SNodeptr nodesMakeNode(ENodeType type) {
case
QUERY_NODE_DROP_USER_STMT
:
return
makeNode
(
type
,
sizeof
(
SDropUserStmt
));
case
QUERY_NODE_SHOW_USERS_STMT
:
return
makeNode
(
type
,
sizeof
(
S
Node
));
return
makeNode
(
type
,
sizeof
(
S
ShowStmt
));
case
QUERY_NODE_USE_DATABASE_STMT
:
return
makeNode
(
type
,
sizeof
(
SUseDatabaseStmt
));
case
QUERY_NODE_CREATE_DNODE_STMT
:
...
...
@@ -114,9 +116,9 @@ SNodeptr nodesMakeNode(ENodeType type) {
case
QUERY_NODE_DROP_DNODE_STMT
:
return
makeNode
(
type
,
sizeof
(
SDropDnodeStmt
));
case
QUERY_NODE_SHOW_DNODES_STMT
:
return
makeNode
(
type
,
sizeof
(
S
Node
));
return
makeNode
(
type
,
sizeof
(
S
ShowStmt
));
case
QUERY_NODE_SHOW_VGROUPS_STMT
:
return
makeNode
(
type
,
sizeof
(
S
Node
));
return
makeNode
(
type
,
sizeof
(
S
ShowStmt
));
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
return
makeNode
(
type
,
sizeof
(
SScanLogicNode
));
case
QUERY_NODE_LOGIC_PLAN_JOIN
:
...
...
source/libs/parser/inc/astCreateFuncs.h
浏览文件 @
06f0f1d3
...
...
@@ -124,8 +124,9 @@ SNode* createCreateSubTableClause(SAstCreateContext* pCxt, bool ignoreExists, SN
SNode
*
createCreateMultiTableStmt
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pSubTables
);
SNode
*
createDropTableClause
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SNode
*
pRealTable
);
SNode
*
createDropTableStmt
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pTables
);
SNode
*
createDropSuperTableStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SNode
*
pRealTable
);
SNode
*
createUseDatabaseStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDbName
);
SNode
*
createShowStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
);
SNode
*
createShowStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
,
const
SToken
*
pDbName
);
SNode
*
createCreateUserStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pUserName
,
const
SToken
*
pPassword
);
SNode
*
createAlterUserStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pUserName
,
int8_t
alterType
,
const
SToken
*
pVal
);
SNode
*
createDropUserStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pUserName
);
...
...
source/libs/parser/inc/new_sql.y
浏览文件 @
06f0f1d3
...
...
@@ -48,14 +48,14 @@ cmd ::= CREATE USER user_name(A) PASS NK_STRING(B).
cmd ::= ALTER USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PASSWD, &B);}
cmd ::= ALTER USER user_name(A) PRIVILEGE NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PRIVILEGES, &B);}
cmd ::= DROP USER user_name(A). { pCxt->pRootNode = createDropUserStmt(pCxt, &A); }
cmd ::= SHOW USERS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT); }
cmd ::= SHOW USERS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT
, NULL
); }
/************************************************ create/drop/show dnode **********************************************/
cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL);}
cmd ::= CREATE DNODE dnode_host_name(A) PORT NK_INTEGER(B). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, &B);}
cmd ::= DROP DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A);}
cmd ::= DROP DNODE dnode_endpoint(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A);}
cmd ::= SHOW DNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); }
cmd ::= SHOW DNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT
, NULL
); }
%type dnode_endpoint { SToken }
%destructor dnode_endpoint { }
...
...
@@ -69,7 +69,7 @@ dnode_host_name(A) ::= NK_IPTOKEN(B).
/************************************************ 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); }
cmd ::= SHOW DATABASES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); }
cmd ::= SHOW DATABASES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT
, NULL
); }
cmd ::= USE db_name(A). { pCxt->pRootNode = createUseDatabaseStmt(pCxt, &A);}
%type not_exists_opt { bool }
...
...
@@ -110,8 +110,9 @@ cmd ::= CREATE TABLE multi_create_clause(A).
cmd ::= CREATE STABLE not_exists_opt(A) full_table_name(B)
NK_LP column_def_list(C) NK_RP tags_def(D) table_options(E). { pCxt->pRootNode = createCreateTableStmt(pCxt, A, B, C, D, E);}
cmd ::= DROP TABLE multi_drop_clause(A). { pCxt->pRootNode = createDropTableStmt(pCxt, A); }
cmd ::= SHOW TABLES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT); }
cmd ::= SHOW STABLES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT); }
cmd ::= DROP STABLE exists_opt(A) full_table_name(B). { pCxt->pRootNode = createDropSuperTableStmt(pCxt, A, B); }
cmd ::= SHOW TABLES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, NULL); }
cmd ::= SHOW STABLES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, NULL); }
%type multi_create_clause { SNodeList* }
%destructor multi_create_clause { nodesDestroyList($$); }
...
...
@@ -195,10 +196,11 @@ col_name_list(A) ::= col_name_list(B) NK_COMMA col_name(C).
col_name(A) ::= column_name(B). { A = createColumnNode(pCxt, NULL, &B); }
/************************************************ show ***************************************************************/
cmd ::= SHOW VGROUPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT); }
/************************************************ show vgroups ********************************************************/
cmd ::= SHOW VGROUPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, NULL); }
cmd ::= SHOW db_name(B) NK_DOT VGROUPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &B); }
/************************************************ select *************************************************************/
/************************************************ select *************************************************************
*
/
cmd ::= query_expression(A). { pCxt->pRootNode = A; }
/************************************************ literal *************************************************************/
...
...
source/libs/parser/src/astCreateFuncs.c
浏览文件 @
06f0f1d3
...
...
@@ -883,6 +883,16 @@ SNode* createDropTableStmt(SAstCreateContext* pCxt, SNodeList* pTables) {
return
(
SNode
*
)
pStmt
;
}
SNode
*
createDropSuperTableStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SNode
*
pRealTable
)
{
SDropSuperTableStmt
*
pStmt
=
nodesMakeNode
(
QUERY_NODE_DROP_SUPER_TABLE_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
strcpy
(
pStmt
->
dbName
,
((
SRealTableNode
*
)
pRealTable
)
->
table
.
dbName
);
strcpy
(
pStmt
->
tableName
,
((
SRealTableNode
*
)
pRealTable
)
->
table
.
tableName
);
pStmt
->
ignoreNotExists
=
ignoreNotExists
;
nodesDestroyNode
(
pRealTable
);
return
(
SNode
*
)
pStmt
;
}
SNode
*
createUseDatabaseStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDbName
)
{
SUseDatabaseStmt
*
pStmt
=
(
SUseDatabaseStmt
*
)
nodesMakeNode
(
QUERY_NODE_USE_DATABASE_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
...
...
@@ -890,10 +900,18 @@ SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName) {
return
(
SNode
*
)
pStmt
;
}
SNode
*
createShowStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
)
{
SNode
*
pStmt
=
nodesMakeNode
(
type
);;
SNode
*
createShowStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
,
const
SToken
*
pDbName
)
{
if
(
!
checkDbName
(
pCxt
,
pDbName
))
{
return
NULL
;
}
SShowStmt
*
pStmt
=
nodesMakeNode
(
type
);;
CHECK_OUT_OF_MEM
(
pStmt
);
return
pStmt
;
if
(
NULL
!=
pDbName
)
{
strncpy
(
pStmt
->
dbName
,
pDbName
->
z
,
pDbName
->
n
);
}
else
if
(
NULL
!=
pCxt
->
pQueryCxt
->
db
)
{
strcpy
(
pStmt
->
dbName
,
pCxt
->
pQueryCxt
->
db
);
}
return
(
SNode
*
)
pStmt
;
}
SNode
*
createCreateUserStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pUserName
,
const
SToken
*
pPassword
)
{
...
...
source/libs/parser/src/astTranslate.c
浏览文件 @
06f0f1d3
...
...
@@ -858,6 +858,55 @@ static int32_t translateCreateSuperTable(STranslateContext* pCxt, SCreateTableSt
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
doTranslateDropSuperTable
(
STranslateContext
*
pCxt
,
const
SName
*
pTableName
,
bool
ignoreNotExists
)
{
SMDropStbReq
dropReq
=
{
0
};
tNameExtractFullName
(
pTableName
,
dropReq
.
name
);
dropReq
.
igNotExists
=
ignoreNotExists
;
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_MND_DROP_STB
;
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSMDropStbReq
(
NULL
,
0
,
&
dropReq
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
tSerializeSMDropStbReq
(
pCxt
->
pCmdMsg
->
pMsg
,
pCxt
->
pCmdMsg
->
msgLen
,
&
dropReq
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateDropTable
(
STranslateContext
*
pCxt
,
SDropTableStmt
*
pStmt
)
{
SDropTableClause
*
pClause
=
nodesListGetNode
(
pStmt
->
pTables
,
0
);
SName
tableName
=
{
.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
strcpy
(
tableName
.
dbname
,
pClause
->
dbName
);
strcpy
(
tableName
.
tname
,
pClause
->
tableName
);
STableMeta
*
pTableMeta
=
NULL
;
int32_t
code
=
catalogGetTableMeta
(
pCxt
->
pParseCxt
->
pCatalog
,
pCxt
->
pParseCxt
->
pTransporter
,
&
(
pCxt
->
pParseCxt
->
mgmtEpSet
),
&
tableName
,
&
pTableMeta
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_SUPER_TABLE
==
pTableMeta
->
tableType
)
{
code
=
doTranslateDropSuperTable
(
pCxt
,
&
tableName
,
pClause
->
ignoreNotExists
);
}
else
{
// todo;
code
=
TSDB_CODE_FAILED
;
}
}
tfree
(
pTableMeta
);
return
code
;
}
static
int32_t
translateDropSuperTable
(
STranslateContext
*
pCxt
,
SDropSuperTableStmt
*
pStmt
)
{
SName
tableName
=
{
.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
strcpy
(
tableName
.
dbname
,
pStmt
->
dbName
);
strcpy
(
tableName
.
tname
,
pStmt
->
tableName
);
return
doTranslateDropSuperTable
(
pCxt
,
&
tableName
,
pStmt
->
ignoreNotExists
);
}
static
int32_t
translateUseDatabase
(
STranslateContext
*
pCxt
,
SUseDatabaseStmt
*
pStmt
)
{
SName
name
=
{
0
};
tNameSetDbName
(
&
name
,
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
strlen
(
pStmt
->
dbName
));
...
...
@@ -1005,17 +1054,19 @@ static int32_t nodeTypeToShowType(ENodeType nt) {
return
TSDB_MGMT_TABLE_USER
;
case
QUERY_NODE_SHOW_DNODES_STMT
:
return
TSDB_MGMT_TABLE_DNODE
;
case
QUERY_NODE_SHOW_VGROUPS_STMT
:
return
TSDB_MGMT_TABLE_VGROUP
;
default:
break
;
}
return
0
;
}
static
int32_t
translateShow
(
STranslateContext
*
pCxt
,
ENodeType
type
)
{
SShowReq
showReq
=
{
.
type
=
nodeTypeToShowType
(
type
)
};
if
(
NULL
!=
pCxt
->
pParseCxt
->
db
)
{
static
int32_t
translateShow
(
STranslateContext
*
pCxt
,
SShowStmt
*
pStmt
)
{
SShowReq
showReq
=
{
.
type
=
nodeTypeToShowType
(
nodeType
(
pStmt
)
)
};
if
(
'\0'
!=
pStmt
->
dbName
[
0
]
)
{
SName
name
=
{
0
};
tNameSetDbName
(
&
name
,
pCxt
->
pParseCxt
->
acctId
,
p
Cxt
->
pParseCxt
->
db
,
strlen
(
pCxt
->
pParseCxt
->
db
));
tNameSetDbName
(
&
name
,
pCxt
->
pParseCxt
->
acctId
,
p
Stmt
->
dbName
,
strlen
(
pStmt
->
dbName
));
char
dbFname
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName
(
&
name
,
showReq
.
db
);
}
...
...
@@ -1079,6 +1130,12 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
case
QUERY_NODE_CREATE_TABLE_STMT
:
code
=
translateCreateSuperTable
(
pCxt
,
(
SCreateTableStmt
*
)
pNode
);
break
;
case
QUERY_NODE_DROP_TABLE_STMT
:
code
=
translateDropTable
(
pCxt
,
(
SDropTableStmt
*
)
pNode
);
break
;
case
QUERY_NODE_DROP_SUPER_TABLE_STMT
:
code
=
translateDropSuperTable
(
pCxt
,
(
SDropSuperTableStmt
*
)
pNode
);
break
;
case
QUERY_NODE_CREATE_USER_STMT
:
code
=
translateCreateUser
(
pCxt
,
(
SCreateUserStmt
*
)
pNode
);
break
;
...
...
@@ -1101,7 +1158,8 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
case
QUERY_NODE_SHOW_STABLES_STMT
:
case
QUERY_NODE_SHOW_USERS_STMT
:
case
QUERY_NODE_SHOW_DNODES_STMT
:
code
=
translateShow
(
pCxt
,
nodeType
(
pNode
));
case
QUERY_NODE_SHOW_VGROUPS_STMT
:
code
=
translateShow
(
pCxt
,
(
SShowStmt
*
)
pNode
);
break
;
case
QUERY_NODE_SHOW_TABLES_STMT
:
code
=
translateShowTables
(
pCxt
);
...
...
source/libs/parser/src/new_sql.c
浏览文件 @
06f0f1d3
此差异已折叠。
点击以展开。
source/libs/planner/src/physicalPlan.c
浏览文件 @
06f0f1d3
...
...
@@ -546,10 +546,12 @@ static SSubplan* createPhysiSubplan(SPhysiPlanContext* pCxt, SSubLogicPlan* pLog
static
int32_t
splitLogicPlan
(
SPhysiPlanContext
*
pCxt
,
SLogicNode
*
pLogicNode
,
SSubLogicPlan
**
pSubLogicPlan
)
{
*
pSubLogicPlan
=
(
SSubLogicPlan
*
)
nodesMakeNode
(
QUERY_NODE_LOGIC_SUBPLAN
);
CHECK_ALLOC
(
*
pSubLogicPlan
,
TSDB_CODE_OUT_OF_MEMORY
);
// todo pSubplan->pNode = nodesCloneNode(pLogicNode);
(
*
pSubLogicPlan
)
->
pNode
=
pLogicNode
;
(
*
pSubLogicPlan
)
->
pNode
=
nodesCloneNode
(
pLogicNode
);
if
(
QUERY_NODE_LOGIC_PLAN_VNODE_MODIF
==
nodeType
(
pLogicNode
))
{
(
*
pSubLogicPlan
)
->
subplanType
=
SUBPLAN_TYPE_MODIFY
;
TSWAP
(((
SVnodeModifLogicNode
*
)
pLogicNode
)
->
pDataBlocks
,
((
SVnodeModifLogicNode
*
)(
*
pSubLogicPlan
)
->
pNode
)
->
pDataBlocks
,
SArray
*
);
}
else
{
(
*
pSubLogicPlan
)
->
subplanType
=
SUBPLAN_TYPE_MERGE
;
}
// todo split
return
TSDB_CODE_SUCCESS
;
...
...
@@ -574,8 +576,7 @@ static int32_t pushSubplan(SPhysiPlanContext* pCxt, SNodeptr pSubplan, int32_t l
SSubLogicPlan
*
singleCloneSubLogicPlan
(
SPhysiPlanContext
*
pCxt
,
SSubLogicPlan
*
pSrc
,
int32_t
level
)
{
SSubLogicPlan
*
pDst
=
nodesMakeNode
(
QUERY_NODE_LOGIC_SUBPLAN
);
CHECK_ALLOC
(
pDst
,
NULL
);
// todo pDst->pNode = nodesCloneNode(pSrc->pNode);
pDst
->
pNode
=
pSrc
->
pNode
;
pDst
->
pNode
=
nodesCloneNode
(
pSrc
->
pNode
);
if
(
NULL
==
pDst
->
pNode
)
{
nodesDestroyNode
(
pDst
);
return
NULL
;
...
...
@@ -690,6 +691,7 @@ int32_t createPhysiPlan(SPlanContext* pCxt, SLogicNode* pLogicNode, SQueryPlan**
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
buildPhysiPlan
(
&
cxt
,
pLogicPlan
,
pPlan
);
}
nodesDestroyNode
((
SNode
*
)
pLogicPlan
);
nodesDestroyNode
(
pSubLogicPlan
);
nodesDestroyNode
(
pLogicPlan
);
return
code
;
}
source/libs/planner/src/planner.c
浏览文件 @
06f0f1d3
...
...
@@ -30,6 +30,7 @@ int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNo
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createPhysiPlan
(
pCxt
,
pLogicNode
,
pPlan
,
pExecNodeList
);
}
nodesDestroyNode
(
pLogicNode
);
return
code
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录