diff --git a/include/common/systable.h b/include/common/systable.h index 558a1ca297bfd42269fd376c5e6500e1e4bdfbcc..6e0c67bb3f9b4b5aff2b5e7cace2846341d55b35 100644 --- a/include/common/systable.h +++ b/include/common/systable.h @@ -77,6 +77,7 @@ void getInfosDbMeta(const SSysTableMeta** pInfosTableMeta, size_t* size); void getPerfDbMeta(const SSysTableMeta** pPerfsTableMeta, size_t* size); void getVisibleInfosTablesNum(bool sysInfo, size_t* size); bool invisibleColumn(bool sysInfo, int8_t tableType, int8_t flags); +bool isSystemDb(const char *dbName); #ifdef __cplusplus } diff --git a/source/common/src/systable.c b/source/common/src/systable.c index cd3dd63ef04b56ca1ea933bbb8c3053da8917f4f..de95a4a5be1ce775245f88bf4f64783cb253f4a9 100644 --- a/source/common/src/systable.c +++ b/source/common/src/systable.c @@ -448,3 +448,7 @@ bool invisibleColumn(bool sysInfo, int8_t tableType, int8_t flags) { } return 0 != (flags & COL_IS_SYSINFO); } + +bool isSystemDb(const char *dbName) { + return ((strcasecmp(dbName, TSDB_INFORMATION_SCHEMA_DB) == 0) || (strcasecmp(dbName, TSDB_PERFORMANCE_SCHEMA_DB) == 0)); +} diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index c9ee83a64757b6fe951d93fd9c9d917ba357f58b..9e03095d2eb82980e0c4f11a2fe374fbf4172fd3 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -1442,8 +1442,12 @@ static int32_t createDeleteRootLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* p } static int32_t createDeleteScanLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pDelete, SLogicNode** pLogicNode) { + if (isSystemDb(((SRealTableNode*)pDelete->pFromTable)->table.dbName)) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + SScanLogicNode* pScan = NULL; - int32_t code = makeScanLogicNode(pCxt, (SRealTableNode*)pDelete->pFromTable, false, (SLogicNode**)&pScan); + int32_t code = makeScanLogicNode(pCxt, (SRealTableNode*)pDelete->pFromTable, false, (SLogicNode**)&pScan); // set columns to scan if (TSDB_CODE_SUCCESS == code) {