Merge pull request #21158 from taosdata/fix/preventSubtableGrant
fix: subtable grant is not allowed
This commit is contained in:
commit
61f13f20eb
|
@ -6666,22 +6666,40 @@ static int32_t createRealTableForGrantTable(SGrantStmt* pStmt, SRealTableNode**
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateGrantTagCond(STranslateContext* pCxt, SGrantStmt* pStmt, SAlterUserReq* pReq) {
|
static int32_t translateGrantTagCond(STranslateContext* pCxt, SGrantStmt* pStmt, SAlterUserReq* pReq) {
|
||||||
if (NULL == pStmt->pTagCond) {
|
SRealTableNode* pTable = NULL;
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
if ('\0' == pStmt->tabName[0] || '*' == pStmt->tabName[0]) {
|
if ('\0' == pStmt->tabName[0] || '*' == pStmt->tabName[0]) {
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR,
|
if (pStmt->pTagCond) {
|
||||||
"The With clause can only be used for table level privilege");
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pCxt->pCurrStmt = (SNode*)pStmt;
|
|
||||||
SRealTableNode* pTable = NULL;
|
|
||||||
int32_t code = createRealTableForGrantTable(pStmt, &pTable);
|
int32_t code = createRealTableForGrantTable(pStmt, &pTable);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
SName name;
|
SName name;
|
||||||
code = getTableMetaImpl(pCxt, toName(pCxt->pParseCxt->acctId, pTable->table.dbName, pTable->table.tableName, &name),
|
code = getTableMetaImpl(pCxt, toName(pCxt->pParseCxt->acctId, pTable->table.dbName, pTable->table.tableName, &name),
|
||||||
&(pTable->pMeta));
|
&(pTable->pMeta));
|
||||||
|
if (code) {
|
||||||
|
nodesDestroyNode((SNode*)pTable);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TSDB_SUPER_TABLE != pTable->pMeta->tableType && TSDB_NORMAL_TABLE != pTable->pMeta->tableType) {
|
||||||
|
nodesDestroyNode((SNode*)pTable);
|
||||||
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR,
|
||||||
|
"Only supertable and normal table can be granted");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (TSDB_CODE_SUCCESS == code && NULL == pStmt->pTagCond) {
|
||||||
|
nodesDestroyNode((SNode*)pTable);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
pCxt->pCurrStmt = (SNode*)pStmt;
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = addNamespace(pCxt, pTable);
|
code = addNamespace(pCxt, pTable);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue