From 2f1c9b3c1673dc6db848775cfa3936e9025a44dc Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Sat, 30 Jul 2022 09:50:19 +0800 Subject: [PATCH] enh: add local forbidden cfg processing --- include/common/tglobal.h | 1 + source/common/src/tglobal.c | 14 ++++++++++++++ source/libs/command/src/command.c | 7 +++++++ 3 files changed, 22 insertions(+) diff --git a/include/common/tglobal.h b/include/common/tglobal.h index 57d1199e17..9111728e1a 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -146,6 +146,7 @@ struct SConfig *taosGetCfg(); void taosSetAllDebugFlag(int32_t flag); void taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVal); int32_t taosSetCfg(SConfig *pCfg, char *name); +void taosLocalCfgForbiddenToChange(char* name, bool* forbidden); #ifdef __cplusplus } diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index ba7f9f93c1..6f4a3060ed 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -594,6 +594,20 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { return 0; } +void taosLocalCfgForbiddenToChange(char* name, bool* forbidden) { + int32_t len = strlen(name); + char lowcaseName[CFG_NAME_MAX_LEN + 1] = {0}; + strntolower(lowcaseName, name, TMIN(CFG_NAME_MAX_LEN, len)); + + if (strcasecmp("charset", name) == 0) { + *forbidden = true; + return; + } + + *forbidden = false; +} + + int32_t taosSetCfg(SConfig *pCfg, char *name) { int32_t len = strlen(name); char lowcaseName[CFG_NAME_MAX_LEN + 1] = {0}; diff --git a/source/libs/command/src/command.c b/source/libs/command/src/command.c index 7c95e71823..a76b457422 100644 --- a/source/libs/command/src/command.c +++ b/source/libs/command/src/command.c @@ -517,6 +517,13 @@ static int32_t execAlterLocal(SAlterLocalStmt* pStmt) { goto _return; } + bool forbidden = false; + taosLocalCfgForbiddenToChange(pStmt->config, &forbidden); + if (forbidden) { + terrno = TSDB_CODE_OPS_NOT_SUPPORT; + return terrno; + } + if (cfgSetItem(tsCfg, pStmt->config, pStmt->value, CFG_STYPE_ALTER_CMD)) { return terrno; }