未验证 提交 155cbc68 编写于 作者: H haojun Liao 提交者: GitHub

Merge pull request #5136 from taosdata/feature/TD-2568

Feature/td 2568
......@@ -892,7 +892,12 @@ int tscProcessLocalCmd(SSqlObj *pSql) {
SSqlRes *pRes = &pSql->res;
if (pCmd->command == TSDB_SQL_CFG_LOCAL) {
pRes->code = (uint8_t)taosCfgDynamicOptions(pCmd->payload);
if (taosCfgDynamicOptions(pCmd->payload)) {
pRes->code = TSDB_CODE_SUCCESS;
} else {
pRes->code = TSDB_CODE_COM_INVALID_CFG_MSG;
}
pRes->numOfRows = 0;
} else if (pCmd->command == TSDB_SQL_DESCRIBE_TABLE) {
pRes->code = (uint8_t)tscProcessDescribeTable(pSql);
} else if (pCmd->command == TSDB_SQL_RETRIEVE_EMPTY_RESULT) {
......
......@@ -129,6 +129,7 @@ static int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo);
static int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo);
static int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index);
static int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSQLExpr* pSqlExpr, SQueryInfo* pQueryInfo, SArray* pCols, int64_t *uid);
static bool validateDebugFlag(int32_t flag);
int16_t getNewResColId(SQueryInfo* pQueryInfo) {
return pQueryInfo->resColumnId--;
......@@ -173,6 +174,16 @@ static uint8_t convertOptr(SStrToken *pToken) {
}
}
static bool validateDebugFlag(int32_t v) {
const static int validFlag[] = {131, 135, 143};
for (int i = 0; i < tListLen(validFlag); i++) {
if (v == validFlag[i]) {
return true;
}
}
return false;
}
/*
* Used during parsing query sql. Since the query sql usually small in length, error position
* is not needed in the final error message.
......@@ -565,16 +576,16 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
int32_t numOfToken = (int32_t) taosArrayGetSize(pMiscInfo->a);
SStrToken* t = taosArrayGet(pMiscInfo->a, 0);
SStrToken* t1 = taosArrayGet(pMiscInfo->a, 1);
assert(numOfToken >= 1 && numOfToken <= 2);
SStrToken* t = taosArrayGet(pMiscInfo->a, 0);
strncpy(pCmd->payload, t->z, t->n);
if (numOfToken == 2) {
SStrToken* t1 = taosArrayGet(pMiscInfo->a, 1);
pCmd->payload[t->n] = ' '; // add sep
strncpy(&pCmd->payload[t->n + 1], t1->z, t1->n);
}
break;
}
return TSDB_CODE_SUCCESS;
}
case TSDB_SQL_CREATE_TABLE: {
......@@ -5357,13 +5368,15 @@ int32_t validateLocalConfig(SMiscInfo* pOptions) {
SDNodeDynConfOption LOCAL_DYNAMIC_CFG_OPTIONS[6] = {{"resetLog", 8}, {"rpcDebugFlag", 12}, {"tmrDebugFlag", 12},
{"cDebugFlag", 10}, {"uDebugFlag", 10}, {"debugFlag", 9}};
SStrToken* pOptionToken = taosArrayGet(pOptions->a, 0);
if (numOfToken == 1) {
// reset log does not need value
for (int32_t i = 0; i < 1; ++i) {
SDNodeDynConfOption* pOption = &LOCAL_DYNAMIC_CFG_OPTIONS[i];
if ((strncasecmp(pOption->name, pOptionToken->z, pOptionToken->n) == 0) && (pOption->len == pOptionToken->n)) {
if ((pOption->len == pOptionToken->n) &&
(strncasecmp(pOption->name, pOptionToken->z, pOptionToken->n) == 0)) {
return TSDB_CODE_SUCCESS;
}
}
......@@ -5371,15 +5384,14 @@ int32_t validateLocalConfig(SMiscInfo* pOptions) {
SStrToken* pValToken = taosArrayGet(pOptions->a, 1);
int32_t val = strtol(pValToken->z, NULL, 10);
if (val < 131 || val > 199) {
// options value is out of valid range
if (!validateDebugFlag(val)) {
return TSDB_CODE_TSC_INVALID_SQL;
}
for (int32_t i = 1; i < tListLen(LOCAL_DYNAMIC_CFG_OPTIONS); ++i) {
SDNodeDynConfOption* pOption = &LOCAL_DYNAMIC_CFG_OPTIONS[i];
if ((strncasecmp(pOption->name, pOptionToken->z, pOptionToken->n) == 0) && (pOption->len == pOptionToken->n)) {
// options is valid
if ((pOption->len == pOptionToken->n)
&& (strncasecmp(pOption->name, pOptionToken->z, pOptionToken->n) == 0)) {
return TSDB_CODE_SUCCESS;
}
}
......
......@@ -273,7 +273,7 @@ bool taosCfgDynamicOptions(char *msg) {
int32_t vint = 0;
paGetToken(msg, &option, &olen);
if (olen == 0) return TSDB_CODE_COM_INVALID_CFG_MSG;
if (olen == 0) return false;;
paGetToken(option + olen + 1, &value, &vlen);
if (vlen == 0)
......@@ -316,11 +316,9 @@ bool taosCfgDynamicOptions(char *msg) {
}
return true;
}
if (strncasecmp(cfg->option, "debugFlag", olen) == 0) {
taosSetAllDebugFlag();
taosSetAllDebugFlag();
}
return true;
}
......
......@@ -4571,7 +4571,7 @@ static void generateBlockDistResult(STableBlockDist *pTableBlockDist) {
if (pTableBlockDist == NULL) {
return;
}
int64_t min = INT64_MAX, max = INT64_MIN, avg = 0;
int64_t min = 0, max = 0, avg = 0;
SArray* blockInfos= pTableBlockDist->dataBlockInfos;
int64_t totalRows = 0, totalBlocks = taosArrayGetSize(blockInfos);
for (size_t i = 0; i < taosArrayGetSize(blockInfos); i++) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册