enh: cannot drop table of system db
This commit is contained in:
parent
b0a711e575
commit
3fd2e51e06
|
@ -14570,7 +14570,11 @@ static int32_t rewriteDropTableWithOpt(STranslateContext* pCxt, SQuery* pQuery)
|
|||
char pTableName[TSDB_TABLE_NAME_LEN] = {0};
|
||||
FOREACH(pNode, pStmt->pTables) {
|
||||
SDropTableClause* pClause = (SDropTableClause*)pNode;
|
||||
SName name = {0};
|
||||
if (IS_SYS_DBNAME(pClause->dbName)) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_TSC_INVALID_OPERATION,
|
||||
"Cannot drop table of system database: '%s.%s'", pClause->dbName, pClause->tableName);
|
||||
}
|
||||
SName name = {0};
|
||||
toName(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, &name);
|
||||
int32_t code = getTargetName(pCxt, &name, pTableName);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
|
@ -14680,6 +14684,11 @@ static int32_t rewriteDropSuperTablewithOpt(STranslateContext* pCxt, SQuery* pQu
|
|||
if (!pStmt->withOpt) return code;
|
||||
pCxt->withOpt = true;
|
||||
|
||||
if (IS_SYS_DBNAME(pStmt->dbName)) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_TSC_INVALID_OPERATION,
|
||||
"Cannot drop table of system database: '%s.%s'", pStmt->dbName, pStmt->tableName);
|
||||
}
|
||||
|
||||
char pTableName[TSDB_TABLE_NAME_LEN] = {0};
|
||||
SName name = {0};
|
||||
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name);
|
||||
|
|
|
@ -172,6 +172,8 @@ class TDTestCase:
|
|||
tdSql.checkRows(0)
|
||||
tdSql.query(f'select * from information_schema.ins_tables where db_name like "dbtest_%"')
|
||||
tdSql.checkRows(8)
|
||||
tdSql.error(f'drop stable with information_schema.`ins_tables`;')
|
||||
tdSql.error(f'drop stable with performance_schema.`perf_connections`;')
|
||||
self.drop_table_check_end()
|
||||
def drop_table_with_check(self):
|
||||
self.drop_table_check_init()
|
||||
|
@ -194,6 +196,8 @@ class TDTestCase:
|
|||
tdSql.checkRows(0)
|
||||
tdSql.query(f'select * from information_schema.ins_stables where db_name like "dbtest_%"')
|
||||
tdSql.checkRows(2)
|
||||
tdSql.error(f'drop table with information_schema.`ins_tables`;')
|
||||
tdSql.error(f'drop table with performance_schema.`perf_connections`;')
|
||||
self.drop_table_check_end()
|
||||
def drop_topic_check(self):
|
||||
tdSql.execute(f'create database {self.dbname} replica {self.replicaVar} wal_retention_period 3600')
|
||||
|
|
Loading…
Reference in New Issue