From 782566ad081d7ecb35b2dd3720cc0214cea5b0eb Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Mon, 24 Apr 2023 17:15:46 +0800 Subject: [PATCH] refactor --- include/common/systable.h | 3 +-- source/common/src/systable.c | 4 ---- source/libs/parser/src/parTranslater.c | 9 ++++----- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/include/common/systable.h b/include/common/systable.h index 6e0c67bb3f..ea18338e9e 100644 --- a/include/common/systable.h +++ b/include/common/systable.h @@ -12,7 +12,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ - + #ifndef TDENGINE_SYSTABLE_H #define TDENGINE_SYSTABLE_H @@ -77,7 +77,6 @@ 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 de95a4a5be..cd3dd63ef0 100644 --- a/source/common/src/systable.c +++ b/source/common/src/systable.c @@ -448,7 +448,3 @@ 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/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 52451d35a8..97fee72bf8 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -2580,6 +2580,10 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) { if (TSDB_SYSTEM_TABLE == pRealTable->pMeta->tableType && isSelectStmt(pCxt->pCurrStmt)) { ((SSelectStmt*)pCxt->pCurrStmt)->isTimeLineResult = false; } + if (TSDB_SYSTEM_TABLE == pRealTable->pMeta->tableType && isDeleteStmt(pCxt->pCurrStmt)) { + code = TSDB_CODE_TSC_INVALID_OPERATION; + break; + } code = addNamespace(pCxt, pRealTable); } break; @@ -3792,11 +3796,6 @@ static int32_t translateDeleteWhere(STranslateContext* pCxt, SDeleteStmt* pDelet } static int32_t translateDelete(STranslateContext* pCxt, SDeleteStmt* pDelete) { - // check delete from system tables - if (isSystemDb(((SRealTableNode*)pDelete->pFromTable)->table.dbName)) { - return TSDB_CODE_TSC_INVALID_OPERATION; - } - pCxt->pCurrStmt = (SNode*)pDelete; int32_t code = translateFrom(pCxt, pDelete->pFromTable); if (TSDB_CODE_SUCCESS == code) { -- GitLab