[td-225]refactor codes.
This commit is contained in:
parent
289e10823a
commit
e27f1ce493
|
@ -4466,8 +4466,13 @@ static int32_t doAddTableName(char* nextStr, char** str, SArray* pNameArray, SSq
|
||||||
strncpy(tablename, *str, TSDB_TABLE_FNAME_LEN);
|
strncpy(tablename, *str, TSDB_TABLE_FNAME_LEN);
|
||||||
len = (int32_t) strlen(tablename);
|
len = (int32_t) strlen(tablename);
|
||||||
} else {
|
} else {
|
||||||
memcpy(tablename, *str, nextStr - (*str));
|
|
||||||
len = (int32_t)(nextStr - (*str));
|
len = (int32_t)(nextStr - (*str));
|
||||||
|
if (len >= TSDB_TABLE_NAME_LEN) {
|
||||||
|
sprintf(pCmd->payload, "table name too long");
|
||||||
|
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(tablename, *str, nextStr - (*str));
|
||||||
tablename[len] = '\0';
|
tablename[len] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4479,9 +4484,8 @@ static int32_t doAddTableName(char* nextStr, char** str, SArray* pNameArray, SSq
|
||||||
|
|
||||||
// Check if the table name available or not
|
// Check if the table name available or not
|
||||||
if (tscValidateName(&sToken) != TSDB_CODE_SUCCESS) {
|
if (tscValidateName(&sToken) != TSDB_CODE_SUCCESS) {
|
||||||
code = TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH;
|
|
||||||
sprintf(pCmd->payload, "table name is invalid");
|
sprintf(pCmd->payload, "table name is invalid");
|
||||||
return code;
|
return TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
SName name = {0};
|
SName name = {0};
|
||||||
|
@ -4541,14 +4545,18 @@ int tscTransferTableNameList(SSqlObj *pSql, const char *pNameList, int32_t lengt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosArrayGetSize(pNameArray) > TSDB_MULTI_TABLEMETA_MAX_NUM) {
|
size_t len = taosArrayGetSize(pNameArray);
|
||||||
|
if (len == 1) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len > TSDB_MULTI_TABLEMETA_MAX_NUM) {
|
||||||
code = TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH;
|
code = TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH;
|
||||||
sprintf(pCmd->payload, "tables over the max number");
|
sprintf(pCmd->payload, "tables over the max number");
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArraySort(pNameArray, nameComparFn);
|
taosArraySort(pNameArray, nameComparFn);
|
||||||
size_t len = taosArrayGetSize(pNameArray);
|
|
||||||
|
|
||||||
int32_t pos = 0;
|
int32_t pos = 0;
|
||||||
for(int32_t i = 1; i < len; ++i) {
|
for(int32_t i = 1; i < len; ++i) {
|
||||||
|
|
Loading…
Reference in New Issue