fix: memory leak problems of parser and planner
This commit is contained in:
parent
763c95a076
commit
37ec05a715
|
@ -369,6 +369,8 @@ static void destroyPhysiNode(SPhysiNode* pNode) {
|
||||||
nodesDestroyList(pNode->pChildren);
|
nodesDestroyList(pNode->pChildren);
|
||||||
nodesDestroyNode(pNode->pConditions);
|
nodesDestroyNode(pNode->pConditions);
|
||||||
nodesDestroyNode((SNode*)pNode->pOutputDataBlockDesc);
|
nodesDestroyNode((SNode*)pNode->pOutputDataBlockDesc);
|
||||||
|
nodesDestroyNode(pNode->pLimit);
|
||||||
|
nodesDestroyNode(pNode->pSlimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroyWinodwPhysiNode(SWinodwPhysiNode* pNode) {
|
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 destroyExprNode(SExprNode* pExpr) { taosArrayDestroy(pExpr->pAssociation); }
|
||||||
|
|
||||||
static void nodesDestroyNodePointer(void* node) {
|
static void destroyTableCfg(STableCfg* pCfg) {
|
||||||
SNode* pNode = *(SNode**)node;
|
taosArrayDestroy(pCfg->pFuncs);
|
||||||
nodesDestroyNode(pNode);
|
taosMemoryFree(pCfg->pComment);
|
||||||
|
taosMemoryFree(pCfg->pSchemas);
|
||||||
|
taosMemoryFree(pCfg->pTags);
|
||||||
|
taosMemoryFree(pCfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void destroySmaIndex(void* pIndex) { taosMemoryFree(((STableIndexInfo*)pIndex)->expr); }
|
||||||
|
|
||||||
void nodesDestroyNode(SNode* pNode) {
|
void nodesDestroyNode(SNode* pNode) {
|
||||||
if (NULL == pNode) {
|
if (NULL == pNode) {
|
||||||
return;
|
return;
|
||||||
|
@ -431,6 +438,7 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
SRealTableNode* pReal = (SRealTableNode*)pNode;
|
SRealTableNode* pReal = (SRealTableNode*)pNode;
|
||||||
taosMemoryFreeClear(pReal->pMeta);
|
taosMemoryFreeClear(pReal->pMeta);
|
||||||
taosMemoryFreeClear(pReal->pVgroupList);
|
taosMemoryFreeClear(pReal->pVgroupList);
|
||||||
|
taosArrayDestroyEx(pReal->pSmaIndexes, destroySmaIndex);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_TEMP_TABLE:
|
case QUERY_NODE_TEMP_TABLE:
|
||||||
|
@ -451,9 +459,12 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_LIMIT: // no pointer field
|
case QUERY_NODE_LIMIT: // no pointer field
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_STATE_WINDOW:
|
case QUERY_NODE_STATE_WINDOW: {
|
||||||
nodesDestroyNode(((SStateWindowNode*)pNode)->pExpr);
|
SStateWindowNode* pState = (SStateWindowNode*)pNode;
|
||||||
|
nodesDestroyNode(pState->pCol);
|
||||||
|
nodesDestroyNode(pState->pExpr);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case QUERY_NODE_SESSION_WINDOW: {
|
case QUERY_NODE_SESSION_WINDOW: {
|
||||||
SSessionWindowNode* pSession = (SSessionWindowNode*)pNode;
|
SSessionWindowNode* pSession = (SSessionWindowNode*)pNode;
|
||||||
nodesDestroyNode((SNode*)pSession->pCol);
|
nodesDestroyNode((SNode*)pSession->pCol);
|
||||||
|
@ -500,8 +511,10 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
}
|
}
|
||||||
case QUERY_NODE_TABLE_OPTIONS: {
|
case QUERY_NODE_TABLE_OPTIONS: {
|
||||||
STableOptions* pOptions = (STableOptions*)pNode;
|
STableOptions* pOptions = (STableOptions*)pNode;
|
||||||
nodesDestroyList(pOptions->pSma);
|
nodesDestroyList(pOptions->pMaxDelay);
|
||||||
|
nodesDestroyList(pOptions->pWatermark);
|
||||||
nodesDestroyList(pOptions->pRollupFuncs);
|
nodesDestroyList(pOptions->pRollupFuncs);
|
||||||
|
nodesDestroyList(pOptions->pSma);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_INDEX_OPTIONS: {
|
case QUERY_NODE_INDEX_OPTIONS: {
|
||||||
|
@ -510,17 +523,22 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
nodesDestroyNode(pOptions->pInterval);
|
nodesDestroyNode(pOptions->pInterval);
|
||||||
nodesDestroyNode(pOptions->pOffset);
|
nodesDestroyNode(pOptions->pOffset);
|
||||||
nodesDestroyNode(pOptions->pSliding);
|
nodesDestroyNode(pOptions->pSliding);
|
||||||
|
nodesDestroyNode(pOptions->pStreamOptions);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_EXPLAIN_OPTIONS: // no pointer field
|
case QUERY_NODE_EXPLAIN_OPTIONS: // no pointer field
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_STREAM_OPTIONS:
|
case QUERY_NODE_STREAM_OPTIONS: {
|
||||||
nodesDestroyNode(((SStreamOptions*)pNode)->pWatermark);
|
SStreamOptions* pOptions = (SStreamOptions*)pNode;
|
||||||
|
nodesDestroyNode(pOptions->pDelay);
|
||||||
|
nodesDestroyNode(pOptions->pWatermark);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case QUERY_NODE_LEFT_VALUE: // no pointer field
|
case QUERY_NODE_LEFT_VALUE: // no pointer field
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_SET_OPERATOR: {
|
case QUERY_NODE_SET_OPERATOR: {
|
||||||
SSetOperator* pStmt = (SSetOperator*)pNode;
|
SSetOperator* pStmt = (SSetOperator*)pNode;
|
||||||
|
nodesDestroyList(pStmt->pProjectionList);
|
||||||
nodesDestroyNode(pStmt->pLeft);
|
nodesDestroyNode(pStmt->pLeft);
|
||||||
nodesDestroyNode(pStmt->pRight);
|
nodesDestroyNode(pStmt->pRight);
|
||||||
nodesDestroyList(pStmt->pOrderByList);
|
nodesDestroyList(pStmt->pOrderByList);
|
||||||
|
@ -582,7 +600,8 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_DROP_SUPER_TABLE_STMT: // no pointer field
|
case QUERY_NODE_DROP_SUPER_TABLE_STMT: // no pointer field
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_ALTER_TABLE_STMT: {
|
case QUERY_NODE_ALTER_TABLE_STMT:
|
||||||
|
case QUERY_NODE_ALTER_SUPER_TABLE_STMT: {
|
||||||
SAlterTableStmt* pStmt = (SAlterTableStmt*)pNode;
|
SAlterTableStmt* pStmt = (SAlterTableStmt*)pNode;
|
||||||
nodesDestroyNode((SNode*)pStmt->pOptions);
|
nodesDestroyNode((SNode*)pStmt->pOptions);
|
||||||
nodesDestroyNode((SNode*)pStmt->pVal);
|
nodesDestroyNode((SNode*)pStmt->pVal);
|
||||||
|
@ -686,14 +705,15 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
nodesDestroyNode(pStmt->pTbName);
|
nodesDestroyNode(pStmt->pTbName);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT: // no pointer field
|
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
||||||
|
nodesDestroyNode(((SShowDnodeVariablesStmt*)pNode)->pDnodeId);
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
|
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
|
||||||
taosMemoryFreeClear(((SShowCreateDatabaseStmt*)pNode)->pCfg);
|
taosMemoryFreeClear(((SShowCreateDatabaseStmt*)pNode)->pCfg);
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
|
case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
|
||||||
case QUERY_NODE_SHOW_CREATE_STABLE_STMT:
|
case QUERY_NODE_SHOW_CREATE_STABLE_STMT:
|
||||||
taosMemoryFreeClear(((SShowCreateTableStmt*)pNode)->pCfg);
|
destroyTableCfg((STableCfg*)(((SShowCreateTableStmt*)pNode)->pCfg));
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT: // no pointer field
|
case QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT: // no pointer field
|
||||||
case QUERY_NODE_KILL_CONNECTION_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->pDbList);
|
||||||
taosArrayDestroy(pQuery->pTableList);
|
taosArrayDestroy(pQuery->pTableList);
|
||||||
taosArrayDestroyEx(pQuery->pPlaceholderValues, nodesDestroyNodePointer);
|
taosArrayDestroy(pQuery->pPlaceholderValues);
|
||||||
|
nodesDestroyNode(pQuery->pPrepareRoot);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_LOGIC_PLAN_SCAN: {
|
case QUERY_NODE_LOGIC_PLAN_SCAN: {
|
||||||
|
@ -737,7 +758,7 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
nodesDestroyList(pLogicNode->pDynamicScanFuncs);
|
nodesDestroyList(pLogicNode->pDynamicScanFuncs);
|
||||||
nodesDestroyNode(pLogicNode->pTagCond);
|
nodesDestroyNode(pLogicNode->pTagCond);
|
||||||
nodesDestroyNode(pLogicNode->pTagIndexCond);
|
nodesDestroyNode(pLogicNode->pTagIndexCond);
|
||||||
taosArrayDestroy(pLogicNode->pSmaIndexes);
|
taosArrayDestroyEx(pLogicNode->pSmaIndexes, destroySmaIndex);
|
||||||
nodesDestroyList(pLogicNode->pGroupTags);
|
nodesDestroyList(pLogicNode->pGroupTags);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -766,6 +787,9 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
destroyLogicNode((SLogicNode*)pLogicNode);
|
destroyLogicNode((SLogicNode*)pLogicNode);
|
||||||
destroyVgDataBlockArray(pLogicNode->pDataBlocks);
|
destroyVgDataBlockArray(pLogicNode->pDataBlocks);
|
||||||
// pVgDataBlocks is weak reference
|
// pVgDataBlocks is weak reference
|
||||||
|
nodesDestroyNode(pLogicNode->pAffectedRows);
|
||||||
|
taosMemoryFreeClear(pLogicNode->pVgroupList);
|
||||||
|
nodesDestroyList(pLogicNode->pInsertCols);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_LOGIC_PLAN_EXCHANGE:
|
case QUERY_NODE_LOGIC_PLAN_EXCHANGE:
|
||||||
|
@ -784,6 +808,7 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
nodesDestroyList(pLogicNode->pFuncs);
|
nodesDestroyList(pLogicNode->pFuncs);
|
||||||
nodesDestroyNode(pLogicNode->pTspk);
|
nodesDestroyNode(pLogicNode->pTspk);
|
||||||
nodesDestroyNode(pLogicNode->pTsEnd);
|
nodesDestroyNode(pLogicNode->pTsEnd);
|
||||||
|
nodesDestroyNode(pLogicNode->pStateExpr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_LOGIC_PLAN_FILL: {
|
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_TAG_SCAN:
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN:
|
case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN:
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN:
|
case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN:
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN:
|
|
||||||
destroyScanPhysiNode((SScanPhysiNode*)pNode);
|
destroyScanPhysiNode((SScanPhysiNode*)pNode);
|
||||||
break;
|
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_SCAN:
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN:
|
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN:
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN:
|
case QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN:
|
||||||
|
|
|
@ -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); }
|
explain_options(A) ::= explain_options(B) RATIO NK_FLOAT(C). { A = setExplainRatio(pCxt, B, &C); }
|
||||||
|
|
||||||
/************************************************ compact *************************************************************/
|
/************************************************ 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 ************************************************/
|
/************************************************ create/drop function ************************************************/
|
||||||
cmd ::= CREATE agg_func_opt(A) FUNCTION not_exists_opt(F) function_name(B)
|
cmd ::= CREATE agg_func_opt(A) FUNCTION not_exists_opt(F) function_name(B)
|
||||||
|
|
|
@ -387,6 +387,19 @@ SNode* createLogicConditionNode(SAstCreateContext* pCxt, ELogicConditionType typ
|
||||||
return (SNode*)cond;
|
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) {
|
SNode* createOperatorNode(SAstCreateContext* pCxt, EOperatorType type, SNode* pLeft, SNode* pRight) {
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
if (OP_TYPE_MINUS == type && QUERY_NODE_VALUE == nodeType(pLeft)) {
|
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);
|
taosMemoryFree(pVal->literal);
|
||||||
pVal->literal = pNewLiteral;
|
pVal->literal = pNewLiteral;
|
||||||
pVal->node.resType.type = TSDB_DATA_TYPE_BIGINT;
|
pVal->node.resType.type = getMinusDataType(pVal->node.resType.type);
|
||||||
return pLeft;
|
return pLeft;
|
||||||
}
|
}
|
||||||
SOperatorNode* op = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR);
|
SOperatorNode* op = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR);
|
||||||
|
|
|
@ -1257,6 +1257,7 @@ static int32_t rewriteFuncToValue(STranslateContext* pCxt, char* pLiteral, SNode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (DEAL_RES_ERROR != translateValue(pCxt, pVal)) {
|
if (DEAL_RES_ERROR != translateValue(pCxt, pVal)) {
|
||||||
|
nodesDestroyNode(*pNode);
|
||||||
*pNode = (SNode*)pVal;
|
*pNode = (SNode*)pVal;
|
||||||
} else {
|
} else {
|
||||||
nodesDestroyNode((SNode*)pVal);
|
nodesDestroyNode((SNode*)pVal);
|
||||||
|
@ -4009,30 +4010,7 @@ static SSchema* getTagSchema(STableMeta* pTableMeta, const char* pTagName) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkAlterSuperTable(STranslateContext* pCxt, SAlterTableStmt* pStmt) {
|
static int32_t checkAlterSuperTableImpl(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta) {
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
SSchema* pTagsSchema = getTableTagSchema(pTableMeta);
|
SSchema* pTagsSchema = getTableTagSchema(pTableMeta);
|
||||||
if (getNumOfTags(pTableMeta) == 1 && pTagsSchema->type == TSDB_DATA_TYPE_JSON &&
|
if (getNumOfTags(pTableMeta) == 1 && pTagsSchema->type == TSDB_DATA_TYPE_JSON &&
|
||||||
(pStmt->alterType == TSDB_ALTER_TABLE_ADD_TAG || pStmt->alterType == TSDB_ALTER_TABLE_DROP_TAG ||
|
(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;
|
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) {
|
static int32_t translateAlterSuperTable(STranslateContext* pCxt, SAlterTableStmt* pStmt) {
|
||||||
SMAlterStbReq alterReq = {0};
|
SMAlterStbReq alterReq = {0};
|
||||||
int32_t code = checkAlterSuperTable(pCxt, pStmt);
|
int32_t code = checkAlterSuperTable(pCxt, pStmt);
|
||||||
|
@ -6438,6 +6443,7 @@ static int32_t toMsgType(ENodeType type) {
|
||||||
|
|
||||||
static int32_t setRefreshMate(STranslateContext* pCxt, SQuery* pQuery) {
|
static int32_t setRefreshMate(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
if (NULL != pCxt->pDbs) {
|
if (NULL != pCxt->pDbs) {
|
||||||
|
taosArrayDestroy(pQuery->pDbList);
|
||||||
pQuery->pDbList = taosArrayInit(taosHashGetSize(pCxt->pDbs), TSDB_DB_FNAME_LEN);
|
pQuery->pDbList = taosArrayInit(taosHashGetSize(pCxt->pDbs), TSDB_DB_FNAME_LEN);
|
||||||
if (NULL == pQuery->pDbList) {
|
if (NULL == pQuery->pDbList) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -6450,6 +6456,7 @@ static int32_t setRefreshMate(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL != pCxt->pTables) {
|
if (NULL != pCxt->pTables) {
|
||||||
|
taosArrayDestroy(pQuery->pTableList);
|
||||||
pQuery->pTableList = taosArrayInit(taosHashGetSize(pCxt->pTables), sizeof(SName));
|
pQuery->pTableList = taosArrayInit(taosHashGetSize(pCxt->pTables), sizeof(SName));
|
||||||
if (NULL == pQuery->pTableList) {
|
if (NULL == pQuery->pTableList) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -6521,6 +6528,7 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
pQuery->stableQuery = pCxt->stableQuery;
|
pQuery->stableQuery = pCxt->stableQuery;
|
||||||
|
|
||||||
if (pQuery->haveResultSet) {
|
if (pQuery->haveResultSet) {
|
||||||
|
taosMemoryFreeClear(pQuery->pResSchema);
|
||||||
if (TSDB_CODE_SUCCESS != extractResultSchema(pQuery->pRoot, &pQuery->numOfResCols, &pQuery->pResSchema)) {
|
if (TSDB_CODE_SUCCESS != extractResultSchema(pQuery->pRoot, &pQuery->numOfResCols, &pQuery->pResSchema)) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)) {
|
if (TSDB_CODE_SUCCESS == code && (colIdx < 0 || colIdx + 1 == pQuery->placeholderNum)) {
|
||||||
|
nodesDestroyNode(pQuery->pRoot);
|
||||||
pQuery->pRoot = nodesCloneNode(pQuery->pPrepareRoot);
|
pQuery->pRoot = nodesCloneNode(pQuery->pPrepareRoot);
|
||||||
if (NULL == pQuery->pRoot) {
|
if (NULL == pQuery->pRoot) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
|
@ -4117,7 +4117,8 @@ static YYACTIONTYPE yy_reduce(
|
||||||
yymsp[-2].minor.yy616 = yylhsminor.yy616;
|
yymsp[-2].minor.yy616 = yylhsminor.yy616;
|
||||||
break;
|
break;
|
||||||
case 254: /* cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */
|
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;
|
break;
|
||||||
case 255: /* cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */
|
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); }
|
{ 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); }
|
||||||
|
|
|
@ -93,6 +93,17 @@ class MockCatalogServiceImpl {
|
||||||
|
|
||||||
MockCatalogServiceImpl() : id_(1) {}
|
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 catalogGetHandle() const { return 0; }
|
||||||
|
|
||||||
int32_t catalogGetTableMeta(const SName* pTableName, STableMeta** pTableMeta) const {
|
int32_t catalogGetTableMeta(const SName* pTableName, STableMeta** pTableMeta) const {
|
||||||
|
@ -676,6 +687,7 @@ void MockCatalogService::destoryCatalogReq(SCatalogReq* pReq) {
|
||||||
taosArrayDestroy(pReq->pIndex);
|
taosArrayDestroy(pReq->pIndex);
|
||||||
taosArrayDestroy(pReq->pUser);
|
taosArrayDestroy(pReq->pUser);
|
||||||
taosArrayDestroy(pReq->pTableIndex);
|
taosArrayDestroy(pReq->pTableIndex);
|
||||||
|
taosArrayDestroy(pReq->pTableCfg);
|
||||||
delete pReq;
|
delete pReq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -684,6 +696,11 @@ void MockCatalogService::destoryMetaRes(void* p) {
|
||||||
taosMemoryFree(pRes->pRes);
|
taosMemoryFree(pRes->pRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MockCatalogService::destoryMetaArrayRes(void* p) {
|
||||||
|
SMetaRes* pRes = (SMetaRes*)p;
|
||||||
|
taosArrayDestroy((SArray*)pRes->pRes);
|
||||||
|
}
|
||||||
|
|
||||||
void MockCatalogService::destoryMetaData(SMetaData* pData) {
|
void MockCatalogService::destoryMetaData(SMetaData* pData) {
|
||||||
taosArrayDestroyEx(pData->pDbVgroup, destoryMetaRes);
|
taosArrayDestroyEx(pData->pDbVgroup, destoryMetaRes);
|
||||||
taosArrayDestroyEx(pData->pDbCfg, destoryMetaRes);
|
taosArrayDestroyEx(pData->pDbCfg, destoryMetaRes);
|
||||||
|
@ -695,5 +712,8 @@ void MockCatalogService::destoryMetaData(SMetaData* pData) {
|
||||||
taosArrayDestroyEx(pData->pIndex, destoryMetaRes);
|
taosArrayDestroyEx(pData->pIndex, destoryMetaRes);
|
||||||
taosArrayDestroyEx(pData->pUser, destoryMetaRes);
|
taosArrayDestroyEx(pData->pUser, destoryMetaRes);
|
||||||
taosArrayDestroyEx(pData->pQnodeList, destoryMetaRes);
|
taosArrayDestroyEx(pData->pQnodeList, destoryMetaRes);
|
||||||
|
taosArrayDestroyEx(pData->pTableCfg, destoryMetaRes);
|
||||||
|
taosArrayDestroyEx(pData->pDnodeList, destoryMetaArrayRes);
|
||||||
|
taosMemoryFree(pData->pSvrVer);
|
||||||
delete pData;
|
delete pData;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,7 @@ class MockCatalogService {
|
||||||
public:
|
public:
|
||||||
static void destoryCatalogReq(SCatalogReq* pReq);
|
static void destoryCatalogReq(SCatalogReq* pReq);
|
||||||
static void destoryMetaRes(void* p);
|
static void destoryMetaRes(void* p);
|
||||||
|
static void destoryMetaArrayRes(void* p);
|
||||||
static void destoryMetaData(SMetaData* pData);
|
static void destoryMetaData(SMetaData* pData);
|
||||||
|
|
||||||
MockCatalogService();
|
MockCatalogService();
|
||||||
|
|
|
@ -21,7 +21,11 @@ namespace ParserTest {
|
||||||
|
|
||||||
class ParserInitialCTest : public ParserDdlTest {};
|
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) {
|
TEST_F(ParserInitialCTest, createAccount) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
@ -32,6 +36,19 @@ TEST_F(ParserInitialCTest, createAccount) {
|
||||||
TEST_F(ParserInitialCTest, createBnode) {
|
TEST_F(ParserInitialCTest, createBnode) {
|
||||||
useDb("root", "test");
|
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");
|
run("CREATE BNODE ON DNODE 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,6 +123,14 @@ class ParserTestBaseImpl {
|
||||||
delete pMetaCache;
|
delete pMetaCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void _destroyQuery(SQuery** pQuery) {
|
||||||
|
if (nullptr == pQuery) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
qDestroyQuery(*pQuery);
|
||||||
|
taosMemoryFree(pQuery);
|
||||||
|
}
|
||||||
|
|
||||||
bool checkResultCode(const string& pFunc, int32_t resultCode) {
|
bool checkResultCode(const string& pFunc, int32_t resultCode) {
|
||||||
return !(stmtEnv_.checkFunc_.empty())
|
return !(stmtEnv_.checkFunc_.empty())
|
||||||
? ((stmtEnv_.checkFunc_ == pFunc) ? stmtEnv_.expect_ == resultCode : TSDB_CODE_SUCCESS == resultCode)
|
? ((stmtEnv_.checkFunc_ == pFunc) ? stmtEnv_.expect_ == resultCode : TSDB_CODE_SUCCESS == resultCode)
|
||||||
|
@ -278,9 +286,9 @@ class ParserTestBaseImpl {
|
||||||
SParseContext cxt = {0};
|
SParseContext cxt = {0};
|
||||||
setParseContext(sql, &cxt);
|
setParseContext(sql, &cxt);
|
||||||
|
|
||||||
SQuery* pQuery = nullptr;
|
unique_ptr<SQuery*, void (*)(SQuery**)> query((SQuery**)taosMemoryCalloc(1, sizeof(SQuery*)), _destroyQuery);
|
||||||
doParse(&cxt, &pQuery);
|
doParse(&cxt, query.get());
|
||||||
unique_ptr<SQuery, void (*)(SQuery*)> query(pQuery, qDestroyQuery);
|
SQuery* pQuery = *(query.get());
|
||||||
|
|
||||||
doAuthenticate(&cxt, pQuery, nullptr);
|
doAuthenticate(&cxt, pQuery, nullptr);
|
||||||
|
|
||||||
|
@ -306,9 +314,9 @@ class ParserTestBaseImpl {
|
||||||
SParseContext cxt = {0};
|
SParseContext cxt = {0};
|
||||||
setParseContext(sql, &cxt);
|
setParseContext(sql, &cxt);
|
||||||
|
|
||||||
SQuery* pQuery = nullptr;
|
unique_ptr<SQuery*, void (*)(SQuery**)> query((SQuery**)taosMemoryCalloc(1, sizeof(SQuery*)), _destroyQuery);
|
||||||
doParseSql(&cxt, &pQuery);
|
doParseSql(&cxt, query.get());
|
||||||
unique_ptr<SQuery, void (*)(SQuery*)> query(pQuery, qDestroyQuery);
|
SQuery* pQuery = *(query.get());
|
||||||
|
|
||||||
if (g_dump) {
|
if (g_dump) {
|
||||||
dump();
|
dump();
|
||||||
|
@ -328,9 +336,9 @@ class ParserTestBaseImpl {
|
||||||
SParseContext cxt = {0};
|
SParseContext cxt = {0};
|
||||||
setParseContext(sql, &cxt, true);
|
setParseContext(sql, &cxt, true);
|
||||||
|
|
||||||
SQuery* pQuery = nullptr;
|
unique_ptr<SQuery*, void (*)(SQuery**)> query((SQuery**)taosMemoryCalloc(1, sizeof(SQuery*)), _destroyQuery);
|
||||||
doParse(&cxt, &pQuery);
|
doParse(&cxt, query.get());
|
||||||
unique_ptr<SQuery, void (*)(SQuery*)> query(pQuery, qDestroyQuery);
|
SQuery* pQuery = *(query.get());
|
||||||
|
|
||||||
unique_ptr<SParseMetaCache, void (*)(SParseMetaCache*)> metaCache(new SParseMetaCache(), _destoryParseMetaCache);
|
unique_ptr<SParseMetaCache, void (*)(SParseMetaCache*)> metaCache(new SParseMetaCache(), _destoryParseMetaCache);
|
||||||
doCollectMetaKey(&cxt, pQuery, metaCache.get());
|
doCollectMetaKey(&cxt, pQuery, metaCache.get());
|
||||||
|
@ -386,9 +394,9 @@ class ParserTestBaseImpl {
|
||||||
|
|
||||||
unique_ptr<SCatalogReq, void (*)(SCatalogReq*)> catalogReq(new SCatalogReq(),
|
unique_ptr<SCatalogReq, void (*)(SCatalogReq*)> catalogReq(new SCatalogReq(),
|
||||||
MockCatalogService::destoryCatalogReq);
|
MockCatalogService::destoryCatalogReq);
|
||||||
SQuery* pQuery = nullptr;
|
unique_ptr<SQuery*, void (*)(SQuery**)> query((SQuery**)taosMemoryCalloc(1, sizeof(SQuery*)), _destroyQuery);
|
||||||
doParseSqlSyntax(&cxt, &pQuery, catalogReq.get());
|
doParseSqlSyntax(&cxt, query.get(), catalogReq.get());
|
||||||
unique_ptr<SQuery, void (*)(SQuery*)> query(pQuery, qDestroyQuery);
|
SQuery* pQuery = *(query.get());
|
||||||
|
|
||||||
string err;
|
string err;
|
||||||
thread t1([&]() {
|
thread t1([&]() {
|
||||||
|
|
|
@ -1068,7 +1068,11 @@ static int32_t createExchangePhysiNode(SPhysiPlanContext* pCxt, SExchangeLogicNo
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createWindowPhysiNodeFinalize(SPhysiPlanContext* pCxt, SNodeList* pChildren, SWinodwPhysiNode* pWindow,
|
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* pPrecalcExprs = NULL;
|
||||||
SNodeList* pFuncs = NULL;
|
SNodeList* pFuncs = NULL;
|
||||||
int32_t code = rewritePrecalcExprs(pCxt, pWindowLogicNode->pFuncs, &pPrecalcExprs, &pFuncs);
|
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);
|
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(pPrecalcExprs);
|
||||||
nodesDestroyList(pFuncs);
|
nodesDestroyList(pFuncs);
|
||||||
|
|
||||||
|
@ -1156,7 +1150,14 @@ static int32_t createIntervalPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChil
|
||||||
pInterval->intervalUnit = pWindowLogicNode->intervalUnit;
|
pInterval->intervalUnit = pWindowLogicNode->intervalUnit;
|
||||||
pInterval->slidingUnit = pWindowLogicNode->slidingUnit;
|
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,
|
static int32_t createSessionWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
|
||||||
|
@ -1169,7 +1170,14 @@ static int32_t createSessionWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList*
|
||||||
|
|
||||||
pSession->gap = pWindowLogicNode->sessionGap;
|
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,
|
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) {
|
||||||
nodesDestroyNode((SNode*)pState);
|
code = createWindowPhysiNodeFinalize(pCxt, pChildren, &pState->window, pWindowLogicNode);
|
||||||
return code;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return createWindowPhysiNodeFinalize(pCxt, pChildren, &pState->window, pWindowLogicNode, pPhyNode);
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
*pPhyNode = (SPhysiNode*)pState;
|
||||||
|
} else {
|
||||||
|
nodesDestroyNode((SNode*)pState);
|
||||||
|
}
|
||||||
|
|
||||||
|
nodesDestroyList(pPrecalcExprs);
|
||||||
|
nodesDestroyNode(pStateKey);
|
||||||
|
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SWindowLogicNode* pWindowLogicNode,
|
static int32_t createWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SWindowLogicNode* pWindowLogicNode,
|
||||||
|
|
|
@ -867,10 +867,11 @@ static int32_t stbSplSplitSortNode(SSplitContext* pCxt, SStableSplitInfo* pInfo)
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = stbSplCreateMergeNode(pCxt, pInfo->pSubplan, pInfo->pSplitNode, pMergeKeys, pPartSort, groupSort);
|
code = stbSplCreateMergeNode(pCxt, pInfo->pSubplan, pInfo->pSplitNode, pMergeKeys, pPartSort, groupSort);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code && groupSort) {
|
|
||||||
stbSplSetScanPartSort(pPartSort);
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
nodesDestroyNode((SNode*)pInfo->pSplitNode);
|
||||||
|
if (groupSort) {
|
||||||
|
stbSplSetScanPartSort(pPartSort);
|
||||||
|
}
|
||||||
code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren,
|
code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren,
|
||||||
(SNode*)splCreateScanSubplan(pCxt, pPartSort, SPLIT_FLAG_STABLE_SPLIT));
|
(SNode*)splCreateScanSubplan(pCxt, pPartSort, SPLIT_FLAG_STABLE_SPLIT));
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,16 @@ class PlanStmtTest : public PlannerTestBase {
|
||||||
return (TAOS_MULTI_BIND*)taosMemoryCalloc(nParams, sizeof(TAOS_MULTI_BIND));
|
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* buildIntegerParam(TAOS_MULTI_BIND* pBindParams, int32_t index, int64_t val, int32_t type) {
|
||||||
TAOS_MULTI_BIND* pBindParam = initParam(pBindParams, index, type, 0);
|
TAOS_MULTI_BIND* pBindParam = initParam(pBindParams, index, type, 0);
|
||||||
|
|
||||||
|
@ -127,8 +137,10 @@ TEST_F(PlanStmtTest, basic) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
prepare("SELECT * FROM t1 WHERE c1 = ?");
|
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();
|
exec();
|
||||||
|
destoryBindParams(pBindParams, 1);
|
||||||
|
|
||||||
{
|
{
|
||||||
prepare("SELECT * FROM t1 WHERE c1 = ? AND c2 = ?");
|
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"));
|
buildStringParam(pBindParams, 1, "abc", TSDB_DATA_TYPE_VARCHAR, strlen("abc"));
|
||||||
bindParams(pBindParams, -1);
|
bindParams(pBindParams, -1);
|
||||||
exec();
|
exec();
|
||||||
taosMemoryFreeClear(pBindParams);
|
destoryBindParams(pBindParams, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -147,7 +159,7 @@ TEST_F(PlanStmtTest, basic) {
|
||||||
buildIntegerParam(pBindParams, 1, 20, TSDB_DATA_TYPE_INT);
|
buildIntegerParam(pBindParams, 1, 20, TSDB_DATA_TYPE_INT);
|
||||||
bindParams(pBindParams, -1);
|
bindParams(pBindParams, -1);
|
||||||
exec();
|
exec();
|
||||||
taosMemoryFreeClear(pBindParams);
|
destoryBindParams(pBindParams, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,12 +167,16 @@ TEST_F(PlanStmtTest, multiExec) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
prepare("SELECT * FROM t1 WHERE c1 = ?");
|
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();
|
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();
|
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();
|
exec();
|
||||||
|
destoryBindParams(pBindParams, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PlanStmtTest, allDataType) { useDb("root", "test"); }
|
|
||||||
|
|
|
@ -126,9 +126,9 @@ class PlannerTestBaseImpl {
|
||||||
reset();
|
reset();
|
||||||
tsQueryPolicy = queryPolicy;
|
tsQueryPolicy = queryPolicy;
|
||||||
try {
|
try {
|
||||||
SQuery* pQuery = nullptr;
|
unique_ptr<SQuery*, void (*)(SQuery**)> query((SQuery**)taosMemoryCalloc(1, sizeof(SQuery*)), _destroyQuery);
|
||||||
doParseSql(sql, &pQuery);
|
doParseSql(sql, query.get());
|
||||||
unique_ptr<SQuery, void (*)(SQuery*)> query(pQuery, qDestroyQuery);
|
SQuery* pQuery = *(query.get());
|
||||||
|
|
||||||
SPlanContext cxt = {0};
|
SPlanContext cxt = {0};
|
||||||
setPlanContext(pQuery, &cxt);
|
setPlanContext(pQuery, &cxt);
|
||||||
|
@ -199,6 +199,8 @@ class PlannerTestBaseImpl {
|
||||||
|
|
||||||
SLogicSubplan* pLogicSubplan = nullptr;
|
SLogicSubplan* pLogicSubplan = nullptr;
|
||||||
doCreateLogicPlan(&cxt, &pLogicSubplan);
|
doCreateLogicPlan(&cxt, &pLogicSubplan);
|
||||||
|
unique_ptr<SLogicSubplan, void (*)(SLogicSubplan*)> logicSubplan(pLogicSubplan,
|
||||||
|
(void (*)(SLogicSubplan*))nodesDestroyNode);
|
||||||
|
|
||||||
doOptimizeLogicPlan(&cxt, pLogicSubplan);
|
doOptimizeLogicPlan(&cxt, pLogicSubplan);
|
||||||
|
|
||||||
|
@ -206,9 +208,12 @@ class PlannerTestBaseImpl {
|
||||||
|
|
||||||
SQueryLogicPlan* pLogicPlan = nullptr;
|
SQueryLogicPlan* pLogicPlan = nullptr;
|
||||||
doScaleOutLogicPlan(&cxt, pLogicSubplan, &pLogicPlan);
|
doScaleOutLogicPlan(&cxt, pLogicSubplan, &pLogicPlan);
|
||||||
|
unique_ptr<SQueryLogicPlan, void (*)(SQueryLogicPlan*)> logicPlan(pLogicPlan,
|
||||||
|
(void (*)(SQueryLogicPlan*))nodesDestroyNode);
|
||||||
|
|
||||||
SQueryPlan* pPlan = nullptr;
|
SQueryPlan* pPlan = nullptr;
|
||||||
doCreatePhysiPlan(&cxt, pLogicPlan, &pPlan);
|
doCreatePhysiPlan(&cxt, pLogicPlan, &pPlan);
|
||||||
|
unique_ptr<SQueryPlan, void (*)(SQueryPlan*)> plan(pPlan, (void (*)(SQueryPlan*))nodesDestroyNode);
|
||||||
|
|
||||||
dump(g_dumpModule);
|
dump(g_dumpModule);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
@ -249,6 +254,14 @@ class PlannerTestBaseImpl {
|
||||||
vector<string> physiSubplans_;
|
vector<string> physiSubplans_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void _destroyQuery(SQuery** pQuery) {
|
||||||
|
if (nullptr == pQuery) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
qDestroyQuery(*pQuery);
|
||||||
|
taosMemoryFree(pQuery);
|
||||||
|
}
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
stmtEnv_.sql_.clear();
|
stmtEnv_.sql_.clear();
|
||||||
stmtEnv_.msgBuf_.fill(0);
|
stmtEnv_.msgBuf_.fill(0);
|
||||||
|
@ -400,20 +413,30 @@ class PlannerTestBaseImpl {
|
||||||
pCxt->queryId = 1;
|
pCxt->queryId = 1;
|
||||||
pCxt->pUser = caseEnv_.user_.c_str();
|
pCxt->pUser = caseEnv_.user_.c_str();
|
||||||
if (QUERY_NODE_CREATE_TOPIC_STMT == nodeType(pQuery->pRoot)) {
|
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;
|
pCxt->topicQuery = true;
|
||||||
} else if (QUERY_NODE_CREATE_INDEX_STMT == nodeType(pQuery->pRoot)) {
|
} else if (QUERY_NODE_CREATE_INDEX_STMT == nodeType(pQuery->pRoot)) {
|
||||||
SMCreateSmaReq req = {0};
|
SMCreateSmaReq req = {0};
|
||||||
tDeserializeSMCreateSmaReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req);
|
tDeserializeSMCreateSmaReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req);
|
||||||
g_mockCatalogService->createSmaIndex(&req);
|
g_mockCatalogService->createSmaIndex(&req);
|
||||||
nodesStringToNode(req.ast, &pCxt->pAstRoot);
|
nodesStringToNode(req.ast, &pCxt->pAstRoot);
|
||||||
|
tFreeSMCreateSmaReq(&req);
|
||||||
|
nodesDestroyNode(pQuery->pRoot);
|
||||||
|
pQuery->pRoot = pCxt->pAstRoot;
|
||||||
pCxt->streamQuery = true;
|
pCxt->streamQuery = true;
|
||||||
} else if (QUERY_NODE_CREATE_STREAM_STMT == nodeType(pQuery->pRoot)) {
|
} else if (QUERY_NODE_CREATE_STREAM_STMT == nodeType(pQuery->pRoot)) {
|
||||||
SCreateStreamStmt* pStmt = (SCreateStreamStmt*)pQuery->pRoot;
|
SCreateStreamStmt* pStmt = (SCreateStreamStmt*)pQuery->pRoot;
|
||||||
pCxt->pAstRoot = pStmt->pQuery;
|
pCxt->pAstRoot = pStmt->pQuery;
|
||||||
|
pStmt->pQuery = nullptr;
|
||||||
pCxt->streamQuery = true;
|
pCxt->streamQuery = true;
|
||||||
pCxt->triggerType = pStmt->pOptions->triggerType;
|
pCxt->triggerType = pStmt->pOptions->triggerType;
|
||||||
pCxt->watermark = (NULL != pStmt->pOptions->pWatermark ? ((SValueNode*)pStmt->pOptions->pWatermark)->datum.i : 0);
|
pCxt->watermark = (NULL != pStmt->pOptions->pWatermark ? ((SValueNode*)pStmt->pOptions->pWatermark)->datum.i : 0);
|
||||||
|
nodesDestroyNode(pQuery->pRoot);
|
||||||
|
pQuery->pRoot = pCxt->pAstRoot;
|
||||||
} else {
|
} else {
|
||||||
pCxt->pAstRoot = pQuery->pRoot;
|
pCxt->pAstRoot = pQuery->pRoot;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue