fix: correct error message for DROP TABLE under system databases

This commit is contained in:
Haolin Wang 2025-01-07 10:51:56 +08:00
parent 981960e8a2
commit a71fdf7252
1 changed files with 8 additions and 3 deletions

View File

@ -15543,11 +15543,9 @@ int32_t serializeVgroupsDropTableBatch(SHashObj* pVgroupHashmap, SArray** pOut)
static int32_t rewriteDropTableWithOpt(STranslateContext* pCxt, SQuery* pQuery) {
int32_t code = TSDB_CODE_SUCCESS;
SDropTableStmt* pStmt = (SDropTableStmt*)pQuery->pRoot;
if (!pStmt->withOpt) return code;
pCxt->withOpt = true;
SNode* pNode = NULL;
char pTableName[TSDB_TABLE_NAME_LEN] = {0};
FOREACH(pNode, pStmt->pTables) {
SDropTableClause* pClause = (SDropTableClause*)pNode;
if (IS_SYS_DBNAME(pClause->dbName)) {
@ -15555,6 +15553,13 @@ static int32_t rewriteDropTableWithOpt(STranslateContext* pCxt, SQuery* pQuery)
"Cannot drop table of system database: `%s`.`%s`", pClause->dbName,
pClause->tableName);
}
}
if (!pStmt->withOpt) return code;
pCxt->withOpt = true;
FOREACH(pNode, pStmt->pTables) {
SDropTableClause* pClause = (SDropTableClause*)pNode;
for (int32_t i = 0; i < TSDB_TABLE_NAME_LEN; i++) {
if (pClause->tableName[i] == '\0') {
break;