未验证 提交 2fb85a49 编写于 作者: M Minglei Jin 提交者: GitHub

Merge pull request #14619 from taosdata/fix/TS-1648-2.6

fix: fixed compilation errors produced by old gcc version
......@@ -7,7 +7,9 @@
* See COPYRIGHT in top-level directory.
*/
#ifndef WINDOWS
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
#pragma GCC diagnostic push
#endif
#pragma GCC diagnostic ignored "-Wchar-subscripts"
#endif
......@@ -233,5 +235,7 @@ INLINE void updateLossyCompElement_Float(unsigned char* diffBytes, unsigned char
}
#ifndef WINDOWS
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
#pragma GCC diagnostic pop
#endif
\ No newline at end of file
#endif
#endif
......@@ -117,7 +117,7 @@ node qremove(HuffmanTree* huffmanTree)
/**
* @out1 should be set to 0.
* @out2 should be 0 as well.
* @index: the index of the byte
* @idx: the idx of the byte
* */
void build_code(HuffmanTree *huffmanTree, node n, int len, unsigned long out1, unsigned long out2)
{
......@@ -136,8 +136,8 @@ void build_code(HuffmanTree *huffmanTree, node n, int len, unsigned long out1, u
huffmanTree->cout[n->c] = (unsigned char)len;
return;
}
int index = len >> 6; //=len/64
if(index == 0)
int idx = len >> 6; //=len/64
if(idx == 0)
{
out1 = out1 << 1;
out1 = out1 | 0;
......@@ -164,13 +164,13 @@ void build_code(HuffmanTree *huffmanTree, node n, int len, unsigned long out1, u
* */
void init(HuffmanTree* huffmanTree, int *s, size_t length)
{
size_t i, index;
size_t i, idx;
size_t *freq = (size_t *)malloc(huffmanTree->allNodes*sizeof(size_t));
memset(freq, 0, huffmanTree->allNodes*sizeof(size_t));
for(i = 0;i < length;i++)
{
index = s[i];
freq[index]++;
idx = s[i];
freq[idx]++;
}
for (i = 0; i < huffmanTree->allNodes; i++)
......
......@@ -25,9 +25,9 @@ void new_TightDataPointStorageD_Empty(TightDataPointStorageD **this)
int new_TightDataPointStorageD_fromFlatBytes(TightDataPointStorageD **this, unsigned char* flatBytes, size_t flatBytesLength, sz_exedata* pde_exe, sz_params* pde_params)
{
new_TightDataPointStorageD_Empty(this);
size_t i, index = 0;
unsigned char version = flatBytes[index++]; //3
unsigned char sameRByte = flatBytes[index++]; //1
size_t i, idx = 0;
unsigned char version = flatBytes[idx++]; //3
unsigned char sameRByte = flatBytes[idx++]; //1
// parse data format
switch (version)
......@@ -46,15 +46,15 @@ int new_TightDataPointStorageD_fromFlatBytes(TightDataPointStorageD **this, unsi
pde_params->accelerate_pw_rel_compression = (sameRByte & 0x08) >> 3;
int errorBoundMode = SZ_ABS;
convertBytesToSZParams(&(flatBytes[index]), pde_params, pde_exe);
convertBytesToSZParams(&(flatBytes[idx]), pde_params, pde_exe);
index += MetaDataByteLength_double;
idx += MetaDataByteLength_double;
int isRegression = (sameRByte >> 7) & 0x01;
unsigned char dsLengthBytes[8];
for (i = 0; i < pde_exe->SZ_SIZE_TYPE; i++)
dsLengthBytes[i] = flatBytes[index++];
dsLengthBytes[i] = flatBytes[idx++];
(*this)->dataSeriesLength = bytesToSize(dsLengthBytes, pde_exe->SZ_SIZE_TYPE);
if((*this)->isLossless==1)
......@@ -65,7 +65,7 @@ int new_TightDataPointStorageD_fromFlatBytes(TightDataPointStorageD **this, unsi
else if(same==1)
{
(*this)->allSameData = 1;
(*this)->exactMidBytes = &(flatBytes[index]);
(*this)->exactMidBytes = &(flatBytes[idx]);
return errorBoundMode;
}
else
......@@ -74,42 +74,42 @@ int new_TightDataPointStorageD_fromFlatBytes(TightDataPointStorageD **this, unsi
if(isRegression == 1)
{
(*this)->raBytes_size = flatBytesLength - 3 - 1 - MetaDataByteLength_double - pde_exe->SZ_SIZE_TYPE;
(*this)->raBytes = &(flatBytes[index]);
(*this)->raBytes = &(flatBytes[idx]);
return errorBoundMode;
}
unsigned char byteBuf[8];
for (i = 0; i < 4; i++)
byteBuf[i] = flatBytes[index++];
byteBuf[i] = flatBytes[idx++];
int max_quant_intervals = bytesToInt_bigEndian(byteBuf);// 4
pde_params->maxRangeRadius = max_quant_intervals/2;
for (i = 0; i < 4; i++)
byteBuf[i] = flatBytes[index++];
byteBuf[i] = flatBytes[idx++];
(*this)->intervals = bytesToInt_bigEndian(byteBuf);// 4
for (i = 0; i < 8; i++)
byteBuf[i] = flatBytes[index++];
byteBuf[i] = flatBytes[idx++];
(*this)->medianValue = bytesToDouble(byteBuf);//8
(*this)->reqLength = flatBytes[index++]; //1
(*this)->reqLength = flatBytes[idx++]; //1
for (i = 0; i < 8; i++)
byteBuf[i] = flatBytes[index++];
byteBuf[i] = flatBytes[idx++];
(*this)->realPrecision = bytesToDouble(byteBuf);//8
for (i = 0; i < pde_exe->SZ_SIZE_TYPE; i++)
byteBuf[i] = flatBytes[index++];
byteBuf[i] = flatBytes[idx++];
(*this)->typeArray_size = bytesToSize(byteBuf, pde_exe->SZ_SIZE_TYPE);
for (i = 0; i < pde_exe->SZ_SIZE_TYPE; i++)
byteBuf[i] = flatBytes[index++];
byteBuf[i] = flatBytes[idx++];
(*this)->exactDataNum = bytesToSize(byteBuf, pde_exe->SZ_SIZE_TYPE);// ST
for (i = 0; i < pde_exe->SZ_SIZE_TYPE; i++)
byteBuf[i] = flatBytes[index++];
byteBuf[i] = flatBytes[idx++];
(*this)->exactMidBytes_size = bytesToSize(byteBuf, pde_exe->SZ_SIZE_TYPE);// ST
size_t logicLeadNumBitsNum = (*this)->exactDataNum * 2;
......@@ -122,12 +122,12 @@ int new_TightDataPointStorageD_fromFlatBytes(TightDataPointStorageD **this, unsi
(*this)->leadNumArray_size = (logicLeadNumBitsNum >> 3) + 1;
}
(*this)->typeArray = &flatBytes[index];
(*this)->typeArray = &flatBytes[idx];
//retrieve the number of states (i.e., stateNum)
(*this)->allNodes = bytesToInt_bigEndian((*this)->typeArray); //the first 4 bytes store the stateNum
(*this)->stateNum = ((*this)->allNodes+1)/2;
index+=(*this)->typeArray_size;
idx+=(*this)->typeArray_size;
// todo need check length
......@@ -135,15 +135,15 @@ int new_TightDataPointStorageD_fromFlatBytes(TightDataPointStorageD **this, unsi
- pde_exe->SZ_SIZE_TYPE - pde_exe->SZ_SIZE_TYPE - pde_exe->SZ_SIZE_TYPE
- (*this)->leadNumArray_size - (*this)->exactMidBytes_size - (*this)->typeArray_size;
(*this)->leadNumArray = &flatBytes[index];
(*this)->leadNumArray = &flatBytes[idx];
index+=(*this)->leadNumArray_size;
idx+=(*this)->leadNumArray_size;
(*this)->exactMidBytes = &flatBytes[index];
(*this)->exactMidBytes = &flatBytes[idx];
index+=(*this)->exactMidBytes_size;
idx+=(*this)->exactMidBytes_size;
(*this)->residualMidBits = &flatBytes[index];
(*this)->residualMidBits = &flatBytes[idx];
return errorBoundMode;
......
......@@ -25,15 +25,15 @@ void new_TightDataPointStorageF_Empty(TightDataPointStorageF **this)
int new_TightDataPointStorageF_fromFlatBytes(TightDataPointStorageF **this, unsigned char* flatBytes, size_t flatBytesLength, sz_exedata* pde_exe, sz_params* pde_params)
{
new_TightDataPointStorageF_Empty(this);
size_t i, index = 0;
size_t i, idx = 0;
//
// parse tdps
//
// 1 version(1)
unsigned char version = flatBytes[index++]; //1
unsigned char sameRByte = flatBytes[index++]; //1
unsigned char version = flatBytes[idx++]; //1
unsigned char sameRByte = flatBytes[idx++]; //1
// parse data format
switch (version)
......@@ -51,12 +51,12 @@ int new_TightDataPointStorageF_fromFlatBytes(TightDataPointStorageF **this, unsi
pde_exe->SZ_SIZE_TYPE = ((sameRByte & 0x40)>>6)==1?8:4; //0100,0000
int errorBoundMode = SZ_ABS;
// 3 meta(2)
convertBytesToSZParams(&(flatBytes[index]), pde_params, pde_exe);
index += MetaDataByteLength;
convertBytesToSZParams(&(flatBytes[idx]), pde_params, pde_exe);
idx += MetaDataByteLength;
// 4 element count(4)
unsigned char dsLengthBytes[8];
for (i = 0; i < pde_exe->SZ_SIZE_TYPE; i++)
dsLengthBytes[i] = flatBytes[index++];
dsLengthBytes[i] = flatBytes[idx++];
(*this)->dataSeriesLength = bytesToSize(dsLengthBytes, pde_exe->SZ_SIZE_TYPE);// 4 or 8
if((*this)->isLossless==1)
{
......@@ -66,7 +66,7 @@ int new_TightDataPointStorageF_fromFlatBytes(TightDataPointStorageF **this, unsi
else if(same==1)
{
(*this)->allSameData = 1;
(*this)->exactMidBytes = &(flatBytes[index]);
(*this)->exactMidBytes = &(flatBytes[idx]);
return errorBoundMode;
}
else
......@@ -76,40 +76,40 @@ int new_TightDataPointStorageF_fromFlatBytes(TightDataPointStorageF **this, unsi
if(isRegression == 1)
{
(*this)->raBytes_size = flatBytesLength - 1 - 1 - MetaDataByteLength - pde_exe->SZ_SIZE_TYPE;
(*this)->raBytes = &(flatBytes[index]);
(*this)->raBytes = &(flatBytes[idx]);
return errorBoundMode;
}
// 5 quant intervals(4)
unsigned char byteBuf[8];
for (i = 0; i < 4; i++)
byteBuf[i] = flatBytes[index++];
byteBuf[i] = flatBytes[idx++];
int max_quant_intervals = bytesToInt_bigEndian(byteBuf);// 4
pde_params->maxRangeRadius = max_quant_intervals/2;
// 6 intervals
for (i = 0; i < 4; i++)
byteBuf[i] = flatBytes[index++];
byteBuf[i] = flatBytes[idx++];
(*this)->intervals = bytesToInt_bigEndian(byteBuf);// 4
// 7 median
for (i = 0; i < 4; i++)
byteBuf[i] = flatBytes[index++];
byteBuf[i] = flatBytes[idx++];
(*this)->medianValue = bytesToFloat(byteBuf); //4
// 8 reqLength
(*this)->reqLength = flatBytes[index++]; //1
(*this)->reqLength = flatBytes[idx++]; //1
// 9 realPrecision(8)
for (i = 0; i < 8; i++)
byteBuf[i] = flatBytes[index++];
byteBuf[i] = flatBytes[idx++];
(*this)->realPrecision = bytesToDouble(byteBuf);//8
// 10 typeArray_size
for (i = 0; i < pde_exe->SZ_SIZE_TYPE; i++)
byteBuf[i] = flatBytes[index++];
byteBuf[i] = flatBytes[idx++];
(*this)->typeArray_size = bytesToSize(byteBuf, pde_exe->SZ_SIZE_TYPE);// 4
// 11 exactNum
for (i = 0; i < pde_exe->SZ_SIZE_TYPE; i++)
byteBuf[i] = flatBytes[index++];
byteBuf[i] = flatBytes[idx++];
(*this)->exactDataNum = bytesToSize(byteBuf, pde_exe->SZ_SIZE_TYPE);// ST
// 12 mid size
for (i = 0; i < pde_exe->SZ_SIZE_TYPE; i++)
byteBuf[i] = flatBytes[index++];
byteBuf[i] = flatBytes[idx++];
(*this)->exactMidBytes_size = bytesToSize(byteBuf, pde_exe->SZ_SIZE_TYPE);// STqq
// calc leadNumArray_size
......@@ -124,20 +124,20 @@ int new_TightDataPointStorageF_fromFlatBytes(TightDataPointStorageF **this, unsi
}
// 13 typeArray
(*this)->typeArray = &flatBytes[index];
(*this)->typeArray = &flatBytes[idx];
//retrieve the number of states (i.e., stateNum)
(*this)->allNodes = bytesToInt_bigEndian((*this)->typeArray); //the first 4 bytes store the stateNum
(*this)->stateNum = ((*this)->allNodes+1)/2;
index+=(*this)->typeArray_size;
idx+=(*this)->typeArray_size;
// 14 leadNumArray
(*this)->leadNumArray = &flatBytes[index];
index += (*this)->leadNumArray_size;
(*this)->leadNumArray = &flatBytes[idx];
idx += (*this)->leadNumArray_size;
// 15 exactMidBytes
(*this)->exactMidBytes = &flatBytes[index];
index+=(*this)->exactMidBytes_size;
(*this)->exactMidBytes = &flatBytes[idx];
idx+=(*this)->exactMidBytes_size;
// 16 residualMidBits
(*this)->residualMidBits = &flatBytes[index];
(*this)->residualMidBits = &flatBytes[idx];
// calc residualMidBits_size
(*this)->residualMidBits_size = flatBytesLength - 1 - 1 - MetaDataByteLength - pde_exe->SZ_SIZE_TYPE - 4 - 4 - 4 - 1 - 8
......
......@@ -1683,7 +1683,7 @@ CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array)
return (int)size;
}
static cJSON* get_array_item(const cJSON *array, size_t index)
static cJSON* get_array_item(const cJSON *array, size_t idx)
{
cJSON *current_child = NULL;
......@@ -1693,23 +1693,23 @@ static cJSON* get_array_item(const cJSON *array, size_t index)
}
current_child = array->child;
while ((current_child != NULL) && (index > 0))
while ((current_child != NULL) && (idx > 0))
{
index--;
idx--;
current_child = current_child->next;
}
return current_child;
}
CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index)
CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int idx)
{
if (index < 0)
if (idx < 0)
{
return NULL;
}
return get_array_item(array, (size_t)index);
return get_array_item(array, (size_t)idx);
}
static cJSON *get_object_item(const cJSON * const object, const char * const name, const cJSON_bool case_sensitive)
......
......@@ -33,12 +33,12 @@ typedef struct SCompareParam {
int32_t groupOrderType;
} SCompareParam;
static bool needToMerge(SSDataBlock* pBlock, SArray* columnIndexList, int32_t index, char **buf) {
static bool needToMerge(SSDataBlock* pBlock, SArray* columnIndexList, int32_t idx, char **buf) {
int32_t ret = 0;
size_t size = taosArrayGetSize(columnIndexList);
if (size > 0) {
ret = compare_aRv(pBlock, columnIndexList, (int32_t) size, index, buf, TSDB_ORDER_ASC);
ret = compare_aRv(pBlock, columnIndexList, (int32_t) size, idx, buf, TSDB_ORDER_ASC);
}
// if ret == 0, means the result belongs to the same group
......@@ -563,9 +563,9 @@ static void savePrevOrderColumns(char** prevRow, SArray* pColumnList, SSDataBloc
int32_t size = (int32_t) taosArrayGetSize(pColumnList);
for(int32_t i = 0; i < size; ++i) {
SColIndex* index = taosArrayGet(pColumnList, i);
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, index->colIndex);
assert(index->colId == pColInfo->info.colId);
SColIndex* idx = taosArrayGet(pColumnList, i);
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, idx->colIndex);
assert(idx->colId == pColInfo->info.colId);
memcpy(prevRow[i], pColInfo->pData + pColInfo->info.bytes * rowIndex, pColInfo->info.bytes);
}
......
......@@ -152,7 +152,7 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols, int32_t typeColLength,
int32_t noteColLength) {
int32_t rowLen = 0;
SColumnIndex index = {0};
SColumnIndex idx = {0, 0};
pSql->cmd.numOfCols = numOfCols;
......@@ -163,7 +163,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
tstrncpy(f.name, "Field", sizeof(f.name));
SInternalField* pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY,
pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &idx, TSDB_DATA_TYPE_BINARY,
(TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE, -1000, (TSDB_COL_NAME_LEN - 1), false);
rowLen += ((TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE);
......@@ -173,7 +173,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
tstrncpy(f.name, "Type", sizeof(f.name));
pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY, (int16_t)(typeColLength + VARSTR_HEADER_SIZE),
pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &idx, TSDB_DATA_TYPE_BINARY, (int16_t)(typeColLength + VARSTR_HEADER_SIZE),
-1000, typeColLength, false);
rowLen += typeColLength + VARSTR_HEADER_SIZE;
......@@ -183,7 +183,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
tstrncpy(f.name, "Length", sizeof(f.name));
pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_INT, sizeof(int32_t),
pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &idx, TSDB_DATA_TYPE_INT, sizeof(int32_t),
-1000, sizeof(int32_t), false);
rowLen += sizeof(int32_t);
......@@ -193,7 +193,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
tstrncpy(f.name, "Note", sizeof(f.name));
pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY, (int16_t)(noteColLength + VARSTR_HEADER_SIZE),
pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &idx, TSDB_DATA_TYPE_BINARY, (int16_t)(noteColLength + VARSTR_HEADER_SIZE),
-1000, noteColLength, false);
rowLen += noteColLength + VARSTR_HEADER_SIZE;
......@@ -415,7 +415,7 @@ static int32_t tscGetTableTagValue(SCreateBuilder *builder, char *result) {
static int32_t tscSCreateBuildResultFields(SSqlObj *pSql, BuildType type, const char *ddl) {
int32_t rowLen = 0;
int16_t ddlLen = (int16_t)strlen(ddl);
SColumnIndex index = {0};
SColumnIndex idx = {0};
pSql->cmd.numOfCols = 2;
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd);
......@@ -433,7 +433,7 @@ static int32_t tscSCreateBuildResultFields(SSqlObj *pSql, BuildType type, const
}
SInternalField* pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY, f.bytes, -1000, f.bytes - VARSTR_HEADER_SIZE, false);
pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &idx, TSDB_DATA_TYPE_BINARY, f.bytes, -1000, f.bytes - VARSTR_HEADER_SIZE, false);
rowLen += f.bytes;
......@@ -446,7 +446,7 @@ static int32_t tscSCreateBuildResultFields(SSqlObj *pSql, BuildType type, const
}
pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY,
pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &idx, TSDB_DATA_TYPE_BINARY,
(int16_t)(ddlLen + VARSTR_HEADER_SIZE), -1000, ddlLen, false);
rowLen += ddlLen + VARSTR_HEADER_SIZE;
......
......@@ -61,8 +61,8 @@ int initMemRowBuilder(SMemRowBuilder *pBuilder, uint32_t nRows, SParsedDataColIn
return TSDB_CODE_SUCCESS;
}
int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int16_t timePrec) {
int32_t index = 0;
int tsParseTime(SStrToken *pToken, int64_t *pTime, char **next, char *err, int16_t timePrec) {
int32_t idx = 0;
SStrToken sToken;
int64_t interval;
int64_t useconds = 0;
......@@ -80,8 +80,8 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1
useconds = taosStr2int64(pToken->z);
} else {
// strptime("2001-11-12 18:31:01", "%Y-%m-%d %H:%M:%S", &tm);
if (taosParseTime(pToken->z, time, pToken->n, timePrec, tsDaylight) != TSDB_CODE_SUCCESS) {
return tscInvalidOperationMsg(error, "invalid timestamp format", pToken->z);
if (taosParseTime(pToken->z, pTime, pToken->n, timePrec, tsDaylight) != TSDB_CODE_SUCCESS) {
return tscInvalidOperationMsg(err, "invalid timestamp format", pToken->z);
}
return TSDB_CODE_SUCCESS;
......@@ -91,7 +91,7 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1
if (isspace(pToken->z[k])) continue;
if (pToken->z[k] == ',') {
*next = pTokenEnd;
*time = useconds;
*pTime = useconds;
return 0;
}
......@@ -103,17 +103,17 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1
* e.g., now+12a, now-5h
*/
SStrToken valueToken;
index = 0;
sToken = tStrGetToken(pTokenEnd, &index, false);
pTokenEnd += index;
idx = 0;
sToken = tStrGetToken(pTokenEnd, &idx, false);
pTokenEnd += idx;
if (sToken.type == TK_MINUS || sToken.type == TK_PLUS) {
index = 0;
valueToken = tStrGetToken(pTokenEnd, &index, false);
pTokenEnd += index;
idx = 0;
valueToken = tStrGetToken(pTokenEnd, &idx, false);
pTokenEnd += idx;
if (valueToken.n < 2) {
return tscInvalidOperationMsg(error, "value expected in timestamp", sToken.z);
return tscInvalidOperationMsg(err, "value expected in timestamp", sToken.z);
}
char unit = 0;
......@@ -130,7 +130,7 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1
*next = pTokenEnd;
}
*time = useconds;
*pTime = useconds;
return TSDB_CODE_SUCCESS;
}
......@@ -433,7 +433,7 @@ int32_t tsCheckTimestamp(STableDataBlocks *pDataBlocks, const char *start) {
int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, int32_t *len, char *tmpTokenBuf,
SInsertStatementParam *pInsertParam) {
int32_t index = 0;
int32_t idx = 0;
SStrToken sToken = {0};
char *row = pDataBlocks->pData + pDataBlocks->size; // skip the SSubmitBlk header
......@@ -455,9 +455,9 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i
SSchema *pSchema = &schema[colIndex]; // get colId here
index = 0;
sToken = tStrGetToken(*str, &index, true);
*str += index;
idx = 0;
sToken = tStrGetToken(*str, &idx, true);
*str += idx;
if (sToken.type == TK_QUESTION) {
if (!isParseBindParam) {
......@@ -564,7 +564,7 @@ int32_t boundIdxCompar(const void *lhs, const void *rhs) {
int32_t tsParseValues(char **str, STableDataBlocks *pDataBlock, int maxRows, SInsertStatementParam *pInsertParam,
int32_t* numOfRows, char *tmpTokenBuf) {
int32_t index = 0;
int32_t idx = 0;
int32_t code = 0;
(*numOfRows) = 0;
......@@ -584,11 +584,11 @@ int32_t tsParseValues(char **str, STableDataBlocks *pDataBlock, int maxRows, SIn
pDataBlock->rowBuilder.rowSize = extendedRowSize;
while (1) {
index = 0;
sToken = tStrGetToken(*str, &index, false);
idx = 0;
sToken = tStrGetToken(*str, &idx, false);
if (sToken.n == 0 || sToken.type != TK_LP) break;
*str += index;
*str += idx;
if ((*numOfRows) >= maxRows || pDataBlock->size + extendedRowSize >= pDataBlock->nAllocSize) {
int32_t tSize;
code = tscAllocateMemIfNeed(pDataBlock, extendedRowSize, &tSize);
......@@ -609,13 +609,13 @@ int32_t tsParseValues(char **str, STableDataBlocks *pDataBlock, int maxRows, SIn
pDataBlock->size += len;
index = 0;
sToken = tStrGetToken(*str, &index, false);
idx = 0;
sToken = tStrGetToken(*str, &idx, false);
if (sToken.n == 0 || sToken.type != TK_RP) {
return tscSQLSyntaxErrMsg(pInsertParam->msg, ") expected", *str);
}
*str += index;
*str += idx;
(*numOfRows)++;
}
......@@ -876,7 +876,7 @@ int validateTableName(char *tblName, int len, SStrToken* psTblToken, bool *dbInc
static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundColumn) {
int32_t index = 0;
int32_t idx = 0;
SStrToken sToken = {0};
SStrToken tableToken = {0};
int32_t code = TSDB_CODE_SUCCESS;
......@@ -891,14 +891,14 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
char *sql = *sqlstr;
// get the token of specified table
index = 0;
tableToken = tStrGetToken(sql, &index, false);
sql += index;
idx = 0;
tableToken = tStrGetToken(sql, &idx, false);
sql += idx;
// skip possibly exists column list
index = 0;
sToken = tStrGetToken(sql, &index, false);
sql += index;
idx = 0;
sToken = tStrGetToken(sql, &idx, false);
sql += idx;
int32_t numOfColList = 0;
......@@ -907,8 +907,8 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
*boundColumn = &sToken.z[0];
while (1) {
index = 0;
sToken = tStrGetToken(sql, &index, false);
idx = 0;
sToken = tStrGetToken(sql, &idx, false);
if (sToken.type == TK_ILLEGAL) {
return tscSQLSyntaxErrMsg(pCmd->payload, "unrecognized token", sToken.z);
......@@ -918,12 +918,12 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
break;
}
sql += index;
sql += idx;
++numOfColList;
}
sToken = tStrGetToken(sql, &index, false);
sql += index;
sToken = tStrGetToken(sql, &idx, false);
sql += idx;
}
if (numOfColList == 0 && (*boundColumn) != NULL) {
......@@ -933,9 +933,9 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, TABLE_INDEX);
if (sToken.type == TK_USING) { // create table if not exists according to the super table
index = 0;
sToken = tStrGetToken(sql, &index, false);
sql += index;
idx = 0;
sToken = tStrGetToken(sql, &idx, false);
sql += idx;
if (sToken.type == TK_ILLEGAL) {
return tscSQLSyntaxErrMsg(pCmd->payload, NULL, sql);
......@@ -980,8 +980,8 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
SParsedDataColInfo spd = {0};
tscSetBoundColumnInfo(&spd, pTagSchema, tscGetNumOfTags(pSTableMetaInfo->pTableMeta));
index = 0;
sToken = tStrGetToken(sql, &index, false);
idx = 0;
sToken = tStrGetToken(sql, &idx, false);
if (sToken.type != TK_TAGS && sToken.type != TK_LP) {
tscDestroyBoundColumnInfo(&spd);
return tscSQLSyntaxErrMsg(pInsertParam->msg, "keyword TAGS expected", sToken.z);
......@@ -1002,16 +1002,16 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
sql = end;
index = 0; // keywords of "TAGS"
sToken = tStrGetToken(sql, &index, false);
sql += index;
idx = 0; // keywords of "TAGS"
sToken = tStrGetToken(sql, &idx, false);
sql += idx;
} else {
sql += index;
sql += idx;
}
index = 0;
sToken = tStrGetToken(sql, &index, false);
sql += index;
idx = 0;
sToken = tStrGetToken(sql, &idx, false);
sql += idx;
if (sToken.type != TK_LP) {
tscDestroyBoundColumnInfo(&spd);
......@@ -1027,9 +1027,9 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
for (int i = 0; i < spd.numOfBound; ++i) {
SSchema* pSchema = &pTagSchema[spd.boundedColumns[i]];
index = 0;
sToken = tStrGetToken(sql, &index, true);
sql += index;
idx = 0;
sToken = tStrGetToken(sql, &idx, true);
sql += idx;
if (TK_ILLEGAL == sToken.type) {
tdDestroyKVRowBuilder(&kvRowBuilder);
......@@ -1101,9 +1101,9 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
free(row);
pInsertParam->tagData.data = pTag;
index = 0;
sToken = tStrGetToken(sql, &index, false);
sql += index;
idx = 0;
sToken = tStrGetToken(sql, &idx, false);
sql += idx;
if (sToken.n == 0 || sToken.type != TK_RP) {
return tscSQLSyntaxErrMsg(pInsertParam->msg, ") expected", sToken.z);
}
......@@ -1112,9 +1112,9 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
* insert into table_name using super_table(tag_name1, tag_name2) tags(tag_val1, tag_val2)
* (normal_col1, normal_col2) values(normal_col1_val, normal_col2_val);
* */
index = 0;
sToken = tStrGetToken(sql, &index, false);
sql += index;
idx = 0;
sToken = tStrGetToken(sql, &idx, false);
sql += idx;
int numOfColsAfterTags = 0;
if (sToken.type == TK_LP) {
if (*boundColumn != NULL) {
......@@ -1124,18 +1124,18 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
}
while (1) {
index = 0;
sToken = tStrGetToken(sql, &index, false);
idx = 0;
sToken = tStrGetToken(sql, &idx, false);
if (sToken.type == TK_RP) {
break;
}
if (sToken.n == 0 || sToken.type == TK_SEMI || index == 0) {
if (sToken.n == 0 || sToken.type == TK_SEMI || idx == 0) {
return tscSQLSyntaxErrMsg(pCmd->payload, "unexpected token", sql);
}
sql += index;
sql += idx;
++numOfColsAfterTags;
}
......@@ -1143,7 +1143,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
return TSDB_CODE_TSC_SQL_SYNTAX_ERROR;
}
sToken = tStrGetToken(sql, &index, false);
sToken = tStrGetToken(sql, &idx, false);
}
sql = sToken.z;
......@@ -1213,9 +1213,9 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat
int32_t code = TSDB_CODE_SUCCESS;
int32_t index = 0;
SStrToken sToken = tStrGetToken(str, &index, false);
str += index;
int32_t idx = 0;
SStrToken sToken = tStrGetToken(str, &idx, false);
str += idx;
if (sToken.type != TK_LP) {
code = tscSQLSyntaxErrMsg(pInsertParam->msg, "( is expected", sToken.z);
......@@ -1225,9 +1225,9 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat
bool isOrdered = true;
int32_t lastColIdx = -1; // last column found
while (1) {
index = 0;
sToken = tStrGetToken(str, &index, false);
str += index;
idx = 0;
sToken = tStrGetToken(str, &idx, false);
str += idx;
char tmpTokenBuf[TSDB_MAX_BYTES_PER_ROW] = {0}; // used for deleting Escape character backstick(`)
strncpy(tmpTokenBuf, sToken.z, sToken.n);
......@@ -1404,8 +1404,8 @@ int tsParseInsertSql(SSqlObj *pSql) {
tscDebug("0x%"PRIx64" create data block list hashList:%p", pSql->self, pInsertParam->pTableBlockHashList);
while (1) {
int32_t index = 0;
SStrToken sToken = tStrGetToken(str, &index, false);
int32_t idx = 0;
SStrToken sToken = tStrGetToken(str, &idx, false);
// no data in the sql string anymore.
if (sToken.n == 0) {
......@@ -1469,9 +1469,9 @@ int tsParseInsertSql(SSqlObj *pSql) {
goto _clean;
}
index = 0;
sToken = tStrGetToken(str, &index, false);
str += index;
idx = 0;
sToken = tStrGetToken(str, &idx, false);
str += idx;
if (sToken.n == 0 || (sToken.type != TK_FILE && sToken.type != TK_VALUES)) {
code = tscSQLSyntaxErrMsg(pInsertParam->msg, "keyword VALUES or FILE required", sToken.z);
......@@ -1484,13 +1484,13 @@ int tsParseInsertSql(SSqlObj *pSql) {
goto _clean;
}
index = 0;
sToken = tStrGetToken(str, &index, false);
idx = 0;
sToken = tStrGetToken(str, &idx, false);
if (sToken.type != TK_STRING && sToken.type != TK_ID) {
code = tscSQLSyntaxErrMsg(pInsertParam->msg, "file path is required following keyword FILE", sToken.z);
goto _clean;
}
str += index;
str += idx;
if (sToken.n == 0) {
code = tscSQLSyntaxErrMsg(pInsertParam->msg, "file path is required following keyword FILE", sToken.z);
goto _clean;
......@@ -1590,7 +1590,7 @@ int tsInsertInitialCheck(SSqlObj *pSql) {
return TSDB_CODE_TSC_NO_WRITE_AUTH;
}
int32_t index = 0;
int32_t idx = 0;
SSqlCmd *pCmd = &pSql->cmd;
pCmd->count = 0;
......@@ -1600,12 +1600,12 @@ int tsInsertInitialCheck(SSqlObj *pSql) {
SQueryInfo *pQueryInfo = tscGetQueryInfoS(pCmd);
TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_INSERT);
SStrToken sToken = tStrGetToken(pSql->sqlstr, &index, false);
SStrToken sToken = tStrGetToken(pSql->sqlstr, &idx, false);
if (sToken.type != TK_INSERT && sToken.type != TK_IMPORT) {
return tscSQLSyntaxErrMsg(pInsertParam->msg, NULL, sToken.z);
}
sToken = tStrGetToken(pSql->sqlstr, &index, false);
sToken = tStrGetToken(pSql->sqlstr, &idx, false);
if (sToken.type != TK_INTO) {
return tscSQLSyntaxErrMsg(pInsertParam->msg, "keyword INTO is expected", sToken.z);
}
......
......@@ -1966,14 +1966,14 @@ int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value,
return TSDB_CODE_SUCCESS;
}
static int32_t parseSmlTimeStamp(TAOS_SML_KV **pTS, const char **index, SSmlLinesInfo* info) {
static int32_t parseSmlTimeStamp(TAOS_SML_KV **pTS, const char **idx, SSmlLinesInfo* info) {
const char *start, *cur;
int32_t ret = TSDB_CODE_SUCCESS;
int len = 0;
char key[] = "ts";
char *value = NULL;
start = cur = *index;
start = cur = *idx;
*pTS = calloc(1, sizeof(TAOS_SML_KV));
while(*cur != '\0') {
......@@ -2013,8 +2013,8 @@ bool checkDuplicateKey(char *key, SHashObj *pHash, SSmlLinesInfo* info) {
return false;
}
static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash, SSmlLinesInfo* info) {
const char *cur = *index;
static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **idx, SHashObj *pHash, SSmlLinesInfo* info) {
const char *cur = *idx;
char key[TSDB_COL_NAME_LEN + 1]; // +1 to avoid key[len] over write
int16_t len = 0;
......@@ -2048,12 +2048,12 @@ static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash
memcpy(pKV->key, key, len + 1);
addEscapeCharToString(pKV->key, len);
tscDebug("SML:0x%"PRIx64" Key:%s|len:%d", info->id, pKV->key, len);
*index = cur + 1;
*idx = cur + 1;
return TSDB_CODE_SUCCESS;
}
static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **idx,
bool *is_last_kv, SSmlLinesInfo* info, bool isTag) {
const char *start, *cur;
int32_t ret = TSDB_CODE_SUCCESS;
......@@ -2077,7 +2077,7 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
val_rqoute
} val_state;
start = cur = *index;
start = cur = *idx;
tag_state = tag_common;
val_state = val_common;
......@@ -2100,17 +2100,17 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
}
if (*cur == '"') {
if (cur == *index) {
if (cur == *idx) {
tag_state = tag_lqoute;
}
cur += 1;
len += 1;
break;
} else if (*cur == 'L') {
line_len = strlen(*index);
line_len = strlen(*idx);
/* common character at the end */
if (cur + 1 >= *index + line_len) {
if (cur + 1 >= *idx + line_len) {
*is_last_kv = true;
kv_done = true;
break;
......@@ -2118,7 +2118,7 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
if (*(cur + 1) == '"') {
/* string starts here */
if (cur + 1 == *index + 1) {
if (cur + 1 == *idx + 1) {
tag_state = tag_lqoute;
}
cur += 2;
......@@ -2224,7 +2224,7 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
}
if (*cur == '"') {
if (cur == *index) {
if (cur == *idx) {
val_state = val_lqoute;
} else {
if (*(cur - 1) != '\\') {
......@@ -2238,10 +2238,10 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
len += 1;
break;
} else if (*cur == 'L') {
line_len = strlen(*index);
line_len = strlen(*idx);
/* common character at the end */
if (cur + 1 >= *index + line_len) {
if (cur + 1 >= *idx + line_len) {
*is_last_kv = true;
kv_done = true;
break;
......@@ -2249,13 +2249,13 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
if (*(cur + 1) == '"') {
/* string starts here */
if (cur + 1 == *index + 1) {
if (cur + 1 == *idx + 1) {
val_state = val_lqoute;
cur += 2;
len += 2;
} else {
/* MUST at the end of string */
if (cur + 2 >= *index + line_len) {
if (cur + 2 >= *idx + line_len) {
cur += 2;
len += 2;
*is_last_kv = true;
......@@ -2385,7 +2385,7 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
}
free(value);
*index = (*cur == '\0') ? cur : cur + 1;
*idx = (*cur == '\0') ? cur : cur + 1;
return ret;
error:
......@@ -2395,9 +2395,9 @@ error:
return ret;
}
static int32_t parseSmlMeasurement(TAOS_SML_DATA_POINT *pSml, const char **index,
static int32_t parseSmlMeasurement(TAOS_SML_DATA_POINT *pSml, const char **idx,
uint8_t *has_tags, SSmlLinesInfo* info) {
const char *cur = *index;
const char *cur = *idx;
int16_t len = 0;
pSml->stableName = calloc(TSDB_TABLE_NAME_LEN + TS_BACKQUOTE_CHAR_SIZE, 1);
......@@ -2441,7 +2441,7 @@ static int32_t parseSmlMeasurement(TAOS_SML_DATA_POINT *pSml, const char **index
return TSDB_CODE_TSC_LINE_SYNTAX_ERROR;
}
addEscapeCharToString(pSml->stableName, len);
*index = cur + 1;
*idx = cur + 1;
tscDebug("SML:0x%"PRIx64" Stable name in measurement:%s|len:%d", info->id, pSml->stableName, len);
return TSDB_CODE_SUCCESS;
......@@ -2464,10 +2464,10 @@ int32_t isValidChildTableName(const char *pTbName, int16_t len, SSmlLinesInfo* i
static int32_t parseSmlKvPairs(TAOS_SML_KV **pKVs, int *num_kvs,
const char **index, bool isField,
const char **idx, bool isField,
TAOS_SML_DATA_POINT* smlData, SHashObj *pHash,
SSmlLinesInfo* info) {
const char *cur = *index;
const char *cur = *idx;
int32_t ret = TSDB_CODE_SUCCESS;
TAOS_SML_KV *pkv;
bool is_last_kv = false;
......@@ -2555,7 +2555,7 @@ static int32_t parseSmlKvPairs(TAOS_SML_KV **pKVs, int *num_kvs,
error:
return ret;
done:
*index = cur;
*idx = cur;
return ret;
}
......@@ -2575,13 +2575,13 @@ static void moveTimeStampToFirstKv(TAOS_SML_DATA_POINT** smlData, TAOS_SML_KV *t
}
int32_t tscParseLine(const char* sql, TAOS_SML_DATA_POINT* smlData, SSmlLinesInfo* info) {
const char* index = sql;
const char* idx = sql;
int32_t ret = TSDB_CODE_SUCCESS;
uint8_t has_tags = 0;
TAOS_SML_KV *timestamp = NULL;
SHashObj *keyHashTable = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false);
ret = parseSmlMeasurement(smlData, &index, &has_tags, info);
ret = parseSmlMeasurement(smlData, &idx, &has_tags, info);
if (ret) {
tscError("SML:0x%"PRIx64" Unable to parse measurement", info->id);
taosHashCleanup(keyHashTable);
......@@ -2591,7 +2591,7 @@ int32_t tscParseLine(const char* sql, TAOS_SML_DATA_POINT* smlData, SSmlLinesInf
//Parse Tags
if (has_tags) {
ret = parseSmlKvPairs(&smlData->tags, &smlData->tagNum, &index, false, smlData, keyHashTable, info);
ret = parseSmlKvPairs(&smlData->tags, &smlData->tagNum, &idx, false, smlData, keyHashTable, info);
if (ret) {
tscError("SML:0x%"PRIx64" Unable to parse tag", info->id);
taosHashCleanup(keyHashTable);
......@@ -2601,7 +2601,7 @@ int32_t tscParseLine(const char* sql, TAOS_SML_DATA_POINT* smlData, SSmlLinesInf
tscDebug("SML:0x%"PRIx64" Parse tags finished, num of tags:%d", info->id, smlData->tagNum);
//Parse fields
ret = parseSmlKvPairs(&smlData->fields, &smlData->fieldNum, &index, true, smlData, keyHashTable, info);
ret = parseSmlKvPairs(&smlData->fields, &smlData->fieldNum, &idx, true, smlData, keyHashTable, info);
if (ret) {
tscError("SML:0x%"PRIx64" Unable to parse field", info->id);
taosHashCleanup(keyHashTable);
......@@ -2611,7 +2611,7 @@ int32_t tscParseLine(const char* sql, TAOS_SML_DATA_POINT* smlData, SSmlLinesInf
taosHashCleanup(keyHashTable);
//Parse timestamp
ret = parseSmlTimeStamp(&timestamp, &index, info);
ret = parseSmlTimeStamp(&timestamp, &idx, info);
if (ret) {
tscError("SML:0x%"PRIx64" Unable to parse timestamp", info->id);
return ret;
......
......@@ -33,8 +33,8 @@ static uint64_t genUID() {
return id;
}
static int32_t parseTelnetMetric(TAOS_SML_DATA_POINT *pSml, const char **index, SSmlLinesInfo* info) {
const char *cur = *index;
static int32_t parseTelnetMetric(TAOS_SML_DATA_POINT *pSml, const char **idx, SSmlLinesInfo* info) {
const char *cur = *idx;
uint16_t len = 0;
pSml->stableName = tcalloc(TSDB_TABLE_NAME_LEN + TS_BACKQUOTE_CHAR_SIZE, 1);
......@@ -76,13 +76,13 @@ static int32_t parseTelnetMetric(TAOS_SML_DATA_POINT *pSml, const char **index,
}
addEscapeCharToString(pSml->stableName, len);
*index = cur + 1;
*idx = cur + 1;
tscDebug("OTD:0x%"PRIx64" Stable name in metric:%s|len:%d", info->id, pSml->stableName, len);
return TSDB_CODE_SUCCESS;
}
static int32_t parseTelnetTimeStamp(TAOS_SML_KV **pTS, int *num_kvs, const char **index, SSmlLinesInfo* info) {
static int32_t parseTelnetTimeStamp(TAOS_SML_KV **pTS, int *num_kvs, const char **idx, SSmlLinesInfo* info) {
//Timestamp must be the first KV to parse
assert(*num_kvs == 0);
......@@ -92,7 +92,7 @@ static int32_t parseTelnetTimeStamp(TAOS_SML_KV **pTS, int *num_kvs, const char
char key[] = OTD_TIMESTAMP_COLUMN_NAME;
char *value = NULL;
start = cur = *index;
start = cur = *idx;
//allocate fields for timestamp and value
*pTS = tcalloc(OTD_MAX_FIELDS_NUM, sizeof(TAOS_SML_KV));
......@@ -130,12 +130,12 @@ static int32_t parseTelnetTimeStamp(TAOS_SML_KV **pTS, int *num_kvs, const char
addEscapeCharToString((*pTS)->key, (int32_t)strlen(key));
*num_kvs += 1;
*index = cur + 1;
*idx = cur + 1;
return ret;
}
static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const char **index, SSmlLinesInfo* info) {
static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const char **idx, SSmlLinesInfo* info) {
//skip timestamp
TAOS_SML_KV *pVal = *pKVs + 1;
const char *start, *cur;
......@@ -145,7 +145,7 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch
char key[] = OTD_METRIC_VALUE_COLUMN_NAME;
char *value = NULL;
start = cur = *index;
start = cur = *idx;
//if metric value is string
if (*cur == '"') {
......@@ -201,12 +201,12 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch
addEscapeCharToString(pVal->key, (int32_t)strlen(pVal->key));
*num_kvs += 1;
*index = cur + 1;
*idx = cur + 1;
return ret;
}
static int32_t parseTelnetTagKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash, SSmlLinesInfo* info) {
const char *cur = *index;
static int32_t parseTelnetTagKey(TAOS_SML_KV *pKV, const char **idx, SHashObj *pHash, SSmlLinesInfo* info) {
const char *cur = *idx;
char key[TSDB_COL_NAME_LEN];
uint16_t len = 0;
......@@ -244,17 +244,17 @@ static int32_t parseTelnetTagKey(TAOS_SML_KV *pKV, const char **index, SHashObj
memcpy(pKV->key, key, len + 1);
addEscapeCharToString(pKV->key, len);
//tscDebug("OTD:0x%"PRIx64" Key:%s|len:%d", info->id, pKV->key, len);
*index = cur + 1;
*idx = cur + 1;
return TSDB_CODE_SUCCESS;
}
static int32_t parseTelnetTagValue(TAOS_SML_KV *pKV, const char **index,
static int32_t parseTelnetTagValue(TAOS_SML_KV *pKV, const char **idx,
bool *is_last_kv, SSmlLinesInfo* info) {
const char *start, *cur;
char *value = NULL;
uint16_t len = 0;
start = cur = *index;
start = cur = *idx;
while (1) {
// whitespace or '\0' identifies a value
......@@ -290,14 +290,14 @@ static int32_t parseTelnetTagValue(TAOS_SML_KV *pKV, const char **index,
}
tfree(value);
*index = (*cur == '\0') ? cur : cur + 1;
*idx = (*cur == '\0') ? cur : cur + 1;
return TSDB_CODE_SUCCESS;
}
static int32_t parseTelnetTagKvs(TAOS_SML_KV **pKVs, int *num_kvs,
const char **index, char **childTableName,
const char **idx, char **childTableName,
SHashObj *pHash, SSmlLinesInfo* info) {
const char *cur = *index;
const char *cur = *idx;
int32_t ret = TSDB_CODE_SUCCESS;
TAOS_SML_KV *pkv;
bool is_last_kv = false;
......@@ -357,11 +357,11 @@ static int32_t parseTelnetTagKvs(TAOS_SML_KV **pKVs, int *num_kvs,
}
static int32_t tscParseTelnetLine(const char* line, TAOS_SML_DATA_POINT* smlData, SSmlLinesInfo* info) {
const char* index = line;
const char* idx = line;
int32_t ret = TSDB_CODE_SUCCESS;
//Parse metric
ret = parseTelnetMetric(smlData, &index, info);
ret = parseTelnetMetric(smlData, &idx, info);
if (ret) {
tscError("OTD:0x%"PRIx64" Unable to parse metric", info->id);
return ret;
......@@ -369,7 +369,7 @@ static int32_t tscParseTelnetLine(const char* line, TAOS_SML_DATA_POINT* smlData
tscDebug("OTD:0x%"PRIx64" Parse metric finished", info->id);
//Parse timestamp
ret = parseTelnetTimeStamp(&smlData->fields, &smlData->fieldNum, &index, info);
ret = parseTelnetTimeStamp(&smlData->fields, &smlData->fieldNum, &idx, info);
if (ret) {
tscError("OTD:0x%"PRIx64" Unable to parse timestamp", info->id);
return ret;
......@@ -377,7 +377,7 @@ static int32_t tscParseTelnetLine(const char* line, TAOS_SML_DATA_POINT* smlData
tscDebug("OTD:0x%"PRIx64" Parse timestamp finished", info->id);
//Parse value
ret = parseTelnetMetricValue(&smlData->fields, &smlData->fieldNum, &index, info);
ret = parseTelnetMetricValue(&smlData->fields, &smlData->fieldNum, &idx, info);
if (ret) {
tscError("OTD:0x%"PRIx64" Unable to parse metric value", info->id);
return ret;
......@@ -386,7 +386,7 @@ static int32_t tscParseTelnetLine(const char* line, TAOS_SML_DATA_POINT* smlData
//Parse tagKVs
SHashObj *keyHashTable = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false);
ret = parseTelnetTagKvs(&smlData->tags, &smlData->tagNum, &index, &smlData->childTableName, keyHashTable, info);
ret = parseTelnetTagKvs(&smlData->tags, &smlData->tagNum, &idx, &smlData->childTableName, keyHashTable, info);
if (ret) {
tscError("OTD:0x%"PRIx64" Unable to parse tags", info->id);
taosHashCleanup(keyHashTable);
......
......@@ -121,11 +121,11 @@ static int normalStmtAddPart(SNormalStmt* stmt, bool isParam, char* str, uint32_
return TSDB_CODE_SUCCESS;
}
static int normalStmtBindParam(STscStmt* stmt, TAOS_BIND* bind) {
static int normalStmtBindParam(STscStmt* stmt, TAOS_BIND* pBind) {
SNormalStmt* normal = &stmt->normal;
for (uint16_t i = 0; i < normal->numParams; ++i) {
TAOS_BIND* tb = bind + i;
TAOS_BIND* tb = pBind + i;
tVariant* var = normal->params + i;
tVariantDestroy(var);
......@@ -383,8 +383,8 @@ int32_t fillTablesColumnsNull(SSqlObj* pSql) {
////////////////////////////////////////////////////////////////////////////////
// functions for insertion statement preparation
static FORCE_INLINE int doBindParam(STableDataBlocks* pBlock, char* data, SParamInfo* param, TAOS_BIND* bind, int32_t colNum) {
if (bind->is_null != NULL && *(bind->is_null)) {
static FORCE_INLINE int doBindParam(STableDataBlocks* pBlock, char* data, SParamInfo* param, TAOS_BIND* pBind, int32_t colNum) {
if (pBind->is_null != NULL && *(pBind->is_null)) {
setNull(data + param->offset, param->type, param->bytes);
return TSDB_CODE_SUCCESS;
}
......@@ -772,7 +772,7 @@ static FORCE_INLINE int doBindParam(STableDataBlocks* pBlock, char* data, SParam
}
#endif
if (bind->buffer_type != param->type) {
if (pBind->buffer_type != param->type) {
tscError("column type mismatch");
return TSDB_CODE_TSC_INVALID_VALUE;
}
......@@ -782,39 +782,39 @@ static FORCE_INLINE int doBindParam(STableDataBlocks* pBlock, char* data, SParam
case TSDB_DATA_TYPE_BOOL:
case TSDB_DATA_TYPE_TINYINT:
case TSDB_DATA_TYPE_UTINYINT:
*(uint8_t *)(data + param->offset) = *(uint8_t *)bind->buffer;
*(uint8_t *)(data + param->offset) = *(uint8_t *)pBind->buffer;
break;
case TSDB_DATA_TYPE_SMALLINT:
case TSDB_DATA_TYPE_USMALLINT:
*(uint16_t *)(data + param->offset) = *(uint16_t *)bind->buffer;
*(uint16_t *)(data + param->offset) = *(uint16_t *)pBind->buffer;
break;
case TSDB_DATA_TYPE_INT:
case TSDB_DATA_TYPE_UINT:
case TSDB_DATA_TYPE_FLOAT:
*(uint32_t *)(data + param->offset) = *(uint32_t *)bind->buffer;
*(uint32_t *)(data + param->offset) = *(uint32_t *)pBind->buffer;
break;
case TSDB_DATA_TYPE_BIGINT:
case TSDB_DATA_TYPE_UBIGINT:
case TSDB_DATA_TYPE_DOUBLE:
case TSDB_DATA_TYPE_TIMESTAMP:
*(uint64_t *)(data + param->offset) = *(uint64_t *)bind->buffer;
*(uint64_t *)(data + param->offset) = *(uint64_t *)pBind->buffer;
break;
case TSDB_DATA_TYPE_BINARY:
if ((*bind->length) > (uintptr_t)param->bytes) {
if ((*pBind->length) > (uintptr_t)param->bytes) {
tscError("column length is too big");
return TSDB_CODE_TSC_INVALID_VALUE;
}
size = (short)*bind->length;
STR_WITH_SIZE_TO_VARSTR(data + param->offset, bind->buffer, size);
size = (short)*pBind->length;
STR_WITH_SIZE_TO_VARSTR(data + param->offset, pBind->buffer, size);
return TSDB_CODE_SUCCESS;
case TSDB_DATA_TYPE_NCHAR: {
int32_t output = 0;
if (!taosMbsToUcs4(bind->buffer, *bind->length, varDataVal(data + param->offset), param->bytes - VARSTR_HEADER_SIZE, &output)) {
if (!taosMbsToUcs4(pBind->buffer, *pBind->length, varDataVal(data + param->offset), param->bytes - VARSTR_HEADER_SIZE, &output)) {
tscError("convert nchar failed");
return TSDB_CODE_TSC_INVALID_VALUE;
}
......@@ -889,27 +889,27 @@ static int32_t insertStmtGenBlock(STscStmt* pStmt, STableDataBlocks** pBlock, ST
}
static int doBindBatchParam(STableDataBlocks* pBlock, SParamInfo* param, TAOS_MULTI_BIND* bind, int32_t rowNum) {
if (bind->buffer_type != param->type || !isValidDataType(param->type)) {
static int doBindBatchParam(STableDataBlocks* pBlock, SParamInfo* param, TAOS_MULTI_BIND* pBind, int32_t rowNum) {
if (pBind->buffer_type != param->type || !isValidDataType(param->type)) {
tscError("column mismatch or invalid");
return TSDB_CODE_TSC_INVALID_VALUE;
}
if (IS_VAR_DATA_TYPE(param->type) && bind->length == NULL) {
if (IS_VAR_DATA_TYPE(param->type) && pBind->length == NULL) {
tscError("BINARY/NCHAR no length");
return TSDB_CODE_TSC_INVALID_VALUE;
}
for (int i = 0; i < bind->num; ++i) {
for (int i = 0; i < pBind->num; ++i) {
char* data = pBlock->pData + sizeof(SSubmitBlk) + pBlock->rowSize * (rowNum + i);
if (bind->is_null != NULL && bind->is_null[i]) {
if (pBind->is_null != NULL && pBind->is_null[i]) {
setNull(data + param->offset, param->type, param->bytes);
continue;
}
if (!IS_VAR_DATA_TYPE(param->type)) {
memcpy(data + param->offset, (char *)bind->buffer + bind->buffer_length * i, tDataTypes[param->type].bytes);
memcpy(data + param->offset, (char *)pBind->buffer + pBind->buffer_length * i, tDataTypes[param->type].bytes);
if (param->offset == 0) {
if (tsCheckTimestamp(pBlock, data + param->offset) != TSDB_CODE_SUCCESS) {
......@@ -918,21 +918,21 @@ static int doBindBatchParam(STableDataBlocks* pBlock, SParamInfo* param, TAOS_MU
}
}
} else if (param->type == TSDB_DATA_TYPE_BINARY) {
if (bind->length[i] > (uintptr_t)param->bytes) {
tscError("binary length too long, ignore it, max:%d, actual:%d", param->bytes, (int32_t)bind->length[i]);
if (pBind->length[i] > (uintptr_t)param->bytes) {
tscError("binary length too long, ignore it, max:%d, actual:%d", param->bytes, (int32_t)pBind->length[i]);
return TSDB_CODE_TSC_INVALID_VALUE;
}
int16_t bsize = (short)bind->length[i];
STR_WITH_SIZE_TO_VARSTR(data + param->offset, (char *)bind->buffer + bind->buffer_length * i, bsize);
int16_t bsize = (short)pBind->length[i];
STR_WITH_SIZE_TO_VARSTR(data + param->offset, (char *)pBind->buffer + pBind->buffer_length * i, bsize);
} else if (param->type == TSDB_DATA_TYPE_NCHAR) {
if (bind->length[i] > (uintptr_t)param->bytes) {
tscError("nchar string length too long, ignore it, max:%d, actual:%d", param->bytes, (int32_t)bind->length[i]);
if (pBind->length[i] > (uintptr_t)param->bytes) {
tscError("nchar string length too long, ignore it, max:%d, actual:%d", param->bytes, (int32_t)pBind->length[i]);
return TSDB_CODE_TSC_INVALID_VALUE;
}
int32_t output = 0;
if (!taosMbsToUcs4((char *)bind->buffer + bind->buffer_length * i, bind->length[i], varDataVal(data + param->offset), param->bytes - VARSTR_HEADER_SIZE, &output)) {
tscError("convert nchar string to UCS4_LE failed:%s", (char*)((char *)bind->buffer + bind->buffer_length * i));
if (!taosMbsToUcs4((char *)pBind->buffer + pBind->buffer_length * i, pBind->length[i], varDataVal(data + param->offset), param->bytes - VARSTR_HEADER_SIZE, &output)) {
tscError("convert nchar string to UCS4_LE failed:%s", (char*)((char *)pBind->buffer + pBind->buffer_length * i));
return TSDB_CODE_TSC_INVALID_VALUE;
}
......@@ -943,7 +943,7 @@ static int doBindBatchParam(STableDataBlocks* pBlock, SParamInfo* param, TAOS_MU
return TSDB_CODE_SUCCESS;
}
static int insertStmtBindParam(STscStmt* stmt, TAOS_BIND* bind) {
static int insertStmtBindParam(STscStmt* stmt, TAOS_BIND* pBind) {
SSqlCmd* pCmd = &stmt->pSql->cmd;
STscStmt* pStmt = (STscStmt*)stmt;
......@@ -995,7 +995,7 @@ static int insertStmtBindParam(STscStmt* stmt, TAOS_BIND* bind) {
for (uint32_t j = 0; j < pBlock->numOfParams; ++j) {
SParamInfo* param = &pBlock->params[j];
int code = doBindParam(pBlock, data, param, &bind[param->idx], 1);
int code = doBindParam(pBlock, data, param, &pBind[param->idx], 1);
if (code != TSDB_CODE_SUCCESS) {
tscDebug("0x%"PRIx64" bind column %d: type mismatch or invalid", pStmt->pSql->self, param->idx);
return invalidOperationMsg(tscGetErrorMsgPayload(&stmt->pSql->cmd), "bind column type mismatch or invalid");
......@@ -1006,10 +1006,10 @@ static int insertStmtBindParam(STscStmt* stmt, TAOS_BIND* bind) {
}
static int insertStmtBindParamBatch(STscStmt* stmt, TAOS_MULTI_BIND* bind, int colIdx) {
static int insertStmtBindParamBatch(STscStmt* stmt, TAOS_MULTI_BIND* pBind, int colIdx) {
SSqlCmd* pCmd = &stmt->pSql->cmd;
STscStmt* pStmt = (STscStmt*)stmt;
int rowNum = bind->num;
int rowNum = pBind->num;
STableDataBlocks* pBlock = NULL;
......@@ -1063,12 +1063,12 @@ static int insertStmtBindParamBatch(STscStmt* stmt, TAOS_MULTI_BIND* bind, int c
if (colIdx == -1) {
for (uint32_t j = 0; j < pBlock->numOfParams; ++j) {
SParamInfo* param = &pBlock->params[j];
if (bind[param->idx].num != rowNum) {
tscError("0x%"PRIx64" param %d: num[%d:%d] not match", pStmt->pSql->self, param->idx, rowNum, bind[param->idx].num);
if (pBind[param->idx].num != rowNum) {
tscError("0x%"PRIx64" param %d: num[%d:%d] not match", pStmt->pSql->self, param->idx, rowNum, pBind[param->idx].num);
return invalidOperationMsg(tscGetErrorMsgPayload(&stmt->pSql->cmd), "bind row num mismatch");
}
int code = doBindBatchParam(pBlock, param, &bind[param->idx], pCmd->batchSize);
int code = doBindBatchParam(pBlock, param, &pBind[param->idx], pCmd->batchSize);
if (code != TSDB_CODE_SUCCESS) {
tscError("0x%"PRIx64" bind column %d: type mismatch or invalid", pStmt->pSql->self, param->idx);
return invalidOperationMsg(tscGetErrorMsgPayload(&stmt->pSql->cmd), "bind column type mismatch or invalid");
......@@ -1079,7 +1079,7 @@ static int insertStmtBindParamBatch(STscStmt* stmt, TAOS_MULTI_BIND* bind, int c
} else {
SParamInfo* param = &pBlock->params[colIdx];
int code = doBindBatchParam(pBlock, param, bind, pCmd->batchSize);
int code = doBindBatchParam(pBlock, param, pBind, pCmd->batchSize);
if (code != TSDB_CODE_SUCCESS) {
tscError("0x%"PRIx64" bind column %d: type mismatch or invalid", pStmt->pSql->self, param->idx);
return invalidOperationMsg(tscGetErrorMsgPayload(&stmt->pSql->cmd), "bind column type mismatch or invalid");
......@@ -1312,8 +1312,8 @@ int stmtParseInsertTbTags(SSqlObj* pSql, STscStmt* pStmt) {
return ret;
}
int32_t index = 0;
SStrToken sToken = tStrGetToken(pCmd->insertParam.sql, &index, false);
int32_t idx = 0;
SStrToken sToken = tStrGetToken(pCmd->insertParam.sql, &idx, false);
if (sToken.n == 0) {
tscError("table is is expected, sql:%s", pCmd->insertParam.sql);
return tscSQLSyntaxErrMsg(pCmd->payload, "table name is expected", pCmd->insertParam.sql);
......@@ -1333,7 +1333,7 @@ int stmtParseInsertTbTags(SSqlObj* pSql, STscStmt* pStmt) {
pStmt->mtb.tagSet = true;
sToken = tStrGetToken(pCmd->insertParam.sql, &index, false);
sToken = tStrGetToken(pCmd->insertParam.sql, &idx, false);
if (sToken.n > 0 && (sToken.type == TK_VALUES || sToken.type == TK_LP)) {
return TSDB_CODE_SUCCESS;
}
......@@ -1343,14 +1343,14 @@ int stmtParseInsertTbTags(SSqlObj* pSql, STscStmt* pStmt) {
return tscSQLSyntaxErrMsg(pCmd->payload, "keywords USING is expected", sToken.z ? sToken.z : pCmd->insertParam.sql);
}
sToken = tStrGetToken(pCmd->insertParam.sql, &index, false);
sToken = tStrGetToken(pCmd->insertParam.sql, &idx, false);
if (sToken.n <= 0 || ((sToken.type != TK_ID) && (sToken.type != TK_STRING))) {
tscError("invalid token, sql:%s", pCmd->insertParam.sql);
return tscSQLSyntaxErrMsg(pCmd->payload, "invalid token", sToken.z ? sToken.z : pCmd->insertParam.sql);
}
pStmt->mtb.stbname = sToken;
sToken = tStrGetToken(pCmd->insertParam.sql, &index, false);
sToken = tStrGetToken(pCmd->insertParam.sql, &idx, false);
if (sToken.n <= 0 || ((sToken.type != TK_TAGS) && (sToken.type != TK_LP))) {
tscError("invalid token, sql:%s", pCmd->insertParam.sql);
return tscSQLSyntaxErrMsg(pCmd->payload, "invalid token", sToken.z ? sToken.z : pCmd->insertParam.sql);
......@@ -1361,9 +1361,9 @@ int stmtParseInsertTbTags(SSqlObj* pSql, STscStmt* pStmt) {
if (sToken.type == TK_LP) {
pStmt->mtb.tagColSet = true;
pStmt->mtb.tagCols = sToken;
int32_t tagColsStart = index;
int32_t tagColsStart = idx;
while (1) {
sToken = tStrGetToken(pCmd->insertParam.sql, &index, false);
sToken = tStrGetToken(pCmd->insertParam.sql, &idx, false);
if (sToken.type == TK_ILLEGAL) {
return tscSQLSyntaxErrMsg(pCmd->payload, "unrecognized token", sToken.z);
}
......@@ -1378,16 +1378,16 @@ int stmtParseInsertTbTags(SSqlObj* pSql, STscStmt* pStmt) {
tscError("tag column list expected, sql:%s", pCmd->insertParam.sql);
return tscSQLSyntaxErrMsg(pCmd->payload, "tag column list expected", pCmd->insertParam.sql);
}
pStmt->mtb.tagCols.n = index - tagColsStart + 1;
pStmt->mtb.tagCols.n = idx - tagColsStart + 1;
sToken = tStrGetToken(pCmd->insertParam.sql, &index, false);
sToken = tStrGetToken(pCmd->insertParam.sql, &idx, false);
if (sToken.n <= 0 || sToken.type != TK_TAGS) {
tscError("keyword TAGS expected, sql:%s", pCmd->insertParam.sql);
return tscSQLSyntaxErrMsg(pCmd->payload, "keyword TAGS expected", sToken.z ? sToken.z : pCmd->insertParam.sql);
}
}
sToken = tStrGetToken(pCmd->insertParam.sql, &index, false);
sToken = tStrGetToken(pCmd->insertParam.sql, &idx, false);
if (sToken.n <= 0 || sToken.type != TK_LP) {
tscError("( expected, sql:%s", pCmd->insertParam.sql);
return tscSQLSyntaxErrMsg(pCmd->payload, "( expected", sToken.z ? sToken.z : pCmd->insertParam.sql);
......@@ -1398,7 +1398,7 @@ int stmtParseInsertTbTags(SSqlObj* pSql, STscStmt* pStmt) {
int32_t loopCont = 1;
while (loopCont) {
sToken = tStrGetToken(pCmd->insertParam.sql, &index, false);
sToken = tStrGetToken(pCmd->insertParam.sql, &idx, false);
if (sToken.n <= 0) {
tscError("unexpected sql end, sql:%s", pCmd->insertParam.sql);
return tscSQLSyntaxErrMsg(pCmd->payload, "unexpected sql end", pCmd->insertParam.sql);
......@@ -1429,7 +1429,7 @@ int stmtParseInsertTbTags(SSqlObj* pSql, STscStmt* pStmt) {
return tscSQLSyntaxErrMsg(pCmd->payload, "not match tags", pCmd->insertParam.sql);
}
sToken = tStrGetToken(pCmd->insertParam.sql, &index, false);
sToken = tStrGetToken(pCmd->insertParam.sql, &idx, false);
if (sToken.n <= 0 || (sToken.type != TK_VALUES && sToken.type != TK_LP)) {
tscError("sql error, sql:%s", pCmd->insertParam.sql);
return tscSQLSyntaxErrMsg(pCmd->payload, "sql error", sToken.z ? sToken.z : pCmd->insertParam.sql);
......@@ -1944,7 +1944,7 @@ int taos_stmt_close(TAOS_STMT* stmt) {
STMT_RET(TSDB_CODE_SUCCESS);
}
int taos_stmt_bind_param(TAOS_STMT* stmt, TAOS_BIND* bind) {
int taos_stmt_bind_param(TAOS_STMT* stmt, TAOS_BIND* pBind) {
STscStmt* pStmt = (STscStmt*)stmt;
STMT_CHECK
......@@ -1965,18 +1965,18 @@ int taos_stmt_bind_param(TAOS_STMT* stmt, TAOS_BIND* bind) {
tscDebug("tableId:%" PRIu64 ", try to bind one row", pStmt->mtb.currentUid);
STMT_RET(insertStmtBindParam(pStmt, bind));
STMT_RET(insertStmtBindParam(pStmt, pBind));
} else {
STMT_RET(normalStmtBindParam(pStmt, bind));
STMT_RET(normalStmtBindParam(pStmt, pBind));
}
}
int taos_stmt_bind_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind) {
int taos_stmt_bind_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIND* pBind) {
STscStmt* pStmt = (STscStmt*)stmt;
STMT_CHECK
if (bind == NULL || bind->num <= 0 || bind->num > INT16_MAX) {
if (pBind == NULL || pBind->num <= 0 || pBind->num > INT16_MAX) {
tscError("0x%"PRIx64" invalid parameter", pStmt->pSql->self);
STMT_RET(invalidOperationMsg(tscGetErrorMsgPayload(&pStmt->pSql->cmd), "invalid bind param"));
}
......@@ -2000,21 +2000,21 @@ int taos_stmt_bind_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind) {
pStmt->last = STMT_BIND;
STMT_RET(insertStmtBindParamBatch(pStmt, bind, -1));
STMT_RET(insertStmtBindParamBatch(pStmt, pBind, -1));
}
int taos_stmt_bind_single_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int colIdx) {
int taos_stmt_bind_single_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIND* pBind, int colIdx) {
STscStmt* pStmt = (STscStmt*)stmt;
STMT_CHECK
if (bind == NULL) {
if (pBind == NULL) {
tscError("0x%" PRIx64 " invalid parameter: bind is NULL", pStmt->pSql->self);
STMT_RET(invalidOperationMsg(tscGetErrorMsgPayload(&pStmt->pSql->cmd), "invalid bind param: bind is NULL"));
}
if (bind->num <= 0 || bind->num > INT16_MAX) {
if (pBind->num <= 0 || pBind->num > INT16_MAX) {
char errMsg[128];
sprintf(errMsg, "invalid parameter: bind->num:%d out of range [0, %d)", bind->num, INT16_MAX);
sprintf(errMsg, "invalid parameter: bind->num:%d out of range [0, %d)", pBind->num, INT16_MAX);
tscError("0x%" PRIx64 " %s", pStmt->pSql->self, errMsg);
STMT_RET(invalidOperationMsg(tscGetErrorMsgPayload(&pStmt->pSql->cmd), errMsg));
}
......@@ -2045,7 +2045,7 @@ int taos_stmt_bind_single_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, in
pStmt->last = STMT_BIND_COL;
STMT_RET(insertStmtBindParamBatch(pStmt, bind, colIdx));
STMT_RET(insertStmtBindParamBatch(pStmt, pBind, colIdx));
}
int taos_stmt_add_batch(TAOS_STMT* stmt) {
......
此差异已折叠。
......@@ -748,13 +748,13 @@ static char *doSerializeTableInfo(SQueryTableMsg *pQueryMsg, SSqlObj *pSql, STab
int32_t vgId = -1;
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
int32_t index = pTableMetaInfo->vgroupIndex;
assert(index >= 0);
int32_t idx = pTableMetaInfo->vgroupIndex;
assert(idx >= 0);
SVgroupMsg* pVgroupInfo = NULL;
if (pTableMetaInfo->vgroupList && pTableMetaInfo->vgroupList->numOfVgroups > 0) {
assert(index < pTableMetaInfo->vgroupList->numOfVgroups);
pVgroupInfo = &pTableMetaInfo->vgroupList->vgroups[index];
assert(idx < pTableMetaInfo->vgroupList->numOfVgroups);
pVgroupInfo = &pTableMetaInfo->vgroupList->vgroups[idx];
} else {
tscError("0x%"PRIx64" No vgroup info found", pSql->self);
......@@ -764,7 +764,7 @@ static char *doSerializeTableInfo(SQueryTableMsg *pQueryMsg, SSqlObj *pSql, STab
vgId = pVgroupInfo->vgId;
tscSetDnodeEpSet(&pSql->epSet, pVgroupInfo);
tscDebug("0x%"PRIx64" query on stable, vgIndex:%d, numOfVgroups:%d", pSql->self, index, pTableMetaInfo->vgroupList->numOfVgroups);
tscDebug("0x%"PRIx64" query on stable, vgIndex:%d, numOfVgroups:%d", pSql->self, idx, pTableMetaInfo->vgroupList->numOfVgroups);
} else {
vgId = pTableMeta->vgId;
......@@ -786,11 +786,11 @@ static char *doSerializeTableInfo(SQueryTableMsg *pQueryMsg, SSqlObj *pSql, STab
pQueryMsg->numOfTables = htonl(1); // set the number of tables
pMsg += sizeof(STableIdInfo);
} else { // it is a subquery of the super table query, this EP info is acquired from vgroupInfo
int32_t index = pTableMetaInfo->vgroupIndex;
int32_t idx = pTableMetaInfo->vgroupIndex;
int32_t numOfVgroups = (int32_t)taosArrayGetSize(pTableMetaInfo->pVgroupTables);
assert(index >= 0 && index < numOfVgroups);
assert(idx >= 0 && idx < numOfVgroups);
SVgroupTableInfo* pTableIdList = taosArrayGet(pTableMetaInfo->pVgroupTables, index);
SVgroupTableInfo* pTableIdList = taosArrayGet(pTableMetaInfo->pVgroupTables, idx);
// set the vgroup info
tscSetDnodeEpSet(&pSql->epSet, &pTableIdList->vgInfo);
......@@ -800,7 +800,7 @@ static char *doSerializeTableInfo(SQueryTableMsg *pQueryMsg, SSqlObj *pSql, STab
pQueryMsg->numOfTables = htonl(numOfTables); // set the number of tables
tscDebug("0x%"PRIx64" query on stable, vgId:%d, numOfTables:%d, vgIndex:%d, numOfVgroups:%d", pSql->self,
pTableIdList->vgInfo.vgId, numOfTables, index, numOfVgroups);
pTableIdList->vgInfo.vgId, numOfTables, idx, numOfVgroups);
// serialize each table id info
for(int32_t i = 0; i < numOfTables; ++i) {
......@@ -1113,7 +1113,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pQueryMsg->tsBuf.tsOffset = htonl((int32_t)(pMsg - pCmd->payload));
if (pQueryInfo->tsBuf != NULL) {
// note: here used the index instead of actual vnode id.
// note: here used the idx instead of actual vnode id.
int32_t vnodeIndex = pTableMetaInfo->vgroupIndex;
code = dumpFileBlockByGroupId(pQueryInfo->tsBuf, vnodeIndex, pMsg, &pQueryMsg->tsBuf.tsLen, &pQueryMsg->tsBuf.tsNumOfBlocks);
if (code != TSDB_CODE_SUCCESS) {
......@@ -1258,10 +1258,10 @@ int32_t tscBuildCreateDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
static bool tscIsAlterCommand(char* sqlstr) {
int32_t index = 0;
int32_t idx = 0;
do {
SStrToken t0 = tStrGetToken(sqlstr, &index, false);
SStrToken t0 = tStrGetToken(sqlstr, &idx, false);
if (t0.type != TK_LP) {
return t0.type == TK_ALTER;
}
......@@ -2643,18 +2643,18 @@ int tscProcessShowRsp(SSqlObj *pSql) {
SFieldInfo* pFieldInfo = &pQueryInfo->fieldsInfo;
SColumnIndex index = {0};
SColumnIndex idx = {0};
pSchema = pMetaMsg->schema;
uint64_t uid = pTableMetaInfo->pTableMeta->id.uid;
for (int16_t i = 0; i < pMetaMsg->numOfColumns; ++i, ++pSchema) {
index.columnIndex = i;
idx.columnIndex = i;
tscColumnListInsert(pQueryInfo->colList, i, uid, pSchema);
TAOS_FIELD f = tscCreateField(pSchema->type, pSchema->name, pSchema->bytes);
SInternalField* pInfo = tscFieldInfoAppend(pFieldInfo, &f);
pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index,
pInfo->pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &idx,
pTableSchema[i].type, pTableSchema[i].bytes, getNewResColId(pCmd), pTableSchema[i].bytes, false);
}
......@@ -3481,4 +3481,4 @@ void tscInitMsgsFp() {
tscKeepConn[TSDB_SQL_SELECT] = 1;
tscKeepConn[TSDB_SQL_FETCH] = 1;
tscKeepConn[TSDB_SQL_HB] = 1;
}
\ No newline at end of file
}
......@@ -30,7 +30,7 @@
typedef struct SInsertSupporter {
SSqlObj* pSql;
int32_t index;
int32_t idx;
} SInsertSupporter;
static void freeJoinSubqueryObj(SSqlObj* pSql);
......@@ -84,14 +84,14 @@ static bool allSubqueryDone(SSqlObj *pParentSql) {
for (int i = 0; i < subState->numOfSub; i++) {
SSqlObj* pSub = pParentSql->pSubs[i];
if (0 == subState->states[i]) {
tscDebug("0x%"PRIx64" subquery:0x%"PRIx64", index: %d NOT finished yet", pParentSql->self, pSub->self, i);
tscDebug("0x%"PRIx64" subquery:0x%"PRIx64", idx: %d NOT finished yet", pParentSql->self, pSub->self, i);
done = false;
break;
} else {
if (pSub != NULL) {
tscDebug("0x%"PRIx64" subquery:0x%"PRIx64", index: %d finished", pParentSql->self, pSub->self, i);
tscDebug("0x%"PRIx64" subquery:0x%"PRIx64", idx: %d finished", pParentSql->self, pSub->self, i);
} else {
tscDebug("0x%"PRIx64" subquery:%p, index: %d finished", pParentSql->self, pSub, i);
tscDebug("0x%"PRIx64" subquery:%p, idx: %d finished", pParentSql->self, pSub, i);
}
}
}
......@@ -105,7 +105,7 @@ bool subAndCheckDone(SSqlObj *pSql, SSqlObj *pParentSql, int idx) {
pthread_mutex_lock(&subState->mutex);
tscDebug("0x%"PRIx64" subquery:0x%"PRIx64", index:%d state set to 1", pParentSql->self, pSql->self, idx);
tscDebug("0x%"PRIx64" subquery:0x%"PRIx64", idx:%d state set to 1", pParentSql->self, pSql->self, idx);
subState->states[idx] = 1;
bool done = allSubqueryDone(pParentSql);
......@@ -383,7 +383,7 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, STimeWindow * win) {
// todo handle failed to create sub query
SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, int32_t index) {
SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, int32_t idx) {
SJoinSupporter* pSupporter = calloc(1, sizeof(SJoinSupporter));
if (pSupporter == NULL) {
return NULL;
......@@ -391,7 +391,7 @@ SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, int32_t index) {
pSupporter->pObj = pSql->self;
pSupporter->subqueryIndex = index;
pSupporter->subqueryIndex = idx;
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd);
memcpy(&pSupporter->interval, &pQueryInfo->interval, sizeof(pSupporter->interval));
......@@ -403,7 +403,7 @@ SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, int32_t index) {
pSupporter->numOfFillVal = pQueryInfo->numOfFillVal;
}
STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, index);
STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, idx);
pSupporter->uid = pTableMetaInfo->pTableMeta->id.uid;
assert (pSupporter->uid != 0);
......@@ -614,7 +614,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
* during the timestamp intersection.
*/
pSupporter->limit = pQueryInfo->limit;
SColumnIndex index = {.tableIndex = 0, .columnIndex = PRIMARYKEY_TIMESTAMP_COL_INDEX};
SColumnIndex idx = {.tableIndex = 0, .columnIndex = PRIMARYKEY_TIMESTAMP_COL_INDEX};
SSchema* s = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, 0);
SExprInfo* pExpr = tscExprGet(pQueryInfo, 0);
......@@ -626,7 +626,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
int16_t functionId = tscIsProjectionQuery(pQueryInfo)? TSDB_FUNC_PRJ : TSDB_FUNC_TS;
tscAddFuncInSelectClause(pQueryInfo, 0, functionId, &index, s, TSDB_COL_NORMAL, getNewResColId(&pNew->cmd));
tscAddFuncInSelectClause(pQueryInfo, 0, functionId, &idx, s, TSDB_COL_NORMAL, getNewResColId(&pNew->cmd));
tscPrintSelNodeList(pNew, 0);
tscFieldInfoUpdateOffset(pQueryInfo);
......@@ -836,8 +836,8 @@ static void issueTsCompQuery(SSqlObj* pSql, SJoinSupporter* pSupporter, SSqlObj*
SSchema colSchema = {.type = TSDB_DATA_TYPE_BINARY, .bytes = 1};
SColumnIndex index = {0, PRIMARYKEY_TIMESTAMP_COL_INDEX};
SExprInfo *pExpr = tscAddFuncInSelectClause(pQueryInfo, 0, TSDB_FUNC_TS_COMP, &index, &colSchema, TSDB_COL_NORMAL, getNewResColId(pCmd));
SColumnIndex idx = {0, PRIMARYKEY_TIMESTAMP_COL_INDEX};
SExprInfo *pExpr = tscAddFuncInSelectClause(pQueryInfo, 0, TSDB_FUNC_TS_COMP, &idx, &colSchema, TSDB_COL_NORMAL, getNewResColId(pCmd));
// set the tags value for ts_comp function
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
......@@ -1280,7 +1280,7 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
// todo retry if other subqueries are not failed
assert(numOfRows < 0 && numOfRows == taos_errno(pSql));
tscError("0x%"PRIx64" sub query failed, code:%s, index:%d", pSql->self, tstrerror(numOfRows), pSupporter->subqueryIndex);
tscError("0x%"PRIx64" sub query failed, code:%s, idx:%d", pSql->self, tstrerror(numOfRows), pSupporter->subqueryIndex);
pParentSql->res.code = numOfRows;
if (quitAllSubquery(pSql, pParentSql, pSupporter)) {
......@@ -1336,7 +1336,7 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
pTableMetaInfo->vgroupIndex += 1;
assert(pTableMetaInfo->vgroupIndex < totalVgroups);
tscDebug("0x%"PRIx64" tid_tag from vgroup index:%d completed, try next vgroup:%d. total vgroups:%d. current numOfRes:%d",
tscDebug("0x%"PRIx64" tid_tag from vgroup idx:%d completed, try next vgroup:%d. total vgroups:%d. current numOfRes:%d",
pSql->self, pTableMetaInfo->vgroupIndex - 1, pTableMetaInfo->vgroupIndex, totalVgroups, pSupporter->num);
pCmd->command = TSDB_SQL_SELECT;
......@@ -1447,7 +1447,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
if (taos_errno(pSql) != TSDB_CODE_SUCCESS) {
// todo retry if other subqueries are not failed yet
assert(numOfRows < 0 && numOfRows == taos_errno(pSql));
tscError("0x%"PRIx64" sub query failed, code:%s, index:%d", pSql->self, tstrerror(numOfRows), pSupporter->subqueryIndex);
tscError("0x%"PRIx64" sub query failed, code:%s, idx:%d", pSql->self, tstrerror(numOfRows), pSupporter->subqueryIndex);
pParentSql->res.code = numOfRows;
if (quitAllSubquery(pSql, pParentSql, pSupporter)){
......@@ -1525,7 +1525,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
pTableMetaInfo->vgroupIndex += 1;
assert(pTableMetaInfo->vgroupIndex < totalVgroups);
tscDebug("0x%"PRIx64" results from vgroup index:%d completed, try next vgroup:%d. total vgroups:%d. current numOfRes:%" PRId64,
tscDebug("0x%"PRIx64" results from vgroup idx:%d completed, try next vgroup:%d. total vgroups:%d. current numOfRes:%" PRId64,
pSql->self, pTableMetaInfo->vgroupIndex - 1, pTableMetaInfo->vgroupIndex, totalVgroups,
pRes->numOfClauseTotal);
......@@ -1610,7 +1610,7 @@ static void joinRetrieveFinalResCallback(void* param, TAOS_RES* tres, int numOfR
assert(numOfRows == taos_errno(pSql));
pParentSql->res.code = numOfRows;
tscError("0x%"PRIx64" retrieve failed, index:%d, code:%s", pSql->self, pSupporter->subqueryIndex, tstrerror(numOfRows));
tscError("0x%"PRIx64" retrieve failed, idx:%d, code:%s", pSql->self, pSupporter->subqueryIndex, tstrerror(numOfRows));
tscAsyncResultOnError(pParentSql);
goto _return;
......@@ -1670,7 +1670,7 @@ static void joinRetrieveFinalResCallback(void* param, TAOS_RES* tres, int numOfR
pParentSql->res.precision = pRes1->precision;
if (pRes1->row > 0 && pRes1->numOfRows > 0) {
tscDebug("0x%"PRIx64" sub:0x%"PRIx64" index:%d numOfRows:%d total:%"PRId64 " (not retrieve)", pParentSql->self,
tscDebug("0x%"PRIx64" sub:0x%"PRIx64" idx:%d numOfRows:%d total:%"PRId64 " (not retrieve)", pParentSql->self,
pParentSql->pSubs[i]->self, i, pRes1->numOfRows, pRes1->numOfTotal);
assert(pRes1->row < pRes1->numOfRows || (pRes1->row == pRes1->numOfRows && pRes1->completed));
} else {
......@@ -1678,7 +1678,7 @@ static void joinRetrieveFinalResCallback(void* param, TAOS_RES* tres, int numOfR
pRes1->numOfClauseTotal += pRes1->numOfRows;
}
tscDebug("0x%"PRIx64" sub:0x%"PRIx64" index:%d numOfRows:%d total:%"PRId64, pParentSql->self,
tscDebug("0x%"PRIx64" sub:0x%"PRIx64" idx:%d numOfRows:%d total:%"PRId64, pParentSql->self,
pParentSql->pSubs[i]->self, i, pRes1->numOfRows, pRes1->numOfTotal);
}
}
......@@ -1879,7 +1879,7 @@ void tscFetchDatablockForSubquery(SSqlObj* pSql) {
}
}
// all subqueries return, set the result output index
// all subqueries return, set the result output idx
void tscSetupOutputColumnIndex(SSqlObj* pSql) {
SSqlCmd* pCmd = &pSql->cmd;
SSqlRes* pRes = &pSql->res;
......@@ -2567,7 +2567,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
int32_t numOfExprs = (int32_t) tscNumOfExprs(pQueryInfo);
int32_t index = 0;
int32_t idx = 0;
for(int32_t i = 0; i < numOfExprs; ++i) {
SExprInfo* pExpr = tscExprGet(pQueryInfo, i);
if (pExpr->base.functionId == TSDB_FUNC_TS && pQueryInfo->interval.interval > 0) {
......@@ -2576,7 +2576,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
SColumnIndex colIndex = {.tableIndex = 0, .columnIndex = PRIMARYKEY_TIMESTAMP_COL_INDEX};
SSchema* schema = tscGetColumnSchemaById(pTableMetaInfo1->pTableMeta, pExpr->base.colInfo.colId);
SExprInfo* p = tscAddFuncInSelectClause(pNewQueryInfo, index++, TSDB_FUNC_TS, &colIndex, schema, TSDB_COL_NORMAL, getNewResColId(pCmd));
SExprInfo* p = tscAddFuncInSelectClause(pNewQueryInfo, idx++, TSDB_FUNC_TS, &colIndex, schema, TSDB_COL_NORMAL, getNewResColId(pCmd));
p->base.resColId = pExpr->base.resColId; // update the result column id
} else if (pExpr->base.functionId == TSDB_FUNC_STDDEV_DST) {
taosArrayPush(pSup->pColsInfo, &pExpr->base.resColId);
......@@ -2585,7 +2585,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
SSchema schema = {.type = TSDB_DATA_TYPE_DOUBLE, .bytes = sizeof(double)};
tstrncpy(schema.name, pExpr->base.aliasName, tListLen(schema.name));
SExprInfo* p = tscAddFuncInSelectClause(pNewQueryInfo, index++, TSDB_FUNC_AVG, &colIndex, &schema, TSDB_COL_NORMAL, getNewResColId(pCmd));
SExprInfo* p = tscAddFuncInSelectClause(pNewQueryInfo, idx++, TSDB_FUNC_AVG, &colIndex, &schema, TSDB_COL_NORMAL, getNewResColId(pCmd));
p->base.resColId = pExpr->base.resColId; // update the result column id
} else if (pExpr->base.functionId == TSDB_FUNC_TAG) {
pSup->tagLen += pExpr->base.resBytes;
......@@ -2598,7 +2598,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
schema = tGetTbnameColumnSchema();
}
SExprInfo* p = tscAddFuncInSelectClause(pNewQueryInfo, index++, TSDB_FUNC_TAG, &colIndex, schema, TSDB_COL_TAG, getNewResColId(pCmd));
SExprInfo* p = tscAddFuncInSelectClause(pNewQueryInfo, idx++, TSDB_FUNC_TAG, &colIndex, schema, TSDB_COL_TAG, getNewResColId(pCmd));
if (schema->type == TSDB_DATA_TYPE_JSON){
p->base.numOfParams = pExpr->base.numOfParams;
tVariantAssign(&p->base.param[0], &pExpr->base.param[0]);
......@@ -2616,7 +2616,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
SSchema* schema = tscGetColumnSchemaById(pTableMetaInfo1->pTableMeta, pExpr->base.colInfo.colId);
//doLimitOutputNormalColOfGroupby
SExprInfo* p = tscAddFuncInSelectClause(pNewQueryInfo, index++, TSDB_FUNC_PRJ, &colIndex, schema, TSDB_COL_NORMAL, getNewResColId(pCmd));
SExprInfo* p = tscAddFuncInSelectClause(pNewQueryInfo, idx++, TSDB_FUNC_PRJ, &colIndex, schema, TSDB_COL_NORMAL, getNewResColId(pCmd));
p->base.numOfParams = 1;
p->base.param[0].i64 = 1;
p->base.param[0].nType = TSDB_DATA_TYPE_INT;
......@@ -2658,7 +2658,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
"0x%"PRIx64" first round subquery:0x%"PRIx64" tableIndex:%d, vgroupIndex:%d, numOfVgroups:%d, type:%d, query to retrieve timestamps, "
"numOfExpr:%" PRIzu ", colList:%d, numOfOutputFields:%d, name:%s",
pSql->self, pNew->self, 0, pTableMetaInfo->vgroupIndex, pTableMetaInfo->vgroupList->numOfVgroups, pNewQueryInfo->type,
tscNumOfExprs(pNewQueryInfo), index+1, pNewQueryInfo->fieldsInfo.numOfOutput, tNameGetTableName(&pTableMetaInfo->name));
tscNumOfExprs(pNewQueryInfo), idx+1, pNewQueryInfo->fieldsInfo.numOfOutput, tNameGetTableName(&pTableMetaInfo->name));
pSql->pSubs = calloc(1, POINTER_BYTES);
if (pSql->pSubs == NULL) {
......@@ -3281,7 +3281,7 @@ SSqlObj *tscCreateSTableSubquery(SSqlObj *pSql, SRetrieveSupport *trsupport, SSq
assert(trsupport->subqueryIndex < pSql->subState.numOfSub);
// launch subquery for each vnode, so the subquery index equals to the vgroupIndex.
// launch subquery for each vnode, so the subquery idx equals to the vgroupIndex.
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, table_index);
pTableMetaInfo->vgroupIndex = trsupport->subqueryIndex;
......@@ -3411,7 +3411,7 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows)
}
}
if (!subAndCheckDone(tres, pParentObj, pSupporter->index)) {
if (!subAndCheckDone(tres, pParentObj, pSupporter->idx)) {
// concurrency problem, other thread already release pParentObj
//tscDebug("0x%"PRIx64" insert:%p,%d completed, total:%d", pParentObj->self, tres, suppIdx, pParentObj->subState.numOfSub);
return;
......@@ -3495,9 +3495,9 @@ int32_t tscHandleInsertRetry(SSqlObj* pParent, SSqlObj* pSql) {
SSqlRes* pRes = &pSql->res;
SInsertSupporter* pSupporter = (SInsertSupporter*) pSql->param;
assert(pSupporter->index < pSupporter->pSql->subState.numOfSub);
assert(pSupporter->idx < pSupporter->pSql->subState.numOfSub);
STableDataBlocks* pTableDataBlock = taosArrayGetP(pParent->cmd.insertParam.pDataBlocks, pSupporter->index);
STableDataBlocks* pTableDataBlock = taosArrayGetP(pParent->cmd.insertParam.pDataBlocks, pSupporter->idx);
int32_t code = tscCopyDataBlockToPayload(pSql, pTableDataBlock);
if ((pRes->code = code)!= TSDB_CODE_SUCCESS) {
......@@ -3524,7 +3524,7 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
for(int32_t i = 0; i < pSql->subState.numOfSub; ++i) {
SSqlObj* pSub = pSql->pSubs[i];
SInsertSupporter* pSup = calloc(1, sizeof(SInsertSupporter));
pSup->index = i;
pSup->idx = i;
pSup->pSql = pSql;
pSub->param = pSup;
......@@ -3572,7 +3572,7 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
}
pSupporter->pSql = pSql;
pSupporter->index = numOfSub;
pSupporter->idx = numOfSub;
SSqlObj *pNew = createSimpleSubObj(pSql, multiVnodeInsertFinalize, pSupporter, TSDB_SQL_INSERT);
if (pNew == NULL) {
......@@ -3763,19 +3763,19 @@ void tscBuildResFromSubqueries(SSqlObj *pSql) {
char * getScalarExprInputSrc(void *param, const char *name, int32_t colId) {
SScalarExprSupport*pSupport = (SScalarExprSupport*) param;
int32_t index = -1;
int32_t idx = -1;
SExprInfo* pExpr = NULL;
for (int32_t i = 0; i < pSupport->numOfCols; ++i) {
pExpr = taosArrayGetP(pSupport->exprList, i);
if (strncmp(name, pExpr->base.aliasName, sizeof(pExpr->base.aliasName) - 1) == 0) {
index = i;
idx = i;
break;
}
}
assert(index >= 0 && index < pSupport->numOfCols);
return pSupport->data[index] + pSupport->offset * pExpr->base.resBytes;
assert(idx >= 0 && idx < pSupport->numOfCols);
return pSupport->data[idx] + pSupport->offset * pExpr->base.resBytes;
}
TAOS_ROW doSetResultRowData(SSqlObj *pSql) {
......@@ -3815,7 +3815,7 @@ TAOS_ROW doSetResultRowData(SSqlObj *pSql) {
j += 1;
}
pRes->row++; // index increase one-step
pRes->row++; // idx increase one-step
return pRes->tsrow;
}
......@@ -3959,7 +3959,7 @@ void* createQInfoFromQueryNode(SQueryInfo* pQueryInfo, STableGroupInfo* pTableGr
pthread_mutex_init(&pQInfo->lock, NULL);
tsem_init(&pQInfo->ready, 0, 0);
int32_t index = 0;
int32_t idx = 0;
for(int32_t i = 0; i < numOfGroups; ++i) {
SArray* pa = taosArrayGetP(pQueryAttr->tableGroupInfo.pGroupList, i);
......@@ -3976,7 +3976,7 @@ void* createQInfoFromQueryNode(SQueryInfo* pQueryInfo, STableGroupInfo* pTableGr
STableKeyInfo* info = taosArrayGet(pa, j);
window.skey = info->lastKey;
void* buf = (char*) pQInfo->pBuf + index * sizeof(STableQueryInfo);
void* buf = (char*) pQInfo->pBuf + idx * sizeof(STableQueryInfo);
STableQueryInfo* item = createTableQueryInfo(pQueryAttr, info->pTable, pQueryAttr->groupbyColumn, window, buf);
if (item == NULL) {
goto _cleanup;
......@@ -3987,7 +3987,7 @@ void* createQInfoFromQueryNode(SQueryInfo* pQueryInfo, STableGroupInfo* pTableGr
STableId id = {.tid = 0, .uid = 0};
taosHashPut(pRuntimeEnv->tableqinfoGroupInfo.map, &id.tid, sizeof(id.tid), &item, POINTER_BYTES);
index += 1;
idx += 1;
}
}
......
......@@ -87,24 +87,24 @@ int32_t tscAcquireRpc(const char *key, const char *user, const char *secretEncry
return 0;
}
SRpcInit rpcInit;
memset(&rpcInit, 0, sizeof(rpcInit));
rpcInit.localPort = 0;
rpcInit.label = "TSC";
rpcInit.numOfThreads = tscNumOfThreads;
rpcInit.cfp = tscProcessMsgFromServer;
rpcInit.sessions = tsMaxConnections;
rpcInit.connType = TAOS_CONN_CLIENT;
rpcInit.user = (char *)user;
rpcInit.idleTime = tsShellActivityTimer * 1000;
rpcInit.ckey = "key";
rpcInit.spi = 1;
rpcInit.secret = (char *)secretEncrypt;
SRpcInit rpcInitial;
memset(&rpcInitial, 0, sizeof(rpcInitial));
rpcInitial.localPort = 0;
rpcInitial.label = "TSC";
rpcInitial.numOfThreads = tscNumOfThreads;
rpcInitial.cfp = tscProcessMsgFromServer;
rpcInitial.sessions = tsMaxConnections;
rpcInitial.connType = TAOS_CONN_CLIENT;
rpcInitial.user = (char *)user;
rpcInitial.idleTime = tsShellActivityTimer * 1000;
rpcInitial.ckey = "key";
rpcInitial.spi = 1;
rpcInitial.secret = (char *)secretEncrypt;
SRpcObj rpcObj;
memset(&rpcObj, 0, sizeof(rpcObj));
tstrncpy(rpcObj.key, key, sizeof(rpcObj.key));
rpcObj.pDnodeConn = rpcOpen(&rpcInit);
rpcObj.pDnodeConn = rpcOpen(&rpcInitial);
if (rpcObj.pDnodeConn == NULL) {
pthread_mutex_unlock(&rpcObjMutex);
tscError("failed to init connection to server");
......
......@@ -2305,10 +2305,10 @@ void tscCloseTscObj(void *param) {
}
bool tscIsInsertData(char* sqlstr) {
int32_t index = 0;
int32_t idx = 0;
do {
SStrToken t0 = tStrGetToken(sqlstr, &index, false);
SStrToken t0 = tStrGetToken(sqlstr, &idx, false);
if (t0.type != TK_LP) {
return t0.type == TK_INSERT || t0.type == TK_IMPORT;
}
......@@ -2378,12 +2378,12 @@ SInternalField* tscFieldInfoAppend(SFieldInfo* pFieldInfo, TAOS_FIELD* pField) {
return taosArrayPush(pFieldInfo->internalField, &info);
}
SInternalField* tscFieldInfoInsert(SFieldInfo* pFieldInfo, int32_t index, TAOS_FIELD* field) {
SInternalField* tscFieldInfoInsert(SFieldInfo* pFieldInfo, int32_t idx, TAOS_FIELD* field) {
pFieldInfo->numOfOutput++;
struct SInternalField info = { .pExpr = NULL, .visible = true };
info.field = *field;
return taosArrayInsert(pFieldInfo->internalField, index, &info);
return taosArrayInsert(pFieldInfo->internalField, idx, &info);
}
void tscFieldInfoUpdateOffset(SQueryInfo* pQueryInfo) {
......@@ -2398,18 +2398,18 @@ void tscFieldInfoUpdateOffset(SQueryInfo* pQueryInfo) {
}
}
SInternalField* tscFieldInfoGetInternalField(SFieldInfo* pFieldInfo, int32_t index) {
assert(index < pFieldInfo->numOfOutput);
return TARRAY_GET_ELEM(pFieldInfo->internalField, index);
SInternalField* tscFieldInfoGetInternalField(SFieldInfo* pFieldInfo, int32_t idx) {
assert(idx < pFieldInfo->numOfOutput);
return TARRAY_GET_ELEM(pFieldInfo->internalField, idx);
}
TAOS_FIELD* tscFieldInfoGetField(SFieldInfo* pFieldInfo, int32_t index) {
assert(index < pFieldInfo->numOfOutput);
return &((SInternalField*)TARRAY_GET_ELEM(pFieldInfo->internalField, index))->field;
TAOS_FIELD* tscFieldInfoGetField(SFieldInfo* pFieldInfo, int32_t idx) {
assert(idx < pFieldInfo->numOfOutput);
return &((SInternalField*)TARRAY_GET_ELEM(pFieldInfo->internalField, idx))->field;
}
int32_t tscFieldInfoGetOffset(SQueryInfo* pQueryInfo, int32_t index) {
SInternalField* pInfo = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, index);
int32_t tscFieldInfoGetOffset(SQueryInfo* pQueryInfo, int32_t idx) {
SInternalField* pInfo = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, idx);
assert(pInfo != NULL && pInfo->pExpr->pExpr == NULL);
return pInfo->pExpr->base.offset;
......@@ -2635,16 +2635,16 @@ SExprInfo* tscExprCreate(STableMetaInfo* pTableMetaInfo, int16_t functionId, SCo
return pExpr;
}
SExprInfo* tscExprInsert(SQueryInfo* pQueryInfo, int32_t index, int16_t functionId, SColumnIndex* pColIndex, int16_t type,
SExprInfo* tscExprInsert(SQueryInfo* pQueryInfo, int32_t idx, int16_t functionId, SColumnIndex* pColIndex, int16_t type,
int16_t size, int16_t resColId, int32_t interSize, bool isTagCol) {
int32_t num = (int32_t)taosArrayGetSize(pQueryInfo->exprList);
if (index == num) {
if (idx == num) {
return tscExprAppend(pQueryInfo, functionId, pColIndex, type, size, resColId, interSize, isTagCol);
}
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, pColIndex->tableIndex);
SExprInfo* pExpr = tscExprCreate(pTableMetaInfo, functionId, pColIndex, type, size, resColId, interSize, isTagCol);
taosArrayInsert(pQueryInfo->exprList, index, &pExpr);
taosArrayInsert(pQueryInfo->exprList, idx, &pExpr);
return pExpr;
}
......@@ -2656,10 +2656,10 @@ SExprInfo* tscExprAppend(SQueryInfo* pQueryInfo, int16_t functionId, SColumnInde
return pExpr;
}
SExprInfo* tscExprUpdate(SQueryInfo* pQueryInfo, int32_t index, int16_t functionId, int16_t srcColumnIndex,
SExprInfo* tscExprUpdate(SQueryInfo* pQueryInfo, int32_t idx, int16_t functionId, int16_t srcColumnIndex,
int16_t type, int32_t size) {
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
SExprInfo* pExpr = tscExprGet(pQueryInfo, index);
SExprInfo* pExpr = tscExprGet(pQueryInfo, idx);
if (pExpr == NULL) {
return NULL;
}
......@@ -2676,8 +2676,8 @@ SExprInfo* tscExprUpdate(SQueryInfo* pQueryInfo, int32_t index, int16_t function
return pExpr;
}
bool tscMultiRoundQuery(SQueryInfo* pQueryInfo, int32_t index) {
if (!UTIL_TABLE_IS_SUPER_TABLE(pQueryInfo->pTableMetaInfo[index])) {
bool tscMultiRoundQuery(SQueryInfo* pQueryInfo, int32_t idx) {
if (!UTIL_TABLE_IS_SUPER_TABLE(pQueryInfo->pTableMetaInfo[idx])) {
return false;
}
......@@ -2725,8 +2725,8 @@ void tscExprAddParams(SSqlExpr* pExpr, char* argument, int32_t type, int32_t byt
assert(pExpr->numOfParams <= 3);
}
SExprInfo* tscExprGet(SQueryInfo* pQueryInfo, int32_t index) {
return taosArrayGetP(pQueryInfo->exprList, index);
SExprInfo* tscExprGet(SQueryInfo* pQueryInfo, int32_t idx) {
return taosArrayGetP(pQueryInfo->exprList, idx);
}
/*
......@@ -3297,8 +3297,8 @@ void tscGetSrcColumnInfo(SSrcColumnInfo* pColInfo, SQueryInfo* pQueryInfo) {
if (TSDB_COL_IS_TAG(pExpr->base.colInfo.flag)) {
SSchema* pTagSchema = tscGetTableTagSchema(pTableMetaInfo->pTableMeta);
int16_t index = pExpr->base.colInfo.colIndex;
pColInfo[i].type = (index != -1) ? pTagSchema[index].type : TSDB_DATA_TYPE_BINARY;
int16_t idx = pExpr->base.colInfo.colIndex;
pColInfo[i].type = (idx != -1) ? pTagSchema[idx].type : TSDB_DATA_TYPE_BINARY;
} else {
pColInfo[i].type = pSchema[pExpr->base.colInfo.colIndex].type;
}
......@@ -3381,7 +3381,7 @@ SQueryInfo* tscGetQueryInfoS(SSqlCmd* pCmd) {
return pQueryInfo;
}
STableMetaInfo* tscGetTableMetaInfoByUid(SQueryInfo* pQueryInfo, uint64_t uid, int32_t* index) {
STableMetaInfo* tscGetTableMetaInfoByUid(SQueryInfo* pQueryInfo, uint64_t uid, int32_t* idx) {
int32_t k = -1;
for (int32_t i = 0; i < pQueryInfo->numOfTables; ++i) {
......@@ -3391,8 +3391,8 @@ STableMetaInfo* tscGetTableMetaInfoByUid(SQueryInfo* pQueryInfo, uint64_t uid, i
}
}
if (index != NULL) {
*index = k;
if (idx != NULL) {
*idx = k;
}
assert(k != -1);
......@@ -3615,19 +3615,19 @@ void tscFreeVgroupTableInfo(SArray* pVgroupTables) {
taosArrayDestroy(&pVgroupTables);
}
void tscRemoveVgroupTableGroup(SArray* pVgroupTable, int32_t index) {
assert(pVgroupTable != NULL && index >= 0);
void tscRemoveVgroupTableGroup(SArray* pVgroupTable, int32_t idx) {
assert(pVgroupTable != NULL && idx >= 0);
size_t size = taosArrayGetSize(pVgroupTable);
assert(size > index);
assert(size > idx);
SVgroupTableInfo* pInfo = taosArrayGet(pVgroupTable, index);
SVgroupTableInfo* pInfo = taosArrayGet(pVgroupTable, idx);
// for(int32_t j = 0; j < pInfo->vgInfo.numOfEps; ++j) {
// tfree(pInfo->vgInfo.epAddr[j].fqdn);
// }
taosArrayDestroy(&pInfo->itemList);
taosArrayRemove(pVgroupTable, index);
taosArrayRemove(pVgroupTable, idx);
}
void tscVgroupTableCopy(SVgroupTableInfo* info, SVgroupTableInfo* pInfo) {
......@@ -4102,15 +4102,15 @@ static void tscSubqueryRetrieveCallback(void* param, TAOS_RES* tres, int code) {
SSqlObj* pParentSql = ps->pParentSql;
SSqlObj* pSql = tres;
int32_t index = ps->subqueryIndex;
bool ret = subAndCheckDone(pSql, pParentSql, index);
int32_t idx = ps->subqueryIndex;
bool ret = subAndCheckDone(pSql, pParentSql, idx);
// TODO refactor
tfree(ps);
pSql->param = NULL;
if (!ret) {
tscDebug("0x%"PRIx64" sub:0x%"PRIx64" orderOfSub:%d completed, not all subquery finished", pParentSql->self, pSql->self, index);
tscDebug("0x%"PRIx64" sub:0x%"PRIx64" orderOfSub:%d completed, not all subquery finished", pParentSql->self, pSql->self, idx);
return;
}
......@@ -4131,13 +4131,13 @@ static void tscSubqueryCompleteCallback(void* param, TAOS_RES* tres, int code) {
if (pSql->res.code != TSDB_CODE_SUCCESS) {
SSqlObj* pParentSql = ps->pParentSql;
int32_t index = ps->subqueryIndex;
bool ret = subAndCheckDone(pSql, pParentSql, index);
int32_t idx = ps->subqueryIndex;
bool ret = subAndCheckDone(pSql, pParentSql, idx);
tscFreeRetrieveSup(&pSql->param);
if (!ret) {
tscDebug("0x%"PRIx64" sub:0x%"PRIx64" orderOfSub:%d completed, not all subquery finished", pParentSql->self, pSql->self, index);
tscDebug("0x%"PRIx64" sub:0x%"PRIx64" orderOfSub:%d completed, not all subquery finished", pParentSql->self, pSql->self, idx);
return;
}
......
......@@ -60,40 +60,40 @@ void calc_i32_i32_add(void *left, void *right, int32_t numLeft, int32_t numRight
}
}
typedef double (*_arithmetic_getVectorDoubleValue_fn_t)(void *src, int32_t index);
typedef double (*_arithmetic_getVectorDoubleValue_fn_t)(void *src, int32_t idx);
double getVectorDoubleValue_TINYINT(void *src, int32_t index) {
return (double)*((int8_t *)src + index);
double getVectorDoubleValue_TINYINT(void *src, int32_t idx) {
return (double)*((int8_t *)src + idx);
}
double getVectorDoubleValue_UTINYINT(void *src, int32_t index) {
return (double)*((uint8_t *)src + index);
double getVectorDoubleValue_UTINYINT(void *src, int32_t idx) {
return (double)*((uint8_t *)src + idx);
}
double getVectorDoubleValue_SMALLINT(void *src, int32_t index) {
return (double)*((int16_t *)src + index);
double getVectorDoubleValue_SMALLINT(void *src, int32_t idx) {
return (double)*((int16_t *)src + idx);
}
double getVectorDoubleValue_USMALLINT(void *src, int32_t index) {
return (double)*((uint16_t *)src + index);
double getVectorDoubleValue_USMALLINT(void *src, int32_t idx) {
return (double)*((uint16_t *)src + idx);
}
double getVectorDoubleValue_INT(void *src, int32_t index) {
return (double)*((int32_t *)src + index);
double getVectorDoubleValue_INT(void *src, int32_t idx) {
return (double)*((int32_t *)src + idx);
}
double getVectorDoubleValue_UINT(void *src, int32_t index) {
return (double)*((uint32_t *)src + index);
double getVectorDoubleValue_UINT(void *src, int32_t idx) {
return (double)*((uint32_t *)src + idx);
}
double getVectorDoubleValue_BIGINT(void *src, int32_t index) {
return (double)*((int64_t *)src + index);
double getVectorDoubleValue_BIGINT(void *src, int32_t idx) {
return (double)*((int64_t *)src + idx);
}
double getVectorDoubleValue_UBIGINT(void *src, int32_t index) {
return (double)*((uint64_t *)src + index);
double getVectorDoubleValue_UBIGINT(void *src, int32_t idx) {
return (double)*((uint64_t *)src + idx);
}
double getVectorDoubleValue_FLOAT(void *src, int32_t index) {
return (double)*((float *)src + index);
double getVectorDoubleValue_FLOAT(void *src, int32_t idx) {
return (double)*((float *)src + idx);
}
double getVectorDoubleValue_DOUBLE(void *src, int32_t index) {
return (double)*((double *)src + index);
double getVectorDoubleValue_DOUBLE(void *src, int32_t idx) {
return (double)*((double *)src + idx);
}
int64_t getVectorTimestampValue(void *src, int32_t index) {
return (int64_t)*((int64_t *)src + index);
int64_t getVectorTimestampValue(void *src, int32_t idx) {
return (int64_t)*((int64_t *)src + idx);
}
_arithmetic_getVectorDoubleValue_fn_t getVectorDoubleValueFn(int32_t srcType) {
_arithmetic_getVectorDoubleValue_fn_t p = NULL;
......@@ -124,40 +124,40 @@ _arithmetic_getVectorDoubleValue_fn_t getVectorDoubleValueFn(int32_t srcType) {
}
typedef void* (*_arithmetic_getVectorValueAddr_fn_t)(void *src, int32_t index);
typedef void* (*_arithmetic_getVectorValueAddr_fn_t)(void *src, int32_t idx);
void* getVectorValueAddr_BOOL(void *src, int32_t index) {
return (void*)((bool *)src + index);
void* getVectorValueAddr_BOOL(void *src, int32_t idx) {
return (void*)((bool *)src + idx);
}
void* getVectorValueAddr_TINYINT(void *src, int32_t index) {
return (void*)((int8_t *)src + index);
void* getVectorValueAddr_TINYINT(void *src, int32_t idx) {
return (void*)((int8_t *)src + idx);
}
void* getVectorValueAddr_UTINYINT(void *src, int32_t index) {
return (void*)((uint8_t *)src + index);
void* getVectorValueAddr_UTINYINT(void *src, int32_t idx) {
return (void*)((uint8_t *)src + idx);
}
void* getVectorValueAddr_SMALLINT(void *src, int32_t index) {
return (void*)((int16_t *)src + index);
void* getVectorValueAddr_SMALLINT(void *src, int32_t idx) {
return (void*)((int16_t *)src + idx);
}
void* getVectorValueAddr_USMALLINT(void *src, int32_t index) {
return (void*)((uint16_t *)src + index);
void* getVectorValueAddr_USMALLINT(void *src, int32_t idx) {
return (void*)((uint16_t *)src + idx);
}
void* getVectorValueAddr_INT(void *src, int32_t index) {
return (void*)((int32_t *)src + index);
void* getVectorValueAddr_INT(void *src, int32_t idx) {
return (void*)((int32_t *)src + idx);
}
void* getVectorValueAddr_UINT(void *src, int32_t index) {
return (void*)((uint32_t *)src + index);
void* getVectorValueAddr_UINT(void *src, int32_t idx) {
return (void*)((uint32_t *)src + idx);
}
void* getVectorValueAddr_BIGINT(void *src, int32_t index) {
return (void*)((int64_t *)src + index);
void* getVectorValueAddr_BIGINT(void *src, int32_t idx) {
return (void*)((int64_t *)src + idx);
}
void* getVectorValueAddr_UBIGINT(void *src, int32_t index) {
return (void*)((uint64_t *)src + index);
void* getVectorValueAddr_UBIGINT(void *src, int32_t idx) {
return (void*)((uint64_t *)src + idx);
}
void* getVectorValueAddr_FLOAT(void *src, int32_t index) {
return (void*)((float *)src + index);
void* getVectorValueAddr_FLOAT(void *src, int32_t idx) {
return (void*)((float *)src + idx);
}
void* getVectorValueAddr_DOUBLE(void *src, int32_t index) {
return (void*)((double *)src + index);
void* getVectorValueAddr_DOUBLE(void *src, int32_t idx) {
return (void*)((double *)src + idx);
}
_arithmetic_getVectorValueAddr_fn_t getVectorValueAddrFn(int32_t srcType) {
......@@ -474,34 +474,34 @@ void vectorRemainder(void *left, int32_t len1, int32_t _left_type, void *right,
}
}
typedef int64_t (*_arithmetic_getVectorBigintValue_fn_t)(void *src, int32_t index);
typedef int64_t (*_arithmetic_getVectorBigintValue_fn_t)(void *src, int32_t idx);
int64_t getVectorBigintValue_BOOL(void *src, int32_t index) {
return (int64_t)*((bool *)src + index);
int64_t getVectorBigintValue_BOOL(void *src, int32_t idx) {
return (int64_t)*((bool *)src + idx);
}
int64_t getVectorBigintValue_TINYINT(void *src, int32_t index) {
return (int64_t)*((int8_t *)src + index);
int64_t getVectorBigintValue_TINYINT(void *src, int32_t idx) {
return (int64_t)*((int8_t *)src + idx);
}
int64_t getVectorBigintValue_UTINYINT(void *src, int32_t index) {
return (int64_t)*((uint8_t *)src + index);
int64_t getVectorBigintValue_UTINYINT(void *src, int32_t idx) {
return (int64_t)*((uint8_t *)src + idx);
}
int64_t getVectorBigintValue_SMALLINT(void *src, int32_t index) {
return (int64_t)*((int16_t *)src + index);
int64_t getVectorBigintValue_SMALLINT(void *src, int32_t idx) {
return (int64_t)*((int16_t *)src + idx);
}
int64_t getVectorBigintValue_USMALLINT(void *src, int32_t index) {
return (int64_t)*((uint16_t *)src + index);
int64_t getVectorBigintValue_USMALLINT(void *src, int32_t idx) {
return (int64_t)*((uint16_t *)src + idx);
}
int64_t getVectorBigintValue_INT(void *src, int32_t index) {
return (int64_t)*((int32_t *)src + index);
int64_t getVectorBigintValue_INT(void *src, int32_t idx) {
return (int64_t)*((int32_t *)src + idx);
}
int64_t getVectorBigintValue_UINT(void *src, int32_t index) {
return (int64_t)*((uint32_t *)src + index);
int64_t getVectorBigintValue_UINT(void *src, int32_t idx) {
return (int64_t)*((uint32_t *)src + idx);
}
int64_t getVectorBigintValue_BIGINT(void *src, int32_t index) {
return (int64_t)*((int64_t *)src + index);
int64_t getVectorBigintValue_BIGINT(void *src, int32_t idx) {
return (int64_t)*((int64_t *)src + idx);
}
int64_t getVectorBigintValue_UBIGINT(void *src, int32_t index) {
return (int64_t)*((uint64_t *)src + index);
int64_t getVectorBigintValue_UBIGINT(void *src, int32_t idx) {
return (int64_t)*((uint64_t *)src + idx);
}
_arithmetic_getVectorBigintValue_fn_t getVectorBigintValueFn(int32_t srcType) {
......
......@@ -304,14 +304,14 @@ bool isNEleNull(SDataCol *pCol, int nEle) {
return true;
}
static FORCE_INLINE void dataColSetNullAt(SDataCol *pCol, int index) {
static FORCE_INLINE void dataColSetNullAt(SDataCol *pCol, int idx) {
if (IS_VAR_DATA_TYPE(pCol->type)) {
pCol->dataOff[index] = pCol->len;
pCol->dataOff[idx] = pCol->len;
char *ptr = POINTER_SHIFT(pCol->pData, pCol->len);
setVardataNull(ptr, pCol->type);
pCol->len += varDataTLen(ptr);
} else {
setNull(POINTER_SHIFT(pCol->pData, TYPE_BYTES[pCol->type] * index), pCol->type, pCol->bytes);
setNull(POINTER_SHIFT(pCol->pData, TYPE_BYTES[pCol->type] * idx), pCol->type, pCol->bytes);
pCol->len += TYPE_BYTES[pCol->type];
}
}
......
......@@ -397,10 +397,10 @@ bool taosCfgDynamicOptions(char *msg) {
return false;
}
void taosAddDataDir(int index, char *v1, int level, int primary) {
tstrncpy(tsDiskCfg[index].dir, v1, TSDB_FILENAME_LEN);
tsDiskCfg[index].level = level;
tsDiskCfg[index].primary = primary;
void taosAddDataDir(int idx, char *v1, int level, int primary) {
tstrncpy(tsDiskCfg[idx].dir, v1, TSDB_FILENAME_LEN);
tsDiskCfg[idx].level = level;
tsDiskCfg[idx].primary = primary;
uTrace("dataDir:%s, level:%d primary:%d is configured", v1, level, primary);
}
......
......@@ -442,29 +442,29 @@ void tNameAssign(SName* dst, const SName* src) {
memcpy(dst, src, sizeof(SName));
}
int32_t tNameSetDbName(SName* dst, const char* acct, SStrToken* dbToken) {
assert(dst != NULL && dbToken != NULL && acct != NULL);
int32_t tNameSetDbName(SName* dst, const char* accnt, SStrToken* dbToken) {
assert(dst != NULL && dbToken != NULL && accnt != NULL);
// too long account id or too long db name
if (strlen(acct) >= tListLen(dst->acctId) || dbToken->n >= tListLen(dst->dbname)) {
if (strlen(accnt) >= tListLen(dst->acctId) || dbToken->n >= tListLen(dst->dbname)) {
return -1;
}
dst->type = TSDB_DB_NAME_T;
tstrncpy(dst->acctId, acct, tListLen(dst->acctId));
tstrncpy(dst->acctId, accnt, tListLen(dst->acctId));
tstrncpy(dst->dbname, dbToken->z, dbToken->n + 1);
return 0;
}
int32_t tNameSetAcctId(SName* dst, const char* acct) {
assert(dst != NULL && acct != NULL);
int32_t tNameSetAcctId(SName* dst, const char* accnt) {
assert(dst != NULL && accnt != NULL);
// too long account id or too long db name
if (strlen(acct) >= tListLen(dst->acctId)) {
if (strlen(accnt) >= tListLen(dst->acctId)) {
return -1;
}
tstrncpy(dst->acctId, acct, tListLen(dst->acctId));
tstrncpy(dst->acctId, accnt, tListLen(dst->acctId));
assert(strlen(dst->acctId) > 0);
......
......@@ -259,8 +259,8 @@ static void getStatics_u64(const void *pData, int32_t numOfRow, int64_t *min, in
static void getStatics_f(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max,
int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
float *data = (float *)pData;
float fmin = FLT_MAX;
float fmax = -FLT_MAX;
float flmin = FLT_MAX;
float flmax = -FLT_MAX;
double dsum = 0;
*minIndex = 0;
*maxIndex = 0;
......@@ -276,20 +276,20 @@ static void getStatics_f(const void *pData, int32_t numOfRow, int64_t *min, int6
float fv = GET_FLOAT_VAL((const char*)&(data[i]));
dsum += fv;
if (fmin > fv) {
fmin = fv;
if (flmin > fv) {
flmin = fv;
*minIndex = i;
}
if (fmax < fv) {
fmax = fv;
if (flmax < fv) {
flmax = fv;
*maxIndex = i;
}
}
SET_DOUBLE_VAL(sum, dsum);
SET_DOUBLE_VAL(max, fmax);
SET_DOUBLE_VAL(min, fmin);
SET_DOUBLE_VAL(max, flmax);
SET_DOUBLE_VAL(min, flmin);
}
static void getStatics_d(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max,
......
......@@ -229,12 +229,12 @@ static void dnodeAllocCheckItem() {
}
void dnodeCleanupCheck() {
for (ECheckItemType index = 0; index < TSDB_CHECK_ITEM_MAX; ++index) {
if (tsCheckItem[index].enable && tsCheckItem[index].stopFp) {
(*tsCheckItem[index].stopFp)();
for (ECheckItemType idx = 0; idx < TSDB_CHECK_ITEM_MAX; ++idx) {
if (tsCheckItem[idx].enable && tsCheckItem[idx].stopFp) {
(*tsCheckItem[idx].stopFp)();
}
if (tsCheckItem[index].cleanUpFp) {
(*tsCheckItem[index].cleanUpFp)();
if (tsCheckItem[idx].cleanUpFp) {
(*tsCheckItem[idx].cleanUpFp)();
}
}
}
......@@ -242,19 +242,19 @@ void dnodeCleanupCheck() {
int32_t dnodeInitCheck() {
dnodeAllocCheckItem();
for (ECheckItemType index = 0; index < TSDB_CHECK_ITEM_MAX; ++index) {
if (tsCheckItem[index].initFp) {
if ((*tsCheckItem[index].initFp)() != 0) {
dError("failed to init check item:%s", tsCheckItem[index].name);
for (ECheckItemType idx = 0; idx < TSDB_CHECK_ITEM_MAX; ++idx) {
if (tsCheckItem[idx].initFp) {
if ((*tsCheckItem[idx].initFp)() != 0) {
dError("failed to init check item:%s", tsCheckItem[idx].name);
return -1;
}
}
}
for (ECheckItemType index = 0; index < TSDB_CHECK_ITEM_MAX; ++index) {
if (tsCheckItem[index].enable && tsCheckItem[index].startFp) {
if ((*tsCheckItem[index].startFp)() != 0) {
dError("failed to check item:%s", tsCheckItem[index].name);
for (ECheckItemType idx = 0; idx < TSDB_CHECK_ITEM_MAX; ++idx) {
if (tsCheckItem[idx].enable && tsCheckItem[idx].startFp) {
if ((*tsCheckItem[idx].startFp)() != 0) {
dError("failed to check item:%s", tsCheckItem[idx].name);
exit(-1);
}
}
......
......@@ -56,17 +56,17 @@ int32_t dnodeInitServer() {
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_GRANT] = dnodeDispatchToMPeerQueue;
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_STATUS] = dnodeDispatchToMPeerQueue;
SRpcInit rpcInit;
memset(&rpcInit, 0, sizeof(rpcInit));
rpcInit.localPort = tsDnodeDnodePort;
rpcInit.label = "DND-S";
rpcInit.numOfThreads = 1;
rpcInit.cfp = dnodeProcessReqMsgFromDnode;
rpcInit.sessions = TSDB_MAX_VNODES << 4;
rpcInit.connType = TAOS_CONN_SERVER;
rpcInit.idleTime = tsShellActivityTimer * 1000;
tsServerRpc = rpcOpen(&rpcInit);
SRpcInit rpcInitial;
memset(&rpcInitial, 0, sizeof(rpcInitial));
rpcInitial.localPort = tsDnodeDnodePort;
rpcInitial.label = "DND-S";
rpcInitial.numOfThreads = 1;
rpcInitial.cfp = dnodeProcessReqMsgFromDnode;
rpcInitial.sessions = TSDB_MAX_VNODES << 4;
rpcInitial.connType = TAOS_CONN_SERVER;
rpcInitial.idleTime = tsShellActivityTimer * 1000;
tsServerRpc = rpcOpen(&rpcInitial);
if (tsServerRpc == NULL) {
dError("failed to init inter-dnodes RPC server");
return -1;
......@@ -123,19 +123,19 @@ static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg, SRpcEpSet *pEpSet) {
int32_t dnodeInitClient() {
char secret[TSDB_KEY_LEN] = "secret";
SRpcInit rpcInit;
memset(&rpcInit, 0, sizeof(rpcInit));
rpcInit.label = "DND-C";
rpcInit.numOfThreads = 1;
rpcInit.cfp = dnodeProcessRspFromDnode;
rpcInit.sessions = TSDB_MAX_VNODES << 4;
rpcInit.connType = TAOS_CONN_CLIENT;
rpcInit.idleTime = tsShellActivityTimer * 1000;
rpcInit.user = "t";
rpcInit.ckey = "key";
rpcInit.secret = secret;
tsClientRpc = rpcOpen(&rpcInit);
SRpcInit rpcInitial;
memset(&rpcInitial, 0, sizeof(rpcInitial));
rpcInitial.label = "DND-C";
rpcInitial.numOfThreads = 1;
rpcInitial.cfp = dnodeProcessRspFromDnode;
rpcInitial.sessions = TSDB_MAX_VNODES << 4;
rpcInitial.connType = TAOS_CONN_CLIENT;
rpcInitial.idleTime = tsShellActivityTimer * 1000;
rpcInitial.user = "t";
rpcInitial.ckey = "key";
rpcInitial.secret = secret;
tsClientRpc = rpcOpen(&rpcInitial);
if (tsClientRpc == NULL) {
dError("failed to init mnode rpc client");
return -1;
......
......@@ -83,18 +83,18 @@ int32_t dnodeInitShell() {
numOfThreads = 1;
}
SRpcInit rpcInit;
memset(&rpcInit, 0, sizeof(rpcInit));
rpcInit.localPort = tsDnodeShellPort;
rpcInit.label = "SHELL";
rpcInit.numOfThreads = numOfThreads;
rpcInit.cfp = dnodeProcessMsgFromShell;
rpcInit.sessions = tsMaxShellConns;
rpcInit.connType = TAOS_CONN_SERVER;
rpcInit.idleTime = tsShellActivityTimer * 1000;
rpcInit.afp = dnodeRetrieveUserAuthInfo;
tsShellRpc = rpcOpen(&rpcInit);
SRpcInit rpcInitial;
memset(&rpcInitial, 0, sizeof(rpcInitial));
rpcInitial.localPort = tsDnodeShellPort;
rpcInitial.label = "SHELL";
rpcInitial.numOfThreads = numOfThreads;
rpcInitial.cfp = dnodeProcessMsgFromShell;
rpcInitial.sessions = tsMaxShellConns;
rpcInitial.connType = TAOS_CONN_SERVER;
rpcInitial.idleTime = tsShellActivityTimer * 1000;
rpcInitial.afp = dnodeRetrieveUserAuthInfo;
tsShellRpc = rpcOpen(&rpcInitial);
if (tsShellRpc == NULL) {
dError("failed to init shell rpc server");
return -1;
......@@ -258,10 +258,10 @@ SDnodeStatisInfo dnodeGetStatisInfo() {
return info;
}
int32_t dnodeGetHttpStatusInfo(int32_t index) {
int32_t dnodeGetHttpStatusInfo(int32_t idx) {
int32_t httpStatus = 0;
#ifdef HTTP_EMBEDDED
httpStatus = httpGetStatusCodeCount(index);
httpStatus = httpGetStatusCodeCount(idx);
#endif
return httpStatus;
}
......
......@@ -93,8 +93,8 @@ static void shellCheckTablesSQLFile(const char *directoryName)
{
sprintf(shellTablesSQLFile, "%s/tables.sql", directoryName);
struct stat fstat;
if (stat(shellTablesSQLFile, &fstat) < 0) {
struct stat status;
if (stat(shellTablesSQLFile, &status) < 0) {
shellTablesSQLFile[0] = 0;
}
}
......
......@@ -145,8 +145,8 @@ static int32_t mnodeCreateCluster() {
SClusterObj *pCluster = malloc(sizeof(SClusterObj));
memset(pCluster, 0, sizeof(SClusterObj));
pCluster->createdTime = taosGetTimestampMs();
bool getuid = taosGetSystemUid(pCluster->uid);
if (!getuid) {
bool bGetuid = taosGetSystemUid(pCluster->uid);
if (!bGetuid) {
strcpy(pCluster->uid, "tdengine2.0");
mError("failed to get uid from system, set to default val %s", pCluster->uid);
} else {
......@@ -260,4 +260,4 @@ int32_t mnodeCompactCluster() {
mInfo("end to compact cluster table...");
return 0;
}
\ No newline at end of file
}
......@@ -210,7 +210,7 @@ void mnodeUpdateMnodeEpSet(SMInfos *pMinfos) {
mInfos = *pMinfos;
} else {
mInfo("vgId:1, update mnodes epSet, numOfMnodes:%d", mnodeGetMnodesNum());
int32_t index = 0;
int32_t idx = 0;
void * pIter = NULL;
while (1) {
SMnodeObj *pMnode = NULL;
......@@ -220,10 +220,10 @@ void mnodeUpdateMnodeEpSet(SMInfos *pMinfos) {
SDnodeObj *pDnode = mnodeGetDnode(pMnode->mnodeId);
if (pDnode != NULL) {
set = true;
mInfos.mnodeInfos[index].mnodeId = pMnode->mnodeId;
strcpy(mInfos.mnodeInfos[index].mnodeEp, pDnode->dnodeEp);
if (pMnode->role == TAOS_SYNC_ROLE_MASTER) mInfos.inUse = index;
index++;
mInfos.mnodeInfos[idx].mnodeId = pMnode->mnodeId;
strcpy(mInfos.mnodeInfos[idx].mnodeEp, pDnode->dnodeEp);
if (pMnode->role == TAOS_SYNC_ROLE_MASTER) mInfos.inUse = idx;
idx++;
} else {
set = false;
}
......@@ -232,7 +232,7 @@ void mnodeUpdateMnodeEpSet(SMInfos *pMinfos) {
mnodeDecMnodeRef(pMnode);
}
mInfos.mnodeNum = index;
mInfos.mnodeNum = idx;
if (mInfos.mnodeNum < sdbGetReplicaNum()) {
set = false;
mDebug("vgId:1, mnodes info not synced, current:%d syncCfgNum:%d", mInfos.mnodeNum, sdbGetReplicaNum());
......@@ -251,23 +251,23 @@ void mnodeUpdateMnodeEpSet(SMInfos *pMinfos) {
tsMEpForPeer.numOfEps = tsMInfos.mnodeNum;
mInfo("vgId:1, mnodes epSet is set, num:%d inUse:%d", tsMInfos.mnodeNum, tsMInfos.inUse);
for (int index = 0; index < mInfos.mnodeNum; ++index) {
SMInfo *pInfo = &tsMInfos.mnodeInfos[index];
taosGetFqdnPortFromEp(pInfo->mnodeEp, tsMEpForShell.fqdn[index], &tsMEpForShell.port[index]);
taosGetFqdnPortFromEp(pInfo->mnodeEp, tsMEpForPeer.fqdn[index], &tsMEpForPeer.port[index]);
tsMEpForPeer.port[index] = tsMEpForPeer.port[index] + TSDB_PORT_DNODEDNODE;
for (int idx = 0; idx < mInfos.mnodeNum; ++idx) {
SMInfo *pInfo = &tsMInfos.mnodeInfos[idx];
taosGetFqdnPortFromEp(pInfo->mnodeEp, tsMEpForShell.fqdn[idx], &tsMEpForShell.port[idx]);
taosGetFqdnPortFromEp(pInfo->mnodeEp, tsMEpForPeer.fqdn[idx], &tsMEpForPeer.port[idx]);
tsMEpForPeer.port[idx] = tsMEpForPeer.port[idx] + TSDB_PORT_DNODEDNODE;
mInfo("vgId:1, mnode:%d, fqdn:%s shell:%u peer:%u", pInfo->mnodeId, tsMEpForShell.fqdn[index],
tsMEpForShell.port[index], tsMEpForPeer.port[index]);
mInfo("vgId:1, mnode:%d, fqdn:%s shell:%u peer:%u", pInfo->mnodeId, tsMEpForShell.fqdn[idx],
tsMEpForShell.port[idx], tsMEpForPeer.port[idx]);
tsMEpForShell.port[index] = htons(tsMEpForShell.port[index]);
tsMEpForPeer.port[index] = htons(tsMEpForPeer.port[index]);
tsMEpForShell.port[idx] = htons(tsMEpForShell.port[idx]);
tsMEpForPeer.port[idx] = htons(tsMEpForPeer.port[idx]);
pInfo->mnodeId = htonl(pInfo->mnodeId);
}
} else {
mInfo("vgId:1, mnodes epSet not set, num:%d inUse:%d", tsMInfos.mnodeNum, tsMInfos.inUse);
for (int index = 0; index < tsMInfos.mnodeNum; ++index) {
mInfo("vgId:1, index:%d, ep:%s:%u", index, tsMEpForShell.fqdn[index], htons(tsMEpForShell.port[index]));
for (int idx = 0; idx < tsMInfos.mnodeNum; ++idx) {
mInfo("vgId:1, index:%d, ep:%s:%u", idx, tsMEpForShell.fqdn[idx], htons(tsMEpForShell.port[idx]));
}
}
......@@ -603,4 +603,4 @@ int32_t mnodeCompactMnodes() {
mInfo("end to compact mnodes table...");
return 0;
}
\ No newline at end of file
}
......@@ -331,7 +331,7 @@ int32_t sdbUpdateSync(void *pMnodes) {
mDebug("vgId:1, update sync config, pMnodes:%p", pMnodes);
SSyncCfg syncCfg = {0};
int32_t index = 0;
int32_t idx = 0;
if (pMinfos == NULL) {
mDebug("vgId:1, mInfos not input, use mInfos in sdb, numOfMnodes:%d", syncCfg.replica);
......@@ -342,29 +342,29 @@ int32_t sdbUpdateSync(void *pMnodes) {
pIter = mnodeGetNextMnode(pIter, &pMnode);
if (pMnode == NULL) break;
syncCfg.nodeInfo[index].nodeId = pMnode->mnodeId;
syncCfg.nodeInfo[idx].nodeId = pMnode->mnodeId;
SDnodeObj *pDnode = mnodeGetDnode(pMnode->mnodeId);
if (pDnode != NULL) {
syncCfg.nodeInfo[index].nodePort = pDnode->dnodePort + TSDB_PORT_SYNC;
tstrncpy(syncCfg.nodeInfo[index].nodeFqdn, pDnode->dnodeFqdn, TSDB_FQDN_LEN);
index++;
syncCfg.nodeInfo[idx].nodePort = pDnode->dnodePort + TSDB_PORT_SYNC;
tstrncpy(syncCfg.nodeInfo[idx].nodeFqdn, pDnode->dnodeFqdn, TSDB_FQDN_LEN);
idx++;
}
mnodeDecDnodeRef(pDnode);
mnodeDecMnodeRef(pMnode);
}
syncCfg.replica = index;
syncCfg.replica = idx;
} else {
mDebug("vgId:1, mInfos input, numOfMnodes:%d", pMinfos->mnodeNum);
for (index = 0; index < pMinfos->mnodeNum; ++index) {
SMInfo *node = &pMinfos->mnodeInfos[index];
syncCfg.nodeInfo[index].nodeId = node->mnodeId;
taosGetFqdnPortFromEp(node->mnodeEp, syncCfg.nodeInfo[index].nodeFqdn, &syncCfg.nodeInfo[index].nodePort);
syncCfg.nodeInfo[index].nodePort += TSDB_PORT_SYNC;
for (idx = 0; idx < pMinfos->mnodeNum; ++idx) {
SMInfo *node = &pMinfos->mnodeInfos[idx];
syncCfg.nodeInfo[idx].nodeId = node->mnodeId;
taosGetFqdnPortFromEp(node->mnodeEp, syncCfg.nodeInfo[idx].nodeFqdn, &syncCfg.nodeInfo[idx].nodePort);
syncCfg.nodeInfo[idx].nodePort += TSDB_PORT_SYNC;
}
syncCfg.replica = index;
syncCfg.replica = idx;
mnodeUpdateMnodeEpSet(pMnodes);
}
......
......@@ -45,8 +45,8 @@ void taosRemoveDir(char *rootDir) {
uInfo("dir:%s is removed", rootDir);
}
bool taosDirExist(const char* dirname) {
return access(dirname, F_OK) == 0;
bool taosDirExist(const char* dir) {
return access(dir, F_OK) == 0;
}
int32_t taosMkdirP(const char *dir, int keepLast) {
......
......@@ -44,11 +44,11 @@ void taosGetTmpfilePath(const char *fileNamePrefix, char *dstPath) {
strcat(tmpPath, "-%d-%s");
}
char rand[32] = {0};
char rand_num[32] = {0};
sprintf(rand, "%" PRIu64, atomic_add_fetch_64(&seqId, 1));
sprintf(rand_num, "%" PRIu64, atomic_add_fetch_64(&seqId, 1));
snprintf(dstPath, PATH_MAX, tmpPath, getpid(), rand);
snprintf(dstPath, PATH_MAX, tmpPath, getpid(), rand_num);
}
#else
......@@ -71,11 +71,11 @@ void taosGetTmpfilePath(const char *fileNamePrefix, char *dstPath) {
strcat(tmpPath, "-%d-%s");
}
char rand[32] = {0};
char rand_num[32] = {0};
sprintf(rand, "%" PRIu64, atomic_add_fetch_64(&seqId, 1));
sprintf(rand_num, "%" PRIu64, atomic_add_fetch_64(&seqId, 1));
snprintf(dstPath, PATH_MAX, tmpPath, getpid(), rand);
snprintf(dstPath, PATH_MAX, tmpPath, getpid(), rand_num);
}
#endif
......
......@@ -82,26 +82,26 @@ void deltaToUtcInitOnce() {
}
static int64_t parseFraction(char* str, char** end, int32_t timePrec);
static int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec, char delim);
static int32_t parseLocaltime(char* timestr, int64_t* time, int32_t timePrec, char delim, bool withDST);
static int32_t parseTimeWithTz(char* timestr, int64_t* pTime, int32_t timePrec, char delim);
static int32_t parseLocaltime(char* timestr, int64_t* pTime, int32_t timePrec, char delim, bool withDST);
static char* forwardToTimeStringEnd(char* str);
static bool checkTzPresent(char *str, int32_t len);
int32_t taosGetTimestampSec() { return (int32_t)time(NULL); }
int32_t taosParseTime(char* timestr, int64_t* time, int32_t len, int32_t timePrec, int8_t day_light) {
int32_t taosParseTime(char* timestr, int64_t* pTime, int32_t len, int32_t timePrec, int8_t day_light) {
/* parse datatime string in with tz */
if (strnchr(timestr, 'T', len, false) != NULL) {
if (checkTzPresent(timestr, len)) {
return parseTimeWithTz(timestr, time, timePrec, 'T');
return parseTimeWithTz(timestr, pTime, timePrec, 'T');
} else {
return parseLocaltime(timestr, time, timePrec, 'T', day_light);
return parseLocaltime(timestr, pTime, timePrec, 'T', day_light);
}
} else {
if (checkTzPresent(timestr, len)) {
return parseTimeWithTz(timestr, time, timePrec, 0);
return parseTimeWithTz(timestr, pTime, timePrec, 0);
} else {
return parseLocaltime(timestr, time, timePrec, 0, day_light);
return parseLocaltime(timestr, pTime, timePrec, 0, day_light);
}
}
}
......@@ -121,8 +121,8 @@ bool checkTzPresent(char *str, int32_t len) {
}
FORCE_INLINE int32_t taos_parse_time(char* timestr, int64_t* time, int32_t len, int32_t timePrec, int8_t day_light) {
return taosParseTime(timestr, time, len, timePrec, day_light);
FORCE_INLINE int32_t taos_parse_time(char* timestr, int64_t* pTime, int32_t len, int32_t timePrec, int8_t day_light) {
return taosParseTime(timestr, pTime, len, timePrec, day_light);
}
char* forwardToTimeStringEnd(char* str) {
......@@ -243,7 +243,7 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) {
* 2013-04-12T15:52:01+0800
* 2013-04-12T15:52:01.123+0800
*/
int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec, char delim) {
int32_t parseTimeWithTz(char* timestr, int64_t* pTime, int32_t timePrec, char delim) {
int64_t factor = (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 :
(timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000);
......@@ -277,14 +277,14 @@ int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec, char del
if ((str[0] == 'Z' || str[0] == 'z') && str[1] == '\0') {
/* utc time, no millisecond, return directly*/
*time = seconds * factor;
*pTime = seconds * factor;
} else if (str[0] == '.') {
str += 1;
if ((fraction = parseFraction(str, &str, timePrec)) < 0) {
return -1;
}
*time = seconds * factor + fraction;
*pTime = seconds * factor + fraction;
char seg = str[0];
if (seg != 'Z' && seg != 'z' && seg != '+' && seg != '-') {
......@@ -297,18 +297,18 @@ int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec, char del
return -1;
}
*time += tzOffset * factor;
*pTime += tzOffset * factor;
}
} else if (str[0] == '+' || str[0] == '-') {
*time = seconds * factor + fraction;
*pTime = seconds * factor + fraction;
// parse the timezone
if (parseTimezone(str, &tzOffset) == -1) {
return -1;
}
*time += tzOffset * factor;
*pTime += tzOffset * factor;
} else {
return -1;
}
......@@ -316,8 +316,8 @@ int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec, char del
return 0;
}
int32_t parseLocaltime(char* timestr, int64_t* time, int32_t timePrec, char delim, bool withDST) {
*time = 0;
int32_t parseLocaltime(char* timestr, int64_t* pTime, int32_t timePrec, char delim, bool withDST) {
*pTime = 0;
struct tm tm = {0};
if (withDST) {
tm.tm_isdst = -1;
......@@ -365,65 +365,65 @@ int32_t parseLocaltime(char* timestr, int64_t* time, int32_t timePrec, char deli
int64_t factor = (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 :
(timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000);
*time = factor * seconds + fraction;
*pTime = factor * seconds + fraction;
return 0;
}
int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrecision) {
int64_t convertTimePrecision(int64_t timeStamp, int32_t fromPrecision, int32_t toPrecision) {
assert(fromPrecision == TSDB_TIME_PRECISION_MILLI ||
fromPrecision == TSDB_TIME_PRECISION_MICRO ||
fromPrecision == TSDB_TIME_PRECISION_NANO);
assert(toPrecision == TSDB_TIME_PRECISION_MILLI ||
toPrecision == TSDB_TIME_PRECISION_MICRO ||
toPrecision == TSDB_TIME_PRECISION_NANO);
double tempResult = (double)time;
double tempResult = (double)timeStamp;
switch(fromPrecision) {
case TSDB_TIME_PRECISION_MILLI: {
switch (toPrecision) {
case TSDB_TIME_PRECISION_MILLI:
return time;
return timeStamp;
case TSDB_TIME_PRECISION_MICRO:
tempResult *= 1000;
time *= 1000;
timeStamp *= 1000;
goto end_;
case TSDB_TIME_PRECISION_NANO:
tempResult *= 1000000;
time *= 1000000;
timeStamp *= 1000000;
goto end_;
}
} // end from milli
case TSDB_TIME_PRECISION_MICRO: {
switch (toPrecision) {
case TSDB_TIME_PRECISION_MILLI:
return time / 1000;
return timeStamp / 1000;
case TSDB_TIME_PRECISION_MICRO:
return time;
return timeStamp;
case TSDB_TIME_PRECISION_NANO:
tempResult *= 1000;
time *= 1000;
timeStamp *= 1000;
goto end_;
}
} //end from micro
case TSDB_TIME_PRECISION_NANO: {
switch (toPrecision) {
case TSDB_TIME_PRECISION_MILLI:
return time / 1000000;
return timeStamp / 1000000;
case TSDB_TIME_PRECISION_MICRO:
return time / 1000;
return timeStamp / 1000;
case TSDB_TIME_PRECISION_NANO:
return time;
return timeStamp;
}
} //end from nano
default: {
assert(0);
return time; // only to pass windows compilation
return timeStamp; // only to pass windows compilation
}
} //end switch fromPrecision
end_:
if (tempResult >= (double)INT64_MAX) return INT64_MAX;
if (tempResult <= (double)INT64_MIN) return INT64_MIN + 1; // INT64_MIN means NULL
return time;
return timeStamp;
}
static int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecision) {
......
......@@ -33,9 +33,9 @@ void* taosLoadDll(const char *filename) {
void* taosLoadSym(void* handle, char* name) {
void* sym = dlsym(handle, name);
char* error = NULL;
char* err = NULL;
if ((error = dlerror()) != NULL) {
if ((err = dlerror()) != NULL) {
uWarn("load sym:%s failed, error:%s", name, dlerror());
return NULL;
}
......
......@@ -352,7 +352,7 @@ static uint64_t hllCountCnt(uint8_t *buckets) {
static uint8_t hllCountNum(void *ele, int32_t elesize, int32_t *buk) {
uint64_t hash = MurmurHash3_64(ele,elesize);
int32_t index = hash & HLL_BUCKET_MASK;
int32_t idx = hash & HLL_BUCKET_MASK;
hash >>= HLL_BUCKET_BITS;
hash |= ((uint64_t)1<<HLL_DATA_BITS);
uint64_t bit = 1;
......@@ -361,7 +361,7 @@ static uint8_t hllCountNum(void *ele, int32_t elesize, int32_t *buk) {
count++;
bit <<= 1;
}
*buk = index;
*buk = idx;
return count;
}
......@@ -377,11 +377,11 @@ static void hll_function(SQLFunctionCtx *pCtx) {
elesize = varDataLen(val);
val = varDataVal(val);
}
int32_t index = 0;
uint8_t count = hllCountNum(val,elesize,&index);
uint8_t oldcount = pHLLInfo->buckets[index];
int32_t idx = 0;
uint8_t count = hllCountNum(val,elesize,&idx);
uint8_t oldcount = pHLLInfo->buckets[idx];
if (count > oldcount) {
pHLLInfo->buckets[index] = count;
pHLLInfo->buckets[idx] = count;
}
}
GET_RES_INFO(pCtx)->numOfRes = 1;
......@@ -1363,14 +1363,14 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin,
}
void* tval = NULL;
int16_t index = 0;
int16_t idx = 0;
if (isMin) {
tval = &pCtx->preAggVals.statis.min;
index = pCtx->preAggVals.statis.minIndex;
idx = pCtx->preAggVals.statis.minIndex;
} else {
tval = &pCtx->preAggVals.statis.max;
index = pCtx->preAggVals.statis.maxIndex;
idx = pCtx->preAggVals.statis.maxIndex;
}
TSKEY key = TSKEY_INITIAL_VAL;
......@@ -1381,12 +1381,12 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin,
*
* The following codes of 3 lines will be removed later.
*/
// if (index < 0 || index >= pCtx->size + pCtx->startOffset) {
// index = 0;
// if (idx < 0 || idx >= pCtx->size + pCtx->startOffset) {
// idx = 0;
// }
// the index is the original position, not the relative position
key = pCtx->ptsList[index];
// the idx is the original position, not the relative position
key = pCtx->ptsList[idx];
}
if (IS_SIGNED_NUMERIC_TYPE(pCtx->inputType)) {
......@@ -2065,15 +2065,15 @@ static void first_function(SQLFunctionCtx *pCtx) {
SET_VAL(pCtx, notNullElems, 1);
}
static void first_data_assign_impl(SQLFunctionCtx *pCtx, char *pData, int32_t index) {
static void first_data_assign_impl(SQLFunctionCtx *pCtx, char *pData, int32_t idx) {
int64_t *timestamp = GET_TS_LIST(pCtx);
SFirstLastInfo *pInfo = (SFirstLastInfo *)(pCtx->pOutput + pCtx->inputBytes);
if (pInfo->hasResult != DATA_SET_FLAG || timestamp[index] < pInfo->ts) {
if (pInfo->hasResult != DATA_SET_FLAG || timestamp[idx] < pInfo->ts) {
memcpy(pCtx->pOutput, pData, pCtx->inputBytes);
pInfo->hasResult = DATA_SET_FLAG;
pInfo->ts = timestamp[index];
pInfo->ts = timestamp[idx];
DO_UPDATE_TAG_COLUMNS(pCtx, pInfo->ts);
}
......@@ -2203,19 +2203,19 @@ static void last_function(SQLFunctionCtx *pCtx) {
SET_VAL(pCtx, notNullElems, 1);
}
static void last_data_assign_impl(SQLFunctionCtx *pCtx, char *pData, int32_t index) {
static void last_data_assign_impl(SQLFunctionCtx *pCtx, char *pData, int32_t idx) {
int64_t *timestamp = GET_TS_LIST(pCtx);
SFirstLastInfo *pInfo = (SFirstLastInfo *)(pCtx->pOutput + pCtx->inputBytes);
if (pInfo->hasResult != DATA_SET_FLAG || pInfo->ts < timestamp[index]) {
if (pInfo->hasResult != DATA_SET_FLAG || pInfo->ts < timestamp[idx]) {
#if defined(_DEBUG_VIEW)
qDebug("assign index:%d, ts:%" PRId64 ", val:%d, ", index, timestamp[index], *(int32_t *)pData);
qDebug("assign index:%d, ts:%" PRId64 ", val:%d, ", idx, timestamp[idx], *(int32_t *)pData);
#endif
memcpy(pCtx->pOutput, pData, pCtx->inputBytes);
pInfo->hasResult = DATA_SET_FLAG;
pInfo->ts = timestamp[index];
pInfo->ts = timestamp[idx];
DO_UPDATE_TAG_COLUMNS(pCtx, pInfo->ts);
}
......@@ -3188,12 +3188,12 @@ static bool leastsquares_function_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo
return true;
}
#define LEASTSQR_CAL(p, x, y, index, step) \
#define LEASTSQR_CAL(p, x, y, idx, step) \
do { \
(p)[0][0] += (double)(x) * (x); \
(p)[0][1] += (double)(x); \
(p)[0][2] += (double)(x) * (y)[index]; \
(p)[1][2] += (y)[index]; \
(p)[0][2] += (double)(x) * (y)[idx]; \
(p)[1][2] += (y)[idx]; \
(x) += step; \
} while (0)
......@@ -3831,16 +3831,16 @@ static void diff_function(SQLFunctionCtx *pCtx) {
char *getScalarExprColumnData(void *param, const char* name, int32_t colId) {
SScalarExprSupport *pSupport = (SScalarExprSupport *)param;
int32_t index = -1;
int32_t idx = -1;
for (int32_t i = 0; i < pSupport->numOfCols; ++i) {
if (colId == pSupport->colList[i].colId) {
index = i;
idx = i;
break;
}
}
assert(index >= 0);
return pSupport->data[index] + pSupport->offset * pSupport->colList[index].bytes;
assert(idx >= 0);
return pSupport->data[idx] + pSupport->offset * pSupport->colList[idx].bytes;
}
static void scalar_expr_function(SQLFunctionCtx *pCtx) {
......@@ -4049,14 +4049,14 @@ static double twa_get_area(SPoint1 s, SPoint1 e) {
return val;
}
static int32_t twa_function_impl(SQLFunctionCtx* pCtx, int32_t index, int32_t size) {
static int32_t twa_function_impl(SQLFunctionCtx* pCtx, int32_t idx, int32_t size) {
int32_t notNullElems = 0;
SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx);
STwaInfo *pInfo = GET_ROWCELL_INTERBUF(pResInfo);
TSKEY *tsList = GET_TS_LIST(pCtx);
int32_t i = index;
int32_t i = idx;
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pCtx->order);
SPoint1* last = &pInfo->p;
......@@ -4067,7 +4067,7 @@ static int32_t twa_function_impl(SQLFunctionCtx* pCtx, int32_t index, int32_t si
assert(last->key == INT64_MIN);
last->key = tsList[i];
GET_TYPED_DATA(last->val, double, pCtx->inputType, GET_INPUT_DATA(pCtx, index));
GET_TYPED_DATA(last->val, double, pCtx->inputType, GET_INPUT_DATA(pCtx, idx));
pInfo->dOutput += twa_get_area(pCtx->start, *last);
......@@ -4077,7 +4077,7 @@ static int32_t twa_function_impl(SQLFunctionCtx* pCtx, int32_t index, int32_t si
i += step;
} else if (pInfo->p.key == INT64_MIN) {
last->key = tsList[i];
GET_TYPED_DATA(last->val, double, pCtx->inputType, GET_INPUT_DATA(pCtx, index));
GET_TYPED_DATA(last->val, double, pCtx->inputType, GET_INPUT_DATA(pCtx, idx));
pInfo->hasResult = DATA_SET_FLAG;
pInfo->win.skey = last->key;
......@@ -5016,13 +5016,13 @@ static void mavg_function(SQLFunctionCtx *pCtx) {
//////////////////////////////////////////////////////////////////////////////////
// Sample function with reservoir sampling algorithm
static void assignResultSample(SQLFunctionCtx *pCtx, SSampleFuncInfo *pInfo, int32_t index, int64_t ts, void *pData, uint16_t type, int16_t bytes, char *inputTags) {
assignVal(pInfo->values + index*bytes, pData, bytes, type);
*(pInfo->timeStamps + index) = ts;
static void assignResultSample(SQLFunctionCtx *pCtx, SSampleFuncInfo *pInfo, int32_t idx, int64_t ts, void *pData, uint16_t type, int16_t bytes, char *inputTags) {
assignVal(pInfo->values + idx*bytes, pData, bytes, type);
*(pInfo->timeStamps + idx) = ts;
SExtTagsInfo* pTagInfo = &pCtx->tagInfo;
int32_t posTag = 0;
char* tags = pInfo->taglists + index*pTagInfo->tagsLen;
char* tags = pInfo->taglists + idx*pTagInfo->tagsLen;
if (pCtx->currentStage == MERGE_STAGE) {
assert(inputTags != NULL);
memcpy(tags, inputTags, (size_t)pTagInfo->tagsLen);
......
此差异已折叠。
......@@ -485,9 +485,9 @@ int32_t compare_a(tOrderDescriptor *pDescriptor, int32_t numOfRows1, int32_t s1,
int32_t compare_aRv(SSDataBlock* pBlock, SArray* colIndex, int32_t numOfCols, int32_t rowIndex, char** buffer, int32_t order) {
for (int32_t i = 0; i < numOfCols; ++i) {
SColIndex* pColIndex = taosArrayGet(colIndex, i);
int32_t index = pColIndex->colIndex;
int32_t idx = pColIndex->colIndex;
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, index);
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, idx);
assert(pColIndex->colId == pColInfo->info.colId);
char* data = pColInfo->pData + rowIndex * pColInfo->info.bytes;
......@@ -1176,14 +1176,14 @@ void tColModelCompact(SColumnModel *pModel, tFilePage *inputBuffer, int32_t maxE
}
}
SSchema1* getColumnModelSchema(SColumnModel *pColumnModel, int32_t index) {
assert(pColumnModel != NULL && index >= 0 && index < pColumnModel->numOfCols);
return &pColumnModel->pFields[index].field;
SSchema1* getColumnModelSchema(SColumnModel *pColumnModel, int32_t idx) {
assert(pColumnModel != NULL && idx >= 0 && idx < pColumnModel->numOfCols);
return &pColumnModel->pFields[idx].field;
}
int16_t getColumnModelOffset(SColumnModel *pColumnModel, int32_t index) {
assert(pColumnModel != NULL && index >= 0 && index < pColumnModel->numOfCols);
return pColumnModel->pFields[index].offset;
int16_t getColumnModelOffset(SColumnModel *pColumnModel, int32_t idx) {
assert(pColumnModel != NULL && idx >= 0 && idx < pColumnModel->numOfCols);
return pColumnModel->pFields[idx].offset;
}
void tColModelErase(SColumnModel *pModel, tFilePage *inputBuffer, int32_t blockCapacity, int32_t s, int32_t e) {
......@@ -1257,17 +1257,17 @@ void tOrderDescDestroy(tOrderDescriptor *pDesc) {
tfree(pDesc);
}
void taoscQSort(void** pCols, SSchema* pSchema, int32_t numOfCols, int32_t numOfRows, int32_t index, __compar_fn_t compareFn) {
assert(numOfRows > 0 && numOfCols > 0 && index >= 0 && index < numOfCols);
void taoscQSort(void** pCols, SSchema* pSchema, int32_t numOfCols, int32_t numOfRows, int32_t idx, __compar_fn_t compareFn) {
assert(numOfRows > 0 && numOfCols > 0 && idx >= 0 && idx < numOfCols);
int32_t bytes = pSchema[index].bytes;
int32_t bytes = pSchema[idx].bytes;
int32_t size = bytes + sizeof(int32_t);
char* buf = calloc(1, size * numOfRows);
for(int32_t i = 0; i < numOfRows; ++i) {
char* dest = buf + size * i;
memcpy(dest, ((char*) pCols[index]) + bytes * i, bytes);
memcpy(dest, ((char*) pCols[idx]) + bytes * i, bytes);
*(int32_t*)(dest+bytes) = i;
}
......@@ -1279,7 +1279,7 @@ void taoscQSort(void** pCols, SSchema* pSchema, int32_t numOfCols, int32_t numOf
for(int32_t i = 0; i < numOfCols; ++i) {
int32_t bytes1 = pSchema[i].bytes;
if (i == index) {
if (i == idx) {
for(int32_t j = 0; j < numOfRows; ++j){
char* src = buf + (j * size);
char* dest = ((char*)pCols[i]) + (j * bytes1);
......
......@@ -63,8 +63,8 @@ static void doFillOneRowResult(SFillInfo* pFillInfo, void** data, char** srcData
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pFillInfo->order);
// set the primary timestamp column value
int32_t index = pFillInfo->numOfCurrent;
char* val = elePtrAt(data[0], TSDB_KEYSIZE, index);
int32_t idx = pFillInfo->numOfCurrent;
char* val = elePtrAt(data[0], TSDB_KEYSIZE, idx);
*(TSKEY*) val = pFillInfo->currentKey;
// set the other values
......@@ -78,11 +78,11 @@ static void doFillOneRowResult(SFillInfo* pFillInfo, void** data, char** srcData
continue;
}
char* output = elePtrAt(data[i], pCol->col.bytes, index);
char* output = elePtrAt(data[i], pCol->col.bytes, idx);
assignVal(output, p + pCol->col.offset, pCol->col.bytes, pCol->col.type);
}
} else { // no prev value yet, set the value for NULL
setNullValueForRow(pFillInfo, data, pFillInfo->numOfCols, index);
setNullValueForRow(pFillInfo, data, pFillInfo->numOfCols, idx);
}
} else if (pFillInfo->type == TSDB_FILL_NEXT) {
char* p = next;
......@@ -94,11 +94,11 @@ static void doFillOneRowResult(SFillInfo* pFillInfo, void** data, char** srcData
continue;
}
char* output = elePtrAt(data[i], pCol->col.bytes, index);
char* output = elePtrAt(data[i], pCol->col.bytes, idx);
assignVal(output, p + pCol->col.offset, pCol->col.bytes, pCol->col.type);
}
} else { // no prev value yet, set the value for NULL
setNullValueForRow(pFillInfo, data, pFillInfo->numOfCols, index);
setNullValueForRow(pFillInfo, data, pFillInfo->numOfCols, idx);
}
} else if (pFillInfo->type == TSDB_FILL_LINEAR) {
if (prev != NULL && !outOfBound) {
......@@ -111,7 +111,7 @@ static void doFillOneRowResult(SFillInfo* pFillInfo, void** data, char** srcData
int16_t type = pCol->col.type;
int16_t bytes = pCol->col.bytes;
char *val1 = elePtrAt(data[i], pCol->col.bytes, index);
char *val1 = elePtrAt(data[i], pCol->col.bytes, idx);
if (type == TSDB_DATA_TYPE_BINARY|| type == TSDB_DATA_TYPE_NCHAR || type == TSDB_DATA_TYPE_BOOL) {
setNull(val1, pCol->col.type, bytes);
continue;
......@@ -128,7 +128,7 @@ static void doFillOneRowResult(SFillInfo* pFillInfo, void** data, char** srcData
taosGetLinearInterpolationVal(&point, type, &point1, &point2, type, &exceedMax, &exceedMin);
}
} else {
setNullValueForRow(pFillInfo, data, pFillInfo->numOfCols, index);
setNullValueForRow(pFillInfo, data, pFillInfo->numOfCols, idx);
}
} else { // fill the default value */
for (int32_t i = 1; i < pFillInfo->numOfCols; ++i) {
......@@ -137,12 +137,12 @@ static void doFillOneRowResult(SFillInfo* pFillInfo, void** data, char** srcData
continue;
}
char* val1 = elePtrAt(data[i], pCol->col.bytes, index);
char* val1 = elePtrAt(data[i], pCol->col.bytes, idx);
assignVal(val1, (char*)&pCol->fillVal.i, pCol->col.bytes, pCol->col.type);
}
}
setTagsValue(pFillInfo, data, index);
setTagsValue(pFillInfo, data, idx);
pFillInfo->currentKey = taosTimeAdd(pFillInfo->currentKey, pFillInfo->interval.sliding * step, pFillInfo->interval.slidingUnit, pFillInfo->precision);
pFillInfo->numOfCurrent++;
}
......@@ -303,11 +303,11 @@ static int32_t setTagColumnInfo(SFillInfo* pFillInfo, int32_t numOfCols, int32_t
numOfTags += 1;
bool exists = false;
int32_t index = -1;
int32_t idx = -1;
for (int32_t j = 0; j < k; ++j) {
if (pFillInfo->pTags[j].col.colId == pColInfo->col.colId) {
exists = true;
index = j;
idx = j;
break;
}
}
......@@ -323,7 +323,7 @@ static int32_t setTagColumnInfo(SFillInfo* pFillInfo, int32_t numOfCols, int32_t
k += 1;
} else {
pColInfo->tagIndex = index;
pColInfo->tagIndex = idx;
}
}
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -126,9 +126,9 @@ static SQueryNode* doAddTableColumnNode(SQueryInfo* pQueryInfo, STableMetaInfo*
for (int32_t i = 0; i < numOfCols; ++i) {
SColumn* pCol = taosArrayGetP(tableCols, i);
SColumnIndex index = {.tableIndex = 0, .columnIndex = pCol->columnIndex};
STableMetaInfo* pTableMetaInfo1 = tscGetMetaInfo(pQueryInfo, index.tableIndex);
SExprInfo* p = tscExprCreate(pTableMetaInfo1, TSDB_FUNC_PRJ, &index, pCol->info.type, pCol->info.bytes,
SColumnIndex idx = {.tableIndex = 0, .columnIndex = pCol->columnIndex};
STableMetaInfo* pTableMetaInfo1 = tscGetMetaInfo(pQueryInfo, idx.tableIndex);
SExprInfo* p = tscExprCreate(pTableMetaInfo1, TSDB_FUNC_PRJ, &idx, pCol->info.type, pCol->info.bytes,
pCol->info.colId, 0, TSDB_COL_NORMAL);
strncpy(p->base.aliasName, pSchema[pCol->columnIndex].name, tListLen(p->base.aliasName));
......
......@@ -857,8 +857,8 @@ SArray *tVariantListAppend(SArray *pList, tVariant *pVar, uint8_t sortOrder) {
return pList;
}
SArray *tVariantListInsert(SArray *pList, tVariant *pVar, uint8_t sortOrder, int32_t index) {
if (pList == NULL || pVar == NULL || index >= taosArrayGetSize(pList)) {
SArray *tVariantListInsert(SArray *pList, tVariant *pVar, uint8_t sortOrder, int32_t idx) {
if (pList == NULL || pVar == NULL || idx >= taosArrayGetSize(pList)) {
return tVariantListAppend(NULL, pVar, sortOrder);
}
......@@ -867,7 +867,7 @@ SArray *tVariantListInsert(SArray *pList, tVariant *pVar, uint8_t sortOrder, int
item.pVar = *pVar;
item.sortOrder = sortOrder;
taosArrayInsert(pList, index, &item);
taosArrayInsert(pList, idx, &item);
return pList;
}
......@@ -878,7 +878,8 @@ SRelationInfo *setTableNameList(SRelationInfo* pRelationInfo, SStrToken *pName,
}
pRelationInfo->type = SQL_NODE_FROM_TABLELIST;
SRelElementPair p = {.tableName = *pName};
SRelElementPair p;
p.tableName = *pName;
if (pAlias != NULL) {
p.aliasName = *pAlias;
} else {
......@@ -917,7 +918,8 @@ SRelationInfo* addSubqueryElem(SRelationInfo* pRelationInfo, SArray* pSub, SStrT
pRelationInfo->type = SQL_NODE_FROM_SUBQUERY;
SRelElementPair p = {.pSubquery = pSub};
SRelElementPair p;
p.pSubquery = pSub;
if (pAlias != NULL) {
p.aliasName = *pAlias;
} else {
......
......@@ -183,9 +183,9 @@ void clearResultRow(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pResultRow, int16
}
// TODO refactor: use macro
SResultRowCellInfo* getResultCell(const SResultRow* pRow, int32_t index, int32_t* offset) {
assert(index >= 0 && offset != NULL);
return (SResultRowCellInfo*)((char*) pRow->pCellInfo + offset[index]);
SResultRowCellInfo* getResultCell(const SResultRow* pRow, int32_t idx, int32_t* offset) {
assert(idx >= 0 && offset != NULL);
return (SResultRowCellInfo*)((char*) pRow->pCellInfo + offset[idx]);
}
size_t getResultRowSize(SQueryRuntimeEnv* pRuntimeEnv) {
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册