From e889249c54b2dcf40e3fa4c11a90ef9f3d130079 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Fri, 5 May 2023 14:33:09 +0800 Subject: [PATCH] fix: grant no table specifed issue --- source/libs/parser/src/parTranslater.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 7f77458d53..b598fffbc6 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -6667,6 +6667,15 @@ static int32_t createRealTableForGrantTable(SGrantStmt* pStmt, SRealTableNode** static int32_t translateGrantTagCond(STranslateContext* pCxt, SGrantStmt* pStmt, SAlterUserReq* pReq) { SRealTableNode* pTable = NULL; + if ('\0' == pStmt->tabName[0] || '*' == pStmt->tabName[0]) { + if (pStmt->pTagCond) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, + "The With clause can only be used for table level privilege"); + } else { + return TSDB_CODE_SUCCESS; + } + } + int32_t code = createRealTableForGrantTable(pStmt, &pTable); if (TSDB_CODE_SUCCESS == code) { SName name; @@ -6688,11 +6697,6 @@ static int32_t translateGrantTagCond(STranslateContext* pCxt, SGrantStmt* pStmt, nodesDestroyNode((SNode*)pTable); return TSDB_CODE_SUCCESS; } - if ('\0' == pStmt->tabName[0] || '*' == pStmt->tabName[0]) { - nodesDestroyNode((SNode*)pTable); - return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, - "The With clause can only be used for table level privilege"); - } pCxt->pCurrStmt = (SNode*)pStmt; -- GitLab