fix: correct error message for CREATE TABLE under system databases

This commit is contained in:
Haolin Wang 2025-01-07 10:57:12 +08:00
parent a71fdf7252
commit 04dbca44ab
1 changed files with 6 additions and 0 deletions

View File

@ -9118,6 +9118,12 @@ static int32_t checkCreateTable(STranslateContext* pCxt, SCreateTableStmt* pStmt
"The table name cannot contain '.'"); "The table name cannot contain '.'");
} }
if (IS_SYS_DBNAME(pStmt->dbName)) {
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_TSC_INVALID_OPERATION,
"Cannot create table of system database: `%s`.`%s`", pStmt->dbName,
pStmt->tableName);
}
SDbCfgInfo dbCfg = {0}; SDbCfgInfo dbCfg = {0};
int32_t code = getDBCfg(pCxt, pStmt->dbName, &dbCfg); int32_t code = getDBCfg(pCxt, pStmt->dbName, &dbCfg);
if (TSDB_CODE_SUCCESS == code && !createStable && NULL != dbCfg.pRetensions) { if (TSDB_CODE_SUCCESS == code && !createStable && NULL != dbCfg.pRetensions) {