enh: add more error case handle code
This commit is contained in:
parent
f5da2c71ec
commit
a9e5699a4d
|
@ -895,6 +895,7 @@ int32_t taosGetErrSize();
|
|||
#define TSDB_CODE_PAR_INVALID_ANOMALY_WIN_COL TAOS_DEF_ERROR_CODE(0, 0x2683)
|
||||
#define TSDB_CODE_PAR_INVALID_ANOMALY_WIN_OPT TAOS_DEF_ERROR_CODE(0, 0x2684)
|
||||
#define TSDB_CODE_PAR_INVALID_FORECAST_CLAUSE TAOS_DEF_ERROR_CODE(0, 0x2685)
|
||||
#define TSDB_CODE_PAR_INVALID_VGID_LIST TAOS_DEF_ERROR_CODE(0, 0x2686)
|
||||
#define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x26FF)
|
||||
|
||||
//planner
|
||||
|
|
|
@ -2132,6 +2132,8 @@ SNode* createCompactVgroupsStmt(SAstCreateContext* pCxt, SNode* pDbName, SNodeLi
|
|||
pStmt->pEnd = pEnd;
|
||||
return (SNode*)pStmt;
|
||||
_err:
|
||||
nodesDestroyNode(pDbName);
|
||||
nodesDestroyList(vgidList);
|
||||
nodesDestroyNode(pStart);
|
||||
nodesDestroyNode(pEnd);
|
||||
return NULL;
|
||||
|
|
|
@ -10449,30 +10449,49 @@ static int32_t translateCompactDb(STranslateContext* pCxt, SCompactDatabaseStmt*
|
|||
}
|
||||
|
||||
static int32_t translateVgroupList(STranslateContext* pCxt, SNodeList* vgroupList, SArray** ppVgroups) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
int32_t numOfVgroups = LIST_LENGTH(vgroupList);
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SHashObj* pHash = NULL;
|
||||
int32_t numOfVgroups = LIST_LENGTH(vgroupList);
|
||||
|
||||
(*ppVgroups) = taosArrayInit(numOfVgroups, sizeof(int64_t));
|
||||
if (NULL == *ppVgroups) {
|
||||
return terrno;
|
||||
}
|
||||
|
||||
SNode* pNode = NULL;
|
||||
FOREACH(pNode, vgroupList) {
|
||||
SValueNode* pVal = (SValueNode*)pNode;
|
||||
if (DEAL_RES_ERROR == translateValue(pCxt, pVal)) {
|
||||
code = TSDB_CODE_VND_INVALID_VGROUP_ID;
|
||||
break;
|
||||
}
|
||||
pHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||
if (NULL == pHash) {
|
||||
code = terrno;
|
||||
}
|
||||
|
||||
int64_t vgroupId = getBigintFromValueNode(pVal);
|
||||
if (NULL == taosArrayPush(*ppVgroups, &vgroupId)) {
|
||||
code = terrno;
|
||||
break;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
SNode* pNode = NULL;
|
||||
FOREACH(pNode, vgroupList) {
|
||||
SValueNode* pVal = (SValueNode*)pNode;
|
||||
if (DEAL_RES_ERROR == translateValue(pCxt, pVal)) {
|
||||
code = TSDB_CODE_VND_INVALID_VGROUP_ID;
|
||||
break;
|
||||
}
|
||||
|
||||
int64_t vgroupId = getBigintFromValueNode(pVal);
|
||||
|
||||
if (NULL != taosHashGet(pHash, &vgroupId, sizeof(vgroupId))) {
|
||||
code = TSDB_CODE_PAR_INVALID_VGID_LIST;
|
||||
break;
|
||||
}
|
||||
|
||||
code = taosHashPut(pHash, &vgroupId, sizeof(vgroupId), NULL, 0);
|
||||
if (code) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (NULL == taosArrayPush(*ppVgroups, &vgroupId)) {
|
||||
code = terrno;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
taosHashCleanup(pHash);
|
||||
if (code) {
|
||||
taosArrayDestroy(*ppVgroups);
|
||||
*ppVgroups = NULL;
|
||||
|
|
|
@ -739,6 +739,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_ANOMALY_WIN_COL, "ANOMALY_WINDOW not
|
|||
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_ANOMALY_WIN_OPT, "ANOMALY_WINDOW option should include algo field")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_FORECAST_CLAUSE, "Invalid forecast clause")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_REGULAR_EXPRESSION_ERROR, "Syntax error in regular expression")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_VGID_LIST, "Invalid vgid list")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INTERNAL_ERROR, "Parser internal error")
|
||||
|
||||
//planner
|
||||
|
|
Loading…
Reference in New Issue