From b2fea84a3a28dc3888f36710aea30d73a013a5b6 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Mon, 30 Oct 2023 19:14:31 +0800 Subject: [PATCH] fix: case issue and bugs --- source/libs/parser/inc/parInt.h | 2 +- source/libs/parser/src/parAstParser.c | 16 +++++++++++++--- source/libs/parser/src/parTranslater.c | 2 +- source/libs/planner/src/planLogicCreater.c | 2 ++ tests/develop-test/2-query/table_count_scan.py | 2 +- tests/script/tsim/query/sys_tbname.sim | 2 +- tests/script/tsim/query/tableCount.sim | 6 +++--- tests/script/tsim/view/show_desc_view.sim | 5 +---- 8 files changed, 23 insertions(+), 14 deletions(-) diff --git a/source/libs/parser/inc/parInt.h b/source/libs/parser/inc/parInt.h index bc37a1a6fb..a4a7812474 100644 --- a/source/libs/parser/inc/parInt.h +++ b/source/libs/parser/inc/parInt.h @@ -37,7 +37,7 @@ int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pS int32_t calculateConstant(SParseContext* pParseCxt, SQuery* pQuery); int32_t translatePostCreateStream(SParseContext* pParseCxt, SQuery* pQuery, void** pResRow); int32_t translatePostCreateSmaIndex(SParseContext* pParseCxt, SQuery* pQuery, void** pResRow); -int32_t buildQueryAfterParse(SQuery** pQuery, SNode* pRootNode, int16_t placeholderNo, SArray* pPlaceholderValues); +int32_t buildQueryAfterParse(SQuery** pQuery, SNode* pRootNode, int16_t placeholderNo, SArray** pPlaceholderValues); int32_t translateTable(STranslateContext* pCxt, SNode** pTable); int32_t getMetaDataFromHash(const char* pKey, int32_t len, SHashObj* pHash, void** pOutput); void tfreeSParseQueryRes(void* p); diff --git a/source/libs/parser/src/parAstParser.c b/source/libs/parser/src/parAstParser.c index d16e014d19..91625defd0 100644 --- a/source/libs/parser/src/parAstParser.c +++ b/source/libs/parser/src/parAstParser.c @@ -29,14 +29,14 @@ extern void Parse(void*, int, SToken, void*); extern void ParseFree(void*, FFree); extern void ParseTrace(FILE*, char*); -int32_t buildQueryAfterParse(SQuery** pQuery, SNode* pRootNode, int16_t placeholderNo, SArray* pPlaceholderValues) { +int32_t buildQueryAfterParse(SQuery** pQuery, SNode* pRootNode, int16_t placeholderNo, SArray** pPlaceholderValues) { *pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY); if (NULL == *pQuery) { return TSDB_CODE_OUT_OF_MEMORY; } (*pQuery)->pRoot = pRootNode; (*pQuery)->placeholderNum = placeholderNo; - (*pQuery)->pPlaceholderValues = pPlaceholderValues; + TSWAP((*pQuery)->pPlaceholderValues, *pPlaceholderValues); (*pQuery)->execStage = QUERY_EXEC_STAGE_ANALYSE; return TSDB_CODE_SUCCESS; @@ -91,7 +91,7 @@ int32_t parse(SParseContext* pParseCxt, SQuery** pQuery) { abort_parse: ParseFree(pParser, (FFree)taosMemoryFree); if (TSDB_CODE_SUCCESS == cxt.errCode) { - int32_t code = buildQueryAfterParse(pQuery, cxt.pRootNode, cxt.placeholderNo, cxt.pPlaceholderValues); + int32_t code = buildQueryAfterParse(pQuery, cxt.pRootNode, cxt.placeholderNo, &cxt.pPlaceholderValues); if (TSDB_CODE_SUCCESS != code) { return code; } @@ -700,6 +700,14 @@ static int32_t collectMetaKeyFromGrant(SCollectMetaKeyCxt* pCxt, SGrantStmt* pSt return reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->objName, pStmt->tabName, pCxt->pMetaCache); } +static int32_t collectMetaKeyFromRevoke(SCollectMetaKeyCxt* pCxt, SRevokeStmt* pStmt) { + if ('\0' == pStmt->tabName[0]) { + return TSDB_CODE_SUCCESS; + } + return reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->objName, pStmt->tabName, pCxt->pMetaCache); +} + + static int32_t collectMetaKeyFromCreateViewStmt(SCollectMetaKeyCxt* pCxt, SCreateViewStmt* pStmt) { int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, pCxt->pMetaCache); @@ -760,6 +768,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) { return collectMetaKeyFromCreateStream(pCxt, (SCreateStreamStmt*)pStmt); case QUERY_NODE_GRANT_STMT: return collectMetaKeyFromGrant(pCxt, (SGrantStmt*)pStmt); + case QUERY_NODE_REVOKE_STMT: + return collectMetaKeyFromRevoke(pCxt, (SRevokeStmt*)pStmt); case QUERY_NODE_SHOW_DNODES_STMT: return collectMetaKeyFromShowDnodes(pCxt, (SShowStmt*)pStmt); case QUERY_NODE_SHOW_MNODES_STMT: diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index c01648237c..fc676a0439 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -371,7 +371,7 @@ int32_t getTargetMetaImpl(SParseContext* pParCxt, SParseMetaCache* pMetaCache, c if (pParCxt->async) { code = getTableMetaFromCache(pMetaCache, pName, pMeta); #ifdef TD_ENTERPRISE - if (TSDB_CODE_PAR_TABLE_NOT_EXIST == code && couldBeView) { + if ((TSDB_CODE_PAR_TABLE_NOT_EXIST == code || TSDB_CODE_PAR_INTERNAL_ERROR == code) && couldBeView) { int32_t origCode = code; code = getViewMetaFromCache(pMetaCache, pName, pMeta); if (TSDB_CODE_SUCCESS != code) { diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 0e56615451..222aec9813 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -568,6 +568,7 @@ static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect if (TSDB_CODE_SUCCESS == code && NULL != pColList) { code = createColumnByRewriteExprs(pColList, &pJoin->node.pTargets); } + nodesDestroyList(pColList); } if (TSDB_CODE_SUCCESS == code) { @@ -587,6 +588,7 @@ static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect if (TSDB_CODE_SUCCESS == code && NULL != pColList) { code = createColumnByRewriteExprs(pColList, &pJoin->node.pTargets); } + nodesDestroyList(pColList); } if (NULL == pJoin->node.pTargets && NULL != pLeft) { diff --git a/tests/develop-test/2-query/table_count_scan.py b/tests/develop-test/2-query/table_count_scan.py index d6e49964eb..ce01d05b2f 100644 --- a/tests/develop-test/2-query/table_count_scan.py +++ b/tests/develop-test/2-query/table_count_scan.py @@ -65,7 +65,7 @@ class TDTestCase: tdSql.query('select count(*),db_name, stable_name from information_schema.ins_tables group by db_name, stable_name;') tdSql.checkRows(3) - tdSql.checkData(0, 0, 23) + tdSql.checkData(0, 0, 24) tdSql.checkData(0, 1, 'information_schema') tdSql.checkData(0, 2, None) tdSql.checkData(1, 0, 3) diff --git a/tests/script/tsim/query/sys_tbname.sim b/tests/script/tsim/query/sys_tbname.sim index 6ed978aa15..f49a8e0a7d 100644 --- a/tests/script/tsim/query/sys_tbname.sim +++ b/tests/script/tsim/query/sys_tbname.sim @@ -58,7 +58,7 @@ endi sql select tbname from information_schema.ins_tables; print $rows $data00 -if $rows != 32 then +if $rows != 33 then return -1 endi if $data00 != @ins_tables@ then diff --git a/tests/script/tsim/query/tableCount.sim b/tests/script/tsim/query/tableCount.sim index 524b43620c..6e65852dcc 100644 --- a/tests/script/tsim/query/tableCount.sim +++ b/tests/script/tsim/query/tableCount.sim @@ -53,7 +53,7 @@ sql select stable_name,count(table_name) from information_schema.ins_tables grou if $rows != 3 then return -1 endi -if $data01 != 29 then +if $data01 != 30 then return -1 endi if $data11 != 10 then @@ -72,7 +72,7 @@ endi if $data11 != 5 then return -1 endi -if $data21 != 23 then +if $data21 != 24 then return -1 endi if $data31 != 5 then @@ -97,7 +97,7 @@ endi if $data42 != 3 then return -1 endi -if $data52 != 23 then +if $data52 != 24 then return -1 endi if $data62 != 5 then diff --git a/tests/script/tsim/view/show_desc_view.sim b/tests/script/tsim/view/show_desc_view.sim index cd0f35a39d..307d52964d 100644 --- a/tests/script/tsim/view/show_desc_view.sim +++ b/tests/script/tsim/view/show_desc_view.sim @@ -21,7 +21,7 @@ endi if $data05 != @select * from sta1;@ then return -1 endi -if $data06 != @`ts` TIMESTAMP, `f` INT, `g` INT, `t` INT@ then +if $data06 != NULL then return -1 endi if $data07 != NULL then @@ -30,9 +30,6 @@ endi if $data08 != NULL then return -1 endi -if $data09 != NULL then - return -1 -endi sql desc view1 if $rows != 4 then return -1