From 90222531e7d1f045e202fab56e1fd47e040cf4f1 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Mon, 4 Nov 2024 18:44:56 +0800 Subject: [PATCH] check db --- include/common/tmsg.h | 2 +- source/libs/parser/src/parAstCreater.c | 5 +++++ source/libs/parser/src/parTranslater.c | 6 +++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index a618c1b127..879200f554 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -395,10 +395,10 @@ typedef enum ENodeType { QUERY_NODE_SHOW_TSMAS_STMT, QUERY_NODE_SHOW_ANODES_STMT, QUERY_NODE_SHOW_ANODES_FULL_STMT, + QUERY_NODE_SHOW_USAGE_STMT, QUERY_NODE_CREATE_TSMA_STMT, QUERY_NODE_SHOW_CREATE_TSMA_STMT, QUERY_NODE_DROP_TSMA_STMT, - QUERY_NODE_SHOW_USAGE_STMT, // logic plan node QUERY_NODE_LOGIC_PLAN_SCAN = 1000, diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 9c5b4b072d..806bb447f4 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -3878,6 +3878,11 @@ _err: } SNode* createShowDiskUsageStmt(SAstCreateContext* pCxt, SNode* dbName, ENodeType type) { CHECK_PARSER_STATUS(pCxt); + if (NULL == dbName) { + snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "database not specified"); + pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR; + CHECK_PARSER_STATUS(pCxt); + } SShowStmt* pStmt = NULL; pCxt->errCode = nodesMakeNode(type, (SNode**)&pStmt); diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index b25d706fe2..dd978192fa 100755 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -1904,7 +1904,7 @@ static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode** pCol) { if (pCxt->pParseCxt->biMode) { SNode** ppNode = (SNode**)pCol; - bool ret; + bool ret; pCxt->errCode = biRewriteToTbnameFunc(pCxt, ppNode, &ret); if (TSDB_CODE_SUCCESS != pCxt->errCode) return DEAL_RES_ERROR; if (ret) { @@ -10041,7 +10041,7 @@ static int32_t translateCreateIndex(STranslateContext* pCxt, SCreateIndexStmt* p static int32_t translateDropIndex(STranslateContext* pCxt, SDropIndexStmt* pStmt) { SMDropSmaReq dropSmaReq = {0}; - SName name = {0}; + SName name = {0}; toName(pCxt->pParseCxt->acctId, pStmt->indexDbName, pStmt->indexName, &name); int32_t code = tNameExtractFullName(&name, dropSmaReq.name); if (TSDB_CODE_SUCCESS != code) return code; @@ -11788,7 +11788,7 @@ static int32_t translateDropView(STranslateContext* pCxt, SDropViewStmt* pStmt) #endif SCMDropViewReq dropReq = {0}; - SName name = {0}; + SName name = {0}; int32_t code = tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName)); if (TSDB_CODE_SUCCESS == code) { (void)tNameGetFullDbName(&name, dropReq.dbFName);