Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
37ec05a7
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看板
提交
37ec05a7
编写于
7月 20, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: memory leak problems of parser and planner
上级
763c95a0
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
240 addition
and
85 deletion
+240
-85
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+44
-14
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+1
-1
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+14
-1
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+32
-24
source/libs/parser/src/parser.c
source/libs/parser/src/parser.c
+1
-0
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+2
-1
source/libs/parser/test/mockCatalogService.cpp
source/libs/parser/test/mockCatalogService.cpp
+20
-0
source/libs/parser/test/mockCatalogService.h
source/libs/parser/test/mockCatalogService.h
+1
-0
source/libs/parser/test/parAlterToBalanceTest.cpp
source/libs/parser/test/parAlterToBalanceTest.cpp
+0
-0
source/libs/parser/test/parInitialCTest.cpp
source/libs/parser/test/parInitialCTest.cpp
+18
-1
source/libs/parser/test/parTestUtil.cpp
source/libs/parser/test/parTestUtil.cpp
+20
-12
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+32
-16
source/libs/planner/src/planSpliter.c
source/libs/planner/src/planSpliter.c
+4
-3
source/libs/planner/test/planStmtTest.cpp
source/libs/planner/test/planStmtTest.cpp
+24
-8
source/libs/planner/test/planTestUtil.cpp
source/libs/planner/test/planTestUtil.cpp
+27
-4
未找到文件。
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
37ec05a7
...
...
@@ -369,6 +369,8 @@ static void destroyPhysiNode(SPhysiNode* pNode) {
nodesDestroyList
(
pNode
->
pChildren
);
nodesDestroyNode
(
pNode
->
pConditions
);
nodesDestroyNode
((
SNode
*
)
pNode
->
pOutputDataBlockDesc
);
nodesDestroyNode
(
pNode
->
pLimit
);
nodesDestroyNode
(
pNode
->
pSlimit
);
}
static
void
destroyWinodwPhysiNode
(
SWinodwPhysiNode
*
pNode
)
{
...
...
@@ -389,11 +391,16 @@ static void destroyDataSinkNode(SDataSinkNode* pNode) { nodesDestroyNode((SNode*
static
void
destroyExprNode
(
SExprNode
*
pExpr
)
{
taosArrayDestroy
(
pExpr
->
pAssociation
);
}
static
void
nodesDestroyNodePointer
(
void
*
node
)
{
SNode
*
pNode
=
*
(
SNode
**
)
node
;
nodesDestroyNode
(
pNode
);
static
void
destroyTableCfg
(
STableCfg
*
pCfg
)
{
taosArrayDestroy
(
pCfg
->
pFuncs
);
taosMemoryFree
(
pCfg
->
pComment
);
taosMemoryFree
(
pCfg
->
pSchemas
);
taosMemoryFree
(
pCfg
->
pTags
);
taosMemoryFree
(
pCfg
);
}
static
void
destroySmaIndex
(
void
*
pIndex
)
{
taosMemoryFree
(((
STableIndexInfo
*
)
pIndex
)
->
expr
);
}
void
nodesDestroyNode
(
SNode
*
pNode
)
{
if
(
NULL
==
pNode
)
{
return
;
...
...
@@ -431,6 +438,7 @@ void nodesDestroyNode(SNode* pNode) {
SRealTableNode
*
pReal
=
(
SRealTableNode
*
)
pNode
;
taosMemoryFreeClear
(
pReal
->
pMeta
);
taosMemoryFreeClear
(
pReal
->
pVgroupList
);
taosArrayDestroyEx
(
pReal
->
pSmaIndexes
,
destroySmaIndex
);
break
;
}
case
QUERY_NODE_TEMP_TABLE
:
...
...
@@ -451,9 +459,12 @@ void nodesDestroyNode(SNode* pNode) {
break
;
case
QUERY_NODE_LIMIT
:
// no pointer field
break
;
case
QUERY_NODE_STATE_WINDOW
:
nodesDestroyNode
(((
SStateWindowNode
*
)
pNode
)
->
pExpr
);
case
QUERY_NODE_STATE_WINDOW
:
{
SStateWindowNode
*
pState
=
(
SStateWindowNode
*
)
pNode
;
nodesDestroyNode
(
pState
->
pCol
);
nodesDestroyNode
(
pState
->
pExpr
);
break
;
}
case
QUERY_NODE_SESSION_WINDOW
:
{
SSessionWindowNode
*
pSession
=
(
SSessionWindowNode
*
)
pNode
;
nodesDestroyNode
((
SNode
*
)
pSession
->
pCol
);
...
...
@@ -500,8 +511,10 @@ void nodesDestroyNode(SNode* pNode) {
}
case
QUERY_NODE_TABLE_OPTIONS
:
{
STableOptions
*
pOptions
=
(
STableOptions
*
)
pNode
;
nodesDestroyList
(
pOptions
->
pSma
);
nodesDestroyList
(
pOptions
->
pMaxDelay
);
nodesDestroyList
(
pOptions
->
pWatermark
);
nodesDestroyList
(
pOptions
->
pRollupFuncs
);
nodesDestroyList
(
pOptions
->
pSma
);
break
;
}
case
QUERY_NODE_INDEX_OPTIONS
:
{
...
...
@@ -510,17 +523,22 @@ void nodesDestroyNode(SNode* pNode) {
nodesDestroyNode
(
pOptions
->
pInterval
);
nodesDestroyNode
(
pOptions
->
pOffset
);
nodesDestroyNode
(
pOptions
->
pSliding
);
nodesDestroyNode
(
pOptions
->
pStreamOptions
);
break
;
}
case
QUERY_NODE_EXPLAIN_OPTIONS
:
// no pointer field
break
;
case
QUERY_NODE_STREAM_OPTIONS
:
nodesDestroyNode
(((
SStreamOptions
*
)
pNode
)
->
pWatermark
);
case
QUERY_NODE_STREAM_OPTIONS
:
{
SStreamOptions
*
pOptions
=
(
SStreamOptions
*
)
pNode
;
nodesDestroyNode
(
pOptions
->
pDelay
);
nodesDestroyNode
(
pOptions
->
pWatermark
);
break
;
}
case
QUERY_NODE_LEFT_VALUE
:
// no pointer field
break
;
case
QUERY_NODE_SET_OPERATOR
:
{
SSetOperator
*
pStmt
=
(
SSetOperator
*
)
pNode
;
nodesDestroyList
(
pStmt
->
pProjectionList
);
nodesDestroyNode
(
pStmt
->
pLeft
);
nodesDestroyNode
(
pStmt
->
pRight
);
nodesDestroyList
(
pStmt
->
pOrderByList
);
...
...
@@ -582,7 +600,8 @@ void nodesDestroyNode(SNode* pNode) {
break
;
case
QUERY_NODE_DROP_SUPER_TABLE_STMT
:
// no pointer field
break
;
case
QUERY_NODE_ALTER_TABLE_STMT
:
{
case
QUERY_NODE_ALTER_TABLE_STMT
:
case
QUERY_NODE_ALTER_SUPER_TABLE_STMT
:
{
SAlterTableStmt
*
pStmt
=
(
SAlterTableStmt
*
)
pNode
;
nodesDestroyNode
((
SNode
*
)
pStmt
->
pOptions
);
nodesDestroyNode
((
SNode
*
)
pStmt
->
pVal
);
...
...
@@ -686,14 +705,15 @@ void nodesDestroyNode(SNode* pNode) {
nodesDestroyNode
(
pStmt
->
pTbName
);
break
;
}
case
QUERY_NODE_SHOW_DNODE_VARIABLES_STMT
:
// no pointer field
case
QUERY_NODE_SHOW_DNODE_VARIABLES_STMT
:
nodesDestroyNode
(((
SShowDnodeVariablesStmt
*
)
pNode
)
->
pDnodeId
);
break
;
case
QUERY_NODE_SHOW_CREATE_DATABASE_STMT
:
taosMemoryFreeClear
(((
SShowCreateDatabaseStmt
*
)
pNode
)
->
pCfg
);
break
;
case
QUERY_NODE_SHOW_CREATE_TABLE_STMT
:
case
QUERY_NODE_SHOW_CREATE_STABLE_STMT
:
taosMemoryFreeClear
(((
SShowCreateTableStmt
*
)
pNode
)
->
pCfg
);
destroyTableCfg
((
STableCfg
*
)(((
SShowCreateTableStmt
*
)
pNode
)
->
pCfg
)
);
break
;
case
QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT
:
// no pointer field
case
QUERY_NODE_KILL_CONNECTION_STMT
:
// no pointer field
...
...
@@ -725,7 +745,8 @@ void nodesDestroyNode(SNode* pNode) {
}
taosArrayDestroy
(
pQuery
->
pDbList
);
taosArrayDestroy
(
pQuery
->
pTableList
);
taosArrayDestroyEx
(
pQuery
->
pPlaceholderValues
,
nodesDestroyNodePointer
);
taosArrayDestroy
(
pQuery
->
pPlaceholderValues
);
nodesDestroyNode
(
pQuery
->
pPrepareRoot
);
break
;
}
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
{
...
...
@@ -737,7 +758,7 @@ void nodesDestroyNode(SNode* pNode) {
nodesDestroyList
(
pLogicNode
->
pDynamicScanFuncs
);
nodesDestroyNode
(
pLogicNode
->
pTagCond
);
nodesDestroyNode
(
pLogicNode
->
pTagIndexCond
);
taosArrayDestroy
(
pLogicNode
->
pSmaIndexes
);
taosArrayDestroy
Ex
(
pLogicNode
->
pSmaIndexes
,
destroySmaIndex
);
nodesDestroyList
(
pLogicNode
->
pGroupTags
);
break
;
}
...
...
@@ -766,6 +787,9 @@ void nodesDestroyNode(SNode* pNode) {
destroyLogicNode
((
SLogicNode
*
)
pLogicNode
);
destroyVgDataBlockArray
(
pLogicNode
->
pDataBlocks
);
// pVgDataBlocks is weak reference
nodesDestroyNode
(
pLogicNode
->
pAffectedRows
);
taosMemoryFreeClear
(
pLogicNode
->
pVgroupList
);
nodesDestroyList
(
pLogicNode
->
pInsertCols
);
break
;
}
case
QUERY_NODE_LOGIC_PLAN_EXCHANGE
:
...
...
@@ -784,6 +808,7 @@ void nodesDestroyNode(SNode* pNode) {
nodesDestroyList
(
pLogicNode
->
pFuncs
);
nodesDestroyNode
(
pLogicNode
->
pTspk
);
nodesDestroyNode
(
pLogicNode
->
pTsEnd
);
nodesDestroyNode
(
pLogicNode
->
pStateExpr
);
break
;
}
case
QUERY_NODE_LOGIC_PLAN_FILL
:
{
...
...
@@ -833,9 +858,14 @@ void nodesDestroyNode(SNode* pNode) {
case
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
:
case
QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN
:
case
QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN
:
case
QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN
:
destroyScanPhysiNode
((
SScanPhysiNode
*
)
pNode
);
break
;
case
QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN
:
{
SLastRowScanPhysiNode
*
pPhyNode
=
(
SLastRowScanPhysiNode
*
)
pNode
;
destroyScanPhysiNode
((
SScanPhysiNode
*
)
pNode
);
nodesDestroyList
(
pPhyNode
->
pGroupTags
);
break
;
}
case
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
:
case
QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN
:
case
QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN
:
...
...
source/libs/parser/inc/sql.y
浏览文件 @
37ec05a7
...
...
@@ -462,7 +462,7 @@ explain_options(A) ::= explain_options(B) VERBOSE NK_BOOL(C).
explain_options(A) ::= explain_options(B) RATIO NK_FLOAT(C). { A = setExplainRatio(pCxt, B, &C); }
/************************************************ compact *************************************************************/
cmd ::= COMPACT VNODES IN NK_LP integer_list
(A) NK_RP. { pCxt->pRootNode = createCompactStmt(pCxt, A
); }
cmd ::= COMPACT VNODES IN NK_LP integer_list
NK_RP. { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT
); }
/************************************************ create/drop function ************************************************/
cmd ::= CREATE agg_func_opt(A) FUNCTION not_exists_opt(F) function_name(B)
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
37ec05a7
...
...
@@ -387,6 +387,19 @@ SNode* createLogicConditionNode(SAstCreateContext* pCxt, ELogicConditionType typ
return
(
SNode
*
)
cond
;
}
static
uint8_t
getMinusDataType
(
uint8_t
orgType
)
{
switch
(
orgType
)
{
case
TSDB_DATA_TYPE_UTINYINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
case
TSDB_DATA_TYPE_UINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
return
TSDB_DATA_TYPE_BIGINT
;
default:
break
;
}
return
orgType
;
}
SNode
*
createOperatorNode
(
SAstCreateContext
*
pCxt
,
EOperatorType
type
,
SNode
*
pLeft
,
SNode
*
pRight
)
{
CHECK_PARSER_STATUS
(
pCxt
);
if
(
OP_TYPE_MINUS
==
type
&&
QUERY_NODE_VALUE
==
nodeType
(
pLeft
))
{
...
...
@@ -402,7 +415,7 @@ SNode* createOperatorNode(SAstCreateContext* pCxt, EOperatorType type, SNode* pL
}
taosMemoryFree
(
pVal
->
literal
);
pVal
->
literal
=
pNewLiteral
;
pVal
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_BIGINT
;
pVal
->
node
.
resType
.
type
=
getMinusDataType
(
pVal
->
node
.
resType
.
type
)
;
return
pLeft
;
}
SOperatorNode
*
op
=
(
SOperatorNode
*
)
nodesMakeNode
(
QUERY_NODE_OPERATOR
);
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
37ec05a7
...
...
@@ -1257,6 +1257,7 @@ static int32_t rewriteFuncToValue(STranslateContext* pCxt, char* pLiteral, SNode
}
}
if
(
DEAL_RES_ERROR
!=
translateValue
(
pCxt
,
pVal
))
{
nodesDestroyNode
(
*
pNode
);
*
pNode
=
(
SNode
*
)
pVal
;
}
else
{
nodesDestroyNode
((
SNode
*
)
pVal
);
...
...
@@ -4009,30 +4010,7 @@ static SSchema* getTagSchema(STableMeta* pTableMeta, const char* pTagName) {
return
NULL
;
}
static
int32_t
checkAlterSuperTable
(
STranslateContext
*
pCxt
,
SAlterTableStmt
*
pStmt
)
{
if
(
TSDB_ALTER_TABLE_UPDATE_TAG_VAL
==
pStmt
->
alterType
||
TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME
==
pStmt
->
alterType
)
{
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_ALTER_TABLE
,
"Set tag value only available for child table"
);
}
if
(
pStmt
->
alterType
==
TSDB_ALTER_TABLE_UPDATE_OPTIONS
&&
-
1
!=
pStmt
->
pOptions
->
ttl
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_ALTER_TABLE
);
}
if
(
pStmt
->
dataType
.
type
==
TSDB_DATA_TYPE_JSON
&&
pStmt
->
alterType
==
TSDB_ALTER_TABLE_ADD_TAG
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_ONLY_ONE_JSON_TAG
);
}
if
(
pStmt
->
dataType
.
type
==
TSDB_DATA_TYPE_JSON
&&
pStmt
->
alterType
==
TSDB_ALTER_TABLE_ADD_COLUMN
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_COL_JSON
);
}
STableMeta
*
pTableMeta
=
NULL
;
int32_t
code
=
getTableMeta
(
pCxt
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
pTableMeta
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
}
static
int32_t
checkAlterSuperTableImpl
(
STranslateContext
*
pCxt
,
SAlterTableStmt
*
pStmt
,
STableMeta
*
pTableMeta
)
{
SSchema
*
pTagsSchema
=
getTableTagSchema
(
pTableMeta
);
if
(
getNumOfTags
(
pTableMeta
)
==
1
&&
pTagsSchema
->
type
==
TSDB_DATA_TYPE_JSON
&&
(
pStmt
->
alterType
==
TSDB_ALTER_TABLE_ADD_TAG
||
pStmt
->
alterType
==
TSDB_ALTER_TABLE_DROP_TAG
||
...
...
@@ -4057,6 +4035,33 @@ static int32_t checkAlterSuperTable(STranslateContext* pCxt, SAlterTableStmt* pS
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
checkAlterSuperTable
(
STranslateContext
*
pCxt
,
SAlterTableStmt
*
pStmt
)
{
if
(
TSDB_ALTER_TABLE_UPDATE_TAG_VAL
==
pStmt
->
alterType
||
TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME
==
pStmt
->
alterType
)
{
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_ALTER_TABLE
,
"Set tag value only available for child table"
);
}
if
(
pStmt
->
alterType
==
TSDB_ALTER_TABLE_UPDATE_OPTIONS
&&
-
1
!=
pStmt
->
pOptions
->
ttl
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_ALTER_TABLE
);
}
if
(
pStmt
->
dataType
.
type
==
TSDB_DATA_TYPE_JSON
&&
pStmt
->
alterType
==
TSDB_ALTER_TABLE_ADD_TAG
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_ONLY_ONE_JSON_TAG
);
}
if
(
pStmt
->
dataType
.
type
==
TSDB_DATA_TYPE_JSON
&&
pStmt
->
alterType
==
TSDB_ALTER_TABLE_ADD_COLUMN
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_COL_JSON
);
}
STableMeta
*
pTableMeta
=
NULL
;
int32_t
code
=
getTableMeta
(
pCxt
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
pTableMeta
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkAlterSuperTableImpl
(
pCxt
,
pStmt
,
pTableMeta
);
}
taosMemoryFree
(
pTableMeta
);
return
code
;
}
static
int32_t
translateAlterSuperTable
(
STranslateContext
*
pCxt
,
SAlterTableStmt
*
pStmt
)
{
SMAlterStbReq
alterReq
=
{
0
};
int32_t
code
=
checkAlterSuperTable
(
pCxt
,
pStmt
);
...
...
@@ -6438,6 +6443,7 @@ static int32_t toMsgType(ENodeType type) {
static
int32_t
setRefreshMate
(
STranslateContext
*
pCxt
,
SQuery
*
pQuery
)
{
if
(
NULL
!=
pCxt
->
pDbs
)
{
taosArrayDestroy
(
pQuery
->
pDbList
);
pQuery
->
pDbList
=
taosArrayInit
(
taosHashGetSize
(
pCxt
->
pDbs
),
TSDB_DB_FNAME_LEN
);
if
(
NULL
==
pQuery
->
pDbList
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -6450,6 +6456,7 @@ static int32_t setRefreshMate(STranslateContext* pCxt, SQuery* pQuery) {
}
if
(
NULL
!=
pCxt
->
pTables
)
{
taosArrayDestroy
(
pQuery
->
pTableList
);
pQuery
->
pTableList
=
taosArrayInit
(
taosHashGetSize
(
pCxt
->
pTables
),
sizeof
(
SName
));
if
(
NULL
==
pQuery
->
pTableList
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -6521,6 +6528,7 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) {
pQuery
->
stableQuery
=
pCxt
->
stableQuery
;
if
(
pQuery
->
haveResultSet
)
{
taosMemoryFreeClear
(
pQuery
->
pResSchema
);
if
(
TSDB_CODE_SUCCESS
!=
extractResultSchema
(
pQuery
->
pRoot
,
&
pQuery
->
numOfResCols
,
&
pQuery
->
pResSchema
))
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
...
...
source/libs/parser/src/parser.c
浏览文件 @
37ec05a7
...
...
@@ -239,6 +239,7 @@ int32_t qStmtBindParams(SQuery* pQuery, TAOS_MULTI_BIND* pParams, int32_t colIdx
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
(
colIdx
<
0
||
colIdx
+
1
==
pQuery
->
placeholderNum
))
{
nodesDestroyNode
(
pQuery
->
pRoot
);
pQuery
->
pRoot
=
nodesCloneNode
(
pQuery
->
pPrepareRoot
);
if
(
NULL
==
pQuery
->
pRoot
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
source/libs/parser/src/sql.c
浏览文件 @
37ec05a7
...
...
@@ -4117,7 +4117,8 @@ static YYACTIONTYPE yy_reduce(
yymsp
[
-
2
].
minor
.
yy616
=
yylhsminor
.
yy616
;
break
;
case
254
:
/* cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */
{
pCxt
->
pRootNode
=
createCompactStmt
(
pCxt
,
yymsp
[
-
1
].
minor
.
yy356
);
}
{
pCxt
->
errCode
=
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_EXPRIE_STATEMENT
);
}
yy_destructor
(
yypParser
,
273
,
&
yymsp
[
-
1
].
minor
);
break
;
case
255
:
/* cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */
{
pCxt
->
pRootNode
=
createCreateFunctionStmt
(
pCxt
,
yymsp
[
-
6
].
minor
.
yy151
,
yymsp
[
-
8
].
minor
.
yy151
,
&
yymsp
[
-
5
].
minor
.
yy361
,
&
yymsp
[
-
3
].
minor
.
yy0
,
yymsp
[
-
1
].
minor
.
yy600
,
yymsp
[
0
].
minor
.
yy734
);
}
...
...
source/libs/parser/test/mockCatalogService.cpp
浏览文件 @
37ec05a7
...
...
@@ -93,6 +93,17 @@ class MockCatalogServiceImpl {
MockCatalogServiceImpl
()
:
id_
(
1
)
{}
~
MockCatalogServiceImpl
()
{
for
(
auto
&
cfg
:
dbCfg_
)
{
taosArrayDestroy
(
cfg
.
second
.
pRetensions
);
}
for
(
auto
&
indexes
:
index_
)
{
for
(
auto
&
index
:
indexes
.
second
)
{
taosMemoryFree
(
index
.
expr
);
}
}
}
int32_t
catalogGetHandle
()
const
{
return
0
;
}
int32_t
catalogGetTableMeta
(
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
)
const
{
...
...
@@ -676,6 +687,7 @@ void MockCatalogService::destoryCatalogReq(SCatalogReq* pReq) {
taosArrayDestroy
(
pReq
->
pIndex
);
taosArrayDestroy
(
pReq
->
pUser
);
taosArrayDestroy
(
pReq
->
pTableIndex
);
taosArrayDestroy
(
pReq
->
pTableCfg
);
delete
pReq
;
}
...
...
@@ -684,6 +696,11 @@ void MockCatalogService::destoryMetaRes(void* p) {
taosMemoryFree
(
pRes
->
pRes
);
}
void
MockCatalogService
::
destoryMetaArrayRes
(
void
*
p
)
{
SMetaRes
*
pRes
=
(
SMetaRes
*
)
p
;
taosArrayDestroy
((
SArray
*
)
pRes
->
pRes
);
}
void
MockCatalogService
::
destoryMetaData
(
SMetaData
*
pData
)
{
taosArrayDestroyEx
(
pData
->
pDbVgroup
,
destoryMetaRes
);
taosArrayDestroyEx
(
pData
->
pDbCfg
,
destoryMetaRes
);
...
...
@@ -695,5 +712,8 @@ void MockCatalogService::destoryMetaData(SMetaData* pData) {
taosArrayDestroyEx
(
pData
->
pIndex
,
destoryMetaRes
);
taosArrayDestroyEx
(
pData
->
pUser
,
destoryMetaRes
);
taosArrayDestroyEx
(
pData
->
pQnodeList
,
destoryMetaRes
);
taosArrayDestroyEx
(
pData
->
pTableCfg
,
destoryMetaRes
);
taosArrayDestroyEx
(
pData
->
pDnodeList
,
destoryMetaArrayRes
);
taosMemoryFree
(
pData
->
pSvrVer
);
delete
pData
;
}
source/libs/parser/test/mockCatalogService.h
浏览文件 @
37ec05a7
...
...
@@ -52,6 +52,7 @@ class MockCatalogService {
public:
static
void
destoryCatalogReq
(
SCatalogReq
*
pReq
);
static
void
destoryMetaRes
(
void
*
p
);
static
void
destoryMetaArrayRes
(
void
*
p
);
static
void
destoryMetaData
(
SMetaData
*
pData
);
MockCatalogService
();
...
...
source/libs/parser/test/par
InitialA
Test.cpp
→
source/libs/parser/test/par
AlterToBalance
Test.cpp
浏览文件 @
37ec05a7
文件已移动
source/libs/parser/test/parInitialCTest.cpp
浏览文件 @
37ec05a7
...
...
@@ -21,7 +21,11 @@ namespace ParserTest {
class
ParserInitialCTest
:
public
ParserDdlTest
{};
// todo compact
TEST_F
(
ParserInitialCTest
,
compact
)
{
useDb
(
"root"
,
"test"
);
run
(
"COMPACT VNODES IN (1, 2)"
,
TSDB_CODE_PAR_EXPRIE_STATEMENT
,
PARSER_STAGE_PARSE
);
}
TEST_F
(
ParserInitialCTest
,
createAccount
)
{
useDb
(
"root"
,
"test"
);
...
...
@@ -32,6 +36,19 @@ TEST_F(ParserInitialCTest, createAccount) {
TEST_F
(
ParserInitialCTest
,
createBnode
)
{
useDb
(
"root"
,
"test"
);
SMCreateQnodeReq
expect
=
{
0
};
auto
setCreateQnodeReq
=
[
&
](
int32_t
dnodeId
)
{
expect
.
dnodeId
=
dnodeId
;
};
setCheckDdlFunc
([
&
](
const
SQuery
*
pQuery
,
ParserStage
stage
)
{
ASSERT_EQ
(
nodeType
(
pQuery
->
pRoot
),
QUERY_NODE_CREATE_BNODE_STMT
);
SMCreateQnodeReq
req
=
{
0
};
ASSERT_TRUE
(
TSDB_CODE_SUCCESS
==
tDeserializeSCreateDropMQSBNodeReq
(
pQuery
->
pCmdMsg
->
pMsg
,
pQuery
->
pCmdMsg
->
msgLen
,
&
req
));
ASSERT_EQ
(
req
.
dnodeId
,
expect
.
dnodeId
);
});
setCreateQnodeReq
(
1
);
run
(
"CREATE BNODE ON DNODE 1"
);
}
...
...
source/libs/parser/test/parTestUtil.cpp
浏览文件 @
37ec05a7
...
...
@@ -123,6 +123,14 @@ class ParserTestBaseImpl {
delete
pMetaCache
;
}
static
void
_destroyQuery
(
SQuery
**
pQuery
)
{
if
(
nullptr
==
pQuery
)
{
return
;
}
qDestroyQuery
(
*
pQuery
);
taosMemoryFree
(
pQuery
);
}
bool
checkResultCode
(
const
string
&
pFunc
,
int32_t
resultCode
)
{
return
!
(
stmtEnv_
.
checkFunc_
.
empty
())
?
((
stmtEnv_
.
checkFunc_
==
pFunc
)
?
stmtEnv_
.
expect_
==
resultCode
:
TSDB_CODE_SUCCESS
==
resultCode
)
...
...
@@ -278,9 +286,9 @@ class ParserTestBaseImpl {
SParseContext
cxt
=
{
0
};
setParseContext
(
sql
,
&
cxt
);
SQuery
*
pQuery
=
nullptr
;
doParse
(
&
cxt
,
&
pQuery
);
unique_ptr
<
SQuery
,
void
(
*
)(
SQuery
*
)
>
query
(
pQuery
,
qDestroyQuery
);
unique_ptr
<
SQuery
*
,
void
(
*
)(
SQuery
**
)
>
query
((
SQuery
**
)
taosMemoryCalloc
(
1
,
sizeof
(
SQuery
*
)),
_destroyQuery
)
;
doParse
(
&
cxt
,
query
.
get
()
);
SQuery
*
pQuery
=
*
(
query
.
get
()
);
doAuthenticate
(
&
cxt
,
pQuery
,
nullptr
);
...
...
@@ -306,9 +314,9 @@ class ParserTestBaseImpl {
SParseContext
cxt
=
{
0
};
setParseContext
(
sql
,
&
cxt
);
SQuery
*
pQuery
=
nullptr
;
doParseSql
(
&
cxt
,
&
pQuery
);
unique_ptr
<
SQuery
,
void
(
*
)(
SQuery
*
)
>
query
(
pQuery
,
qDestroyQuery
);
unique_ptr
<
SQuery
*
,
void
(
*
)(
SQuery
**
)
>
query
((
SQuery
**
)
taosMemoryCalloc
(
1
,
sizeof
(
SQuery
*
)),
_destroyQuery
)
;
doParseSql
(
&
cxt
,
query
.
get
()
);
SQuery
*
pQuery
=
*
(
query
.
get
()
);
if
(
g_dump
)
{
dump
();
...
...
@@ -328,9 +336,9 @@ class ParserTestBaseImpl {
SParseContext
cxt
=
{
0
};
setParseContext
(
sql
,
&
cxt
,
true
);
SQuery
*
pQuery
=
nullptr
;
doParse
(
&
cxt
,
&
pQuery
);
unique_ptr
<
SQuery
,
void
(
*
)(
SQuery
*
)
>
query
(
pQuery
,
qDestroyQuery
);
unique_ptr
<
SQuery
*
,
void
(
*
)(
SQuery
**
)
>
query
((
SQuery
**
)
taosMemoryCalloc
(
1
,
sizeof
(
SQuery
*
)),
_destroyQuery
)
;
doParse
(
&
cxt
,
query
.
get
()
);
SQuery
*
pQuery
=
*
(
query
.
get
()
);
unique_ptr
<
SParseMetaCache
,
void
(
*
)(
SParseMetaCache
*
)
>
metaCache
(
new
SParseMetaCache
(),
_destoryParseMetaCache
);
doCollectMetaKey
(
&
cxt
,
pQuery
,
metaCache
.
get
());
...
...
@@ -386,9 +394,9 @@ class ParserTestBaseImpl {
unique_ptr
<
SCatalogReq
,
void
(
*
)(
SCatalogReq
*
)
>
catalogReq
(
new
SCatalogReq
(),
MockCatalogService
::
destoryCatalogReq
);
SQuery
*
pQuery
=
nullptr
;
doParseSqlSyntax
(
&
cxt
,
&
pQuery
,
catalogReq
.
get
());
unique_ptr
<
SQuery
,
void
(
*
)(
SQuery
*
)
>
query
(
pQuery
,
qDestroyQuery
);
unique_ptr
<
SQuery
*
,
void
(
*
)(
SQuery
**
)
>
query
((
SQuery
**
)
taosMemoryCalloc
(
1
,
sizeof
(
SQuery
*
)),
_destroyQuery
)
;
doParseSqlSyntax
(
&
cxt
,
query
.
get
()
,
catalogReq
.
get
());
SQuery
*
pQuery
=
*
(
query
.
get
()
);
string
err
;
thread
t1
([
&
]()
{
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
37ec05a7
...
...
@@ -1068,7 +1068,11 @@ static int32_t createExchangePhysiNode(SPhysiPlanContext* pCxt, SExchangeLogicNo
}
static
int32_t
createWindowPhysiNodeFinalize
(
SPhysiPlanContext
*
pCxt
,
SNodeList
*
pChildren
,
SWinodwPhysiNode
*
pWindow
,
SWindowLogicNode
*
pWindowLogicNode
,
SPhysiNode
**
pPhyNode
)
{
SWindowLogicNode
*
pWindowLogicNode
)
{
pWindow
->
triggerType
=
pWindowLogicNode
->
triggerType
;
pWindow
->
watermark
=
pWindowLogicNode
->
watermark
;
pWindow
->
igExpired
=
pWindowLogicNode
->
igExpired
;
SNodeList
*
pPrecalcExprs
=
NULL
;
SNodeList
*
pFuncs
=
NULL
;
int32_t
code
=
rewritePrecalcExprs
(
pCxt
,
pWindowLogicNode
->
pFuncs
,
&
pPrecalcExprs
,
&
pFuncs
);
...
...
@@ -1100,16 +1104,6 @@ static int32_t createWindowPhysiNodeFinalize(SPhysiPlanContext* pCxt, SNodeList*
code
=
setConditionsSlotId
(
pCxt
,
(
const
SLogicNode
*
)
pWindowLogicNode
,
(
SPhysiNode
*
)
pWindow
);
}
pWindow
->
triggerType
=
pWindowLogicNode
->
triggerType
;
pWindow
->
watermark
=
pWindowLogicNode
->
watermark
;
pWindow
->
igExpired
=
pWindowLogicNode
->
igExpired
;
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pPhyNode
=
(
SPhysiNode
*
)
pWindow
;
}
else
{
nodesDestroyNode
((
SNode
*
)
pWindow
);
}
nodesDestroyList
(
pPrecalcExprs
);
nodesDestroyList
(
pFuncs
);
...
...
@@ -1156,7 +1150,14 @@ static int32_t createIntervalPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChil
pInterval
->
intervalUnit
=
pWindowLogicNode
->
intervalUnit
;
pInterval
->
slidingUnit
=
pWindowLogicNode
->
slidingUnit
;
return
createWindowPhysiNodeFinalize
(
pCxt
,
pChildren
,
&
pInterval
->
window
,
pWindowLogicNode
,
pPhyNode
);
int32_t
code
=
createWindowPhysiNodeFinalize
(
pCxt
,
pChildren
,
&
pInterval
->
window
,
pWindowLogicNode
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pPhyNode
=
(
SPhysiNode
*
)
pInterval
;
}
else
{
nodesDestroyNode
((
SNode
*
)
pInterval
);
}
return
code
;
}
static
int32_t
createSessionWindowPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SNodeList
*
pChildren
,
...
...
@@ -1169,7 +1170,14 @@ static int32_t createSessionWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList*
pSession
->
gap
=
pWindowLogicNode
->
sessionGap
;
return
createWindowPhysiNodeFinalize
(
pCxt
,
pChildren
,
&
pSession
->
window
,
pWindowLogicNode
,
pPhyNode
);
int32_t
code
=
createWindowPhysiNodeFinalize
(
pCxt
,
pChildren
,
&
pSession
->
window
,
pWindowLogicNode
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pPhyNode
=
(
SPhysiNode
*
)
pSession
;
}
else
{
nodesDestroyNode
((
SNode
*
)
pSession
);
}
return
code
;
}
static
int32_t
createStateWindowPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SNodeList
*
pChildren
,
...
...
@@ -1201,12 +1209,20 @@ static int32_t createStateWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pC
}
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createWindowPhysiNodeFinalize
(
pCxt
,
pChildren
,
&
pState
->
window
,
pWindowLogicNode
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pPhyNode
=
(
SPhysiNode
*
)
pState
;
}
else
{
nodesDestroyNode
((
SNode
*
)
pState
);
return
code
;
}
return
createWindowPhysiNodeFinalize
(
pCxt
,
pChildren
,
&
pState
->
window
,
pWindowLogicNode
,
pPhyNode
);
nodesDestroyList
(
pPrecalcExprs
);
nodesDestroyNode
(
pStateKey
);
return
code
;
}
static
int32_t
createWindowPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SNodeList
*
pChildren
,
SWindowLogicNode
*
pWindowLogicNode
,
...
...
source/libs/planner/src/planSpliter.c
浏览文件 @
37ec05a7
...
...
@@ -867,10 +867,11 @@ static int32_t stbSplSplitSortNode(SSplitContext* pCxt, SStableSplitInfo* pInfo)
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
stbSplCreateMergeNode
(
pCxt
,
pInfo
->
pSubplan
,
pInfo
->
pSplitNode
,
pMergeKeys
,
pPartSort
,
groupSort
);
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
groupSort
)
{
stbSplSetScanPartSort
(
pPartSort
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
nodesDestroyNode
((
SNode
*
)
pInfo
->
pSplitNode
);
if
(
groupSort
)
{
stbSplSetScanPartSort
(
pPartSort
);
}
code
=
nodesListMakeStrictAppend
(
&
pInfo
->
pSubplan
->
pChildren
,
(
SNode
*
)
splCreateScanSubplan
(
pCxt
,
pPartSort
,
SPLIT_FLAG_STABLE_SPLIT
));
}
...
...
source/libs/planner/test/planStmtTest.cpp
浏览文件 @
37ec05a7
...
...
@@ -24,6 +24,16 @@ class PlanStmtTest : public PlannerTestBase {
return
(
TAOS_MULTI_BIND
*
)
taosMemoryCalloc
(
nParams
,
sizeof
(
TAOS_MULTI_BIND
));
}
void
destoryBindParams
(
TAOS_MULTI_BIND
*
pParams
,
int32_t
nParams
)
{
for
(
int32_t
i
=
0
;
i
<
nParams
;
++
i
)
{
TAOS_MULTI_BIND
*
pParam
=
pParams
+
i
;
taosMemoryFree
(
pParam
->
buffer
);
taosMemoryFree
(
pParam
->
length
);
taosMemoryFree
(
pParam
->
is_null
);
}
taosMemoryFree
(
pParams
);
}
TAOS_MULTI_BIND
*
buildIntegerParam
(
TAOS_MULTI_BIND
*
pBindParams
,
int32_t
index
,
int64_t
val
,
int32_t
type
)
{
TAOS_MULTI_BIND
*
pBindParam
=
initParam
(
pBindParams
,
index
,
type
,
0
);
...
...
@@ -127,8 +137,10 @@ TEST_F(PlanStmtTest, basic) {
useDb
(
"root"
,
"test"
);
prepare
(
"SELECT * FROM t1 WHERE c1 = ?"
);
bindParams
(
buildIntegerParam
(
createBindParams
(
1
),
0
,
10
,
TSDB_DATA_TYPE_INT
),
0
);
TAOS_MULTI_BIND
*
pBindParams
=
buildIntegerParam
(
createBindParams
(
1
),
0
,
10
,
TSDB_DATA_TYPE_INT
);
bindParams
(
pBindParams
,
0
);
exec
();
destoryBindParams
(
pBindParams
,
1
);
{
prepare
(
"SELECT * FROM t1 WHERE c1 = ? AND c2 = ?"
);
...
...
@@ -137,7 +149,7 @@ TEST_F(PlanStmtTest, basic) {
buildStringParam
(
pBindParams
,
1
,
"abc"
,
TSDB_DATA_TYPE_VARCHAR
,
strlen
(
"abc"
));
bindParams
(
pBindParams
,
-
1
);
exec
();
taosMemoryFreeClear
(
pBindParams
);
destoryBindParams
(
pBindParams
,
2
);
}
{
...
...
@@ -147,7 +159,7 @@ TEST_F(PlanStmtTest, basic) {
buildIntegerParam
(
pBindParams
,
1
,
20
,
TSDB_DATA_TYPE_INT
);
bindParams
(
pBindParams
,
-
1
);
exec
();
taosMemoryFreeClear
(
pBindParams
);
destoryBindParams
(
pBindParams
,
2
);
}
}
...
...
@@ -155,12 +167,16 @@ TEST_F(PlanStmtTest, multiExec) {
useDb
(
"root"
,
"test"
);
prepare
(
"SELECT * FROM t1 WHERE c1 = ?"
);
bindParams
(
buildIntegerParam
(
createBindParams
(
1
),
0
,
10
,
TSDB_DATA_TYPE_INT
),
0
);
TAOS_MULTI_BIND
*
pBindParams
=
buildIntegerParam
(
createBindParams
(
1
),
0
,
10
,
TSDB_DATA_TYPE_INT
);
bindParams
(
pBindParams
,
0
);
exec
();
bindParams
(
buildIntegerParam
(
createBindParams
(
1
),
0
,
20
,
TSDB_DATA_TYPE_INT
),
0
);
destoryBindParams
(
pBindParams
,
1
);
pBindParams
=
buildIntegerParam
(
createBindParams
(
1
),
0
,
20
,
TSDB_DATA_TYPE_INT
);
bindParams
(
pBindParams
,
0
);
exec
();
bindParams
(
buildIntegerParam
(
createBindParams
(
1
),
0
,
30
,
TSDB_DATA_TYPE_INT
),
0
);
destoryBindParams
(
pBindParams
,
1
);
pBindParams
=
buildIntegerParam
(
createBindParams
(
1
),
0
,
30
,
TSDB_DATA_TYPE_INT
);
bindParams
(
pBindParams
,
0
);
exec
();
destoryBindParams
(
pBindParams
,
1
);
}
TEST_F
(
PlanStmtTest
,
allDataType
)
{
useDb
(
"root"
,
"test"
);
}
source/libs/planner/test/planTestUtil.cpp
浏览文件 @
37ec05a7
...
...
@@ -126,9 +126,9 @@ class PlannerTestBaseImpl {
reset
();
tsQueryPolicy
=
queryPolicy
;
try
{
SQuery
*
pQuery
=
nullptr
;
doParseSql
(
sql
,
&
pQuery
);
unique_ptr
<
SQuery
,
void
(
*
)(
SQuery
*
)
>
query
(
pQuery
,
qDestroyQuery
);
unique_ptr
<
SQuery
*
,
void
(
*
)(
SQuery
**
)
>
query
((
SQuery
**
)
taosMemoryCalloc
(
1
,
sizeof
(
SQuery
*
)),
_destroyQuery
)
;
doParseSql
(
sql
,
query
.
get
()
);
SQuery
*
pQuery
=
*
(
query
.
get
()
);
SPlanContext
cxt
=
{
0
};
setPlanContext
(
pQuery
,
&
cxt
);
...
...
@@ -199,6 +199,8 @@ class PlannerTestBaseImpl {
SLogicSubplan
*
pLogicSubplan
=
nullptr
;
doCreateLogicPlan
(
&
cxt
,
&
pLogicSubplan
);
unique_ptr
<
SLogicSubplan
,
void
(
*
)(
SLogicSubplan
*
)
>
logicSubplan
(
pLogicSubplan
,
(
void
(
*
)(
SLogicSubplan
*
))
nodesDestroyNode
);
doOptimizeLogicPlan
(
&
cxt
,
pLogicSubplan
);
...
...
@@ -206,9 +208,12 @@ class PlannerTestBaseImpl {
SQueryLogicPlan
*
pLogicPlan
=
nullptr
;
doScaleOutLogicPlan
(
&
cxt
,
pLogicSubplan
,
&
pLogicPlan
);
unique_ptr
<
SQueryLogicPlan
,
void
(
*
)(
SQueryLogicPlan
*
)
>
logicPlan
(
pLogicPlan
,
(
void
(
*
)(
SQueryLogicPlan
*
))
nodesDestroyNode
);
SQueryPlan
*
pPlan
=
nullptr
;
doCreatePhysiPlan
(
&
cxt
,
pLogicPlan
,
&
pPlan
);
unique_ptr
<
SQueryPlan
,
void
(
*
)(
SQueryPlan
*
)
>
plan
(
pPlan
,
(
void
(
*
)(
SQueryPlan
*
))
nodesDestroyNode
);
dump
(
g_dumpModule
);
}
catch
(...)
{
...
...
@@ -249,6 +254,14 @@ class PlannerTestBaseImpl {
vector
<
string
>
physiSubplans_
;
};
static
void
_destroyQuery
(
SQuery
**
pQuery
)
{
if
(
nullptr
==
pQuery
)
{
return
;
}
qDestroyQuery
(
*
pQuery
);
taosMemoryFree
(
pQuery
);
}
void
reset
()
{
stmtEnv_
.
sql_
.
clear
();
stmtEnv_
.
msgBuf_
.
fill
(
0
);
...
...
@@ -400,20 +413,30 @@ class PlannerTestBaseImpl {
pCxt
->
queryId
=
1
;
pCxt
->
pUser
=
caseEnv_
.
user_
.
c_str
();
if
(
QUERY_NODE_CREATE_TOPIC_STMT
==
nodeType
(
pQuery
->
pRoot
))
{
pCxt
->
pAstRoot
=
((
SCreateTopicStmt
*
)
pQuery
->
pRoot
)
->
pQuery
;
SCreateTopicStmt
*
pStmt
=
(
SCreateTopicStmt
*
)
pQuery
->
pRoot
;
pCxt
->
pAstRoot
=
pStmt
->
pQuery
;
pStmt
->
pQuery
=
nullptr
;
nodesDestroyNode
(
pQuery
->
pRoot
);
pQuery
->
pRoot
=
pCxt
->
pAstRoot
;
pCxt
->
topicQuery
=
true
;
}
else
if
(
QUERY_NODE_CREATE_INDEX_STMT
==
nodeType
(
pQuery
->
pRoot
))
{
SMCreateSmaReq
req
=
{
0
};
tDeserializeSMCreateSmaReq
(
pQuery
->
pCmdMsg
->
pMsg
,
pQuery
->
pCmdMsg
->
msgLen
,
&
req
);
g_mockCatalogService
->
createSmaIndex
(
&
req
);
nodesStringToNode
(
req
.
ast
,
&
pCxt
->
pAstRoot
);
tFreeSMCreateSmaReq
(
&
req
);
nodesDestroyNode
(
pQuery
->
pRoot
);
pQuery
->
pRoot
=
pCxt
->
pAstRoot
;
pCxt
->
streamQuery
=
true
;
}
else
if
(
QUERY_NODE_CREATE_STREAM_STMT
==
nodeType
(
pQuery
->
pRoot
))
{
SCreateStreamStmt
*
pStmt
=
(
SCreateStreamStmt
*
)
pQuery
->
pRoot
;
pCxt
->
pAstRoot
=
pStmt
->
pQuery
;
pStmt
->
pQuery
=
nullptr
;
pCxt
->
streamQuery
=
true
;
pCxt
->
triggerType
=
pStmt
->
pOptions
->
triggerType
;
pCxt
->
watermark
=
(
NULL
!=
pStmt
->
pOptions
->
pWatermark
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pWatermark
)
->
datum
.
i
:
0
);
nodesDestroyNode
(
pQuery
->
pRoot
);
pQuery
->
pRoot
=
pCxt
->
pAstRoot
;
}
else
{
pCxt
->
pAstRoot
=
pQuery
->
pRoot
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录