diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 4021fca42f6db2417068953b0b8dd2d78ada6527..988d2ef38f11b6d668bfa720109952fefd3da3b8 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -1632,7 +1632,7 @@ static bool validateTableColumnInfo(SArray* pFieldList, SSqlCmd* pCmd) { } // field name must be unique - if (has(pFieldList, i + 1, pField->name) == true) { + if (has(pFieldList, i, pField->name) == true) { invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); return false; } @@ -1691,7 +1691,7 @@ static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pC return false; } - if (has(pTagsList, i + 1, p->name) == true) { + if (has(pTagsList, i, p->name) == true) { invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); return false; } @@ -1720,8 +1720,8 @@ static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pC // field name must be unique for (int32_t i = 0; i < numOfTags; ++i) { TAOS_FIELD* p = taosArrayGet(pTagsList, i); - - if (has(pFieldList, 0, p->name) == true) { + size_t numOfCols = taosArrayGetSize(pFieldList); + if (has(pFieldList, numOfCols, p->name) == true) { invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); return false; } @@ -1867,9 +1867,8 @@ int32_t validateOneColumn(SSqlCmd* pCmd, TAOS_FIELD* pColField) { } /* is contained in pFieldList or not */ -static bool has(SArray* pFieldList, int32_t startIdx, const char* name) { - size_t numOfCols = taosArrayGetSize(pFieldList); - for (int32_t j = startIdx; j < numOfCols; ++j) { +static bool has(SArray* pFieldList, int32_t endIdx, const char* name) { + for (int32_t j = 0; j < endIdx; ++j) { TAOS_FIELD* field = taosArrayGet(pFieldList, j); if (strncmp(name, field->name, sizeof(field->name) - 1) == 0) return true; }