未验证 提交 5a8172d6 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #17298 from taosdata/fix/glzhao_coverity

fix: fix coverity issues
...@@ -184,22 +184,54 @@ void tmq_commit_cb_print(tmq_t* tmq, int32_t code, void* param) { ...@@ -184,22 +184,54 @@ void tmq_commit_cb_print(tmq_t* tmq, int32_t code, void* param) {
tmq_t* build_consumer() { tmq_t* build_consumer() {
tmq_conf_res_t code; tmq_conf_res_t code;
tmq_conf_t* conf = tmq_conf_new(); tmq_conf_t* conf = tmq_conf_new();
code = tmq_conf_set(conf, "enable.auto.commit", "true"); code = tmq_conf_set(conf, "enable.auto.commit", "true");
if (TMQ_CONF_OK != code) return NULL; if (TMQ_CONF_OK != code) {
tmq_conf_destroy(conf);
return NULL;
}
code = tmq_conf_set(conf, "auto.commit.interval.ms", "1000"); code = tmq_conf_set(conf, "auto.commit.interval.ms", "1000");
if (TMQ_CONF_OK != code) return NULL; if (TMQ_CONF_OK != code) {
tmq_conf_destroy(conf);
return NULL;
}
code = tmq_conf_set(conf, "group.id", "cgrpName"); code = tmq_conf_set(conf, "group.id", "cgrpName");
if (TMQ_CONF_OK != code) return NULL; if (TMQ_CONF_OK != code) {
tmq_conf_destroy(conf);
return NULL;
}
code = tmq_conf_set(conf, "client.id", "user defined name"); code = tmq_conf_set(conf, "client.id", "user defined name");
if (TMQ_CONF_OK != code) return NULL; if (TMQ_CONF_OK != code) {
tmq_conf_destroy(conf);
return NULL;
}
code = tmq_conf_set(conf, "td.connect.user", "root"); code = tmq_conf_set(conf, "td.connect.user", "root");
if (TMQ_CONF_OK != code) return NULL; if (TMQ_CONF_OK != code) {
tmq_conf_destroy(conf);
return NULL;
}
code = tmq_conf_set(conf, "td.connect.pass", "taosdata"); code = tmq_conf_set(conf, "td.connect.pass", "taosdata");
if (TMQ_CONF_OK != code) return NULL; if (TMQ_CONF_OK != code) {
tmq_conf_destroy(conf);
return NULL;
}
code = tmq_conf_set(conf, "auto.offset.reset", "earliest"); code = tmq_conf_set(conf, "auto.offset.reset", "earliest");
if (TMQ_CONF_OK != code) return NULL; if (TMQ_CONF_OK != code) {
tmq_conf_destroy(conf);
return NULL;
}
code = tmq_conf_set(conf, "experimental.snapshot.enable", "false"); code = tmq_conf_set(conf, "experimental.snapshot.enable", "false");
if (TMQ_CONF_OK != code) return NULL; if (TMQ_CONF_OK != code) {
tmq_conf_destroy(conf);
return NULL;
}
tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL); tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL);
......
...@@ -411,7 +411,7 @@ _exit: ...@@ -411,7 +411,7 @@ _exit:
int32_t tTSRowClone(const STSRow2 *pRow, STSRow2 **ppRow) { int32_t tTSRowClone(const STSRow2 *pRow, STSRow2 **ppRow) {
int32_t code = 0; int32_t code = 0;
int32_t rLen; int32_t rLen = 0;
TSROW_LEN(pRow, rLen); TSROW_LEN(pRow, rLen);
(*ppRow) = (STSRow2 *)taosMemoryMalloc(rLen); (*ppRow) = (STSRow2 *)taosMemoryMalloc(rLen);
...@@ -1678,8 +1678,8 @@ int32_t tColDataCopy(SColData *pColDataSrc, SColData *pColDataDest) { ...@@ -1678,8 +1678,8 @@ int32_t tColDataCopy(SColData *pColDataSrc, SColData *pColDataDest) {
int32_t size; int32_t size;
ASSERT(pColDataSrc->nVal > 0); ASSERT(pColDataSrc->nVal > 0);
ASSERT(pColDataDest->cid = pColDataSrc->cid); ASSERT(pColDataDest->cid == pColDataSrc->cid);
ASSERT(pColDataDest->type = pColDataSrc->type); ASSERT(pColDataDest->type == pColDataSrc->type);
pColDataDest->smaOn = pColDataSrc->smaOn; pColDataDest->smaOn = pColDataSrc->smaOn;
pColDataDest->nVal = pColDataSrc->nVal; pColDataDest->nVal = pColDataSrc->nVal;
...@@ -1711,4 +1711,4 @@ int32_t tColDataCopy(SColData *pColDataSrc, SColData *pColDataDest) { ...@@ -1711,4 +1711,4 @@ int32_t tColDataCopy(SColData *pColDataSrc, SColData *pColDataDest) {
_exit: _exit:
return code; return code;
} }
\ No newline at end of file
...@@ -35,7 +35,7 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) { ...@@ -35,7 +35,7 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
// tscError("tmp file created failed since %s", terrstr()); // tscError("tmp file created failed since %s", terrstr());
return NULL; return NULL;
} }
STSBuf* pTSBuf = taosMemoryCalloc(1, sizeof(STSBuf)); STSBuf* pTSBuf = taosMemoryCalloc(1, sizeof(STSBuf));
if (pTSBuf == NULL) { if (pTSBuf == NULL) {
return NULL; return NULL;
...@@ -52,10 +52,13 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) { ...@@ -52,10 +52,13 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
} }
if (!autoDelete) { if (!autoDelete) {
taosRemoveFile(pTSBuf->path); if (taosRemoveFile(pTSBuf->path) != 0) {
taosMemoryFree(pTSBuf);
return NULL;
}
} }
if (NULL == allocResForTSBuf(pTSBuf)) { if (allocResForTSBuf(pTSBuf) == NULL) {
return NULL; return NULL;
} }
......
...@@ -1939,7 +1939,7 @@ int32_t fltInitValFieldData(SFilterInfo *info) { ...@@ -1939,7 +1939,7 @@ int32_t fltInitValFieldData(SFilterInfo *info) {
bytes = (len + 1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE; bytes = (len + 1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE;
fi->data = taosMemoryCalloc(1, bytes); fi->data = taosMemoryCalloc(1, bytes);
} else{ } else {
if (dType->type == TSDB_DATA_TYPE_VALUE_ARRAY) { //TIME RANGE if (dType->type == TSDB_DATA_TYPE_VALUE_ARRAY) { //TIME RANGE
/* /*
fi->data = taosMemoryCalloc(dType->bytes, tDataTypes[type].bytes); fi->data = taosMemoryCalloc(dType->bytes, tDataTypes[type].bytes);
......
...@@ -363,7 +363,11 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t ...@@ -363,7 +363,11 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
} }
SSDataBlock *block = *(SSDataBlock **)taosArrayGet(ctx->pBlockList, index); SSDataBlock *block = *(SSDataBlock **)taosArrayGet(ctx->pBlockList, index);
if (NULL == block || ref->slotId >= taosArrayGetSize(block->pDataBlock)) { if (NULL == block) {
SCL_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
}
if (ref->slotId >= taosArrayGetSize(block->pDataBlock)) {
sclError("column slotId is too big, slodId:%d, dataBlockSize:%d", ref->slotId, (int32_t)taosArrayGetSize(block->pDataBlock)); sclError("column slotId is too big, slodId:%d, dataBlockSize:%d", ref->slotId, (int32_t)taosArrayGetSize(block->pDataBlock));
SCL_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); SCL_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
} }
......
...@@ -2002,7 +2002,7 @@ int32_t avgScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam * ...@@ -2002,7 +2002,7 @@ int32_t avgScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *
} }
} }
if (hasNull) { if (hasNull || (count == 0)) {
colDataAppendNULL(pOutputData, 0); colDataAppendNULL(pOutputData, 0);
} else { } else {
if (IS_SIGNED_NUMERIC_TYPE(type)) { if (IS_SIGNED_NUMERIC_TYPE(type)) {
......
...@@ -281,7 +281,7 @@ static FORCE_INLINE void varToTimestamp(char *buf, SScalarParam* pOut, int32_t r ...@@ -281,7 +281,7 @@ static FORCE_INLINE void varToTimestamp(char *buf, SScalarParam* pOut, int32_t r
if (taosParseTime(buf, &value, strlen(buf), pOut->columnData->info.precision, tsDaylight) != TSDB_CODE_SUCCESS) { if (taosParseTime(buf, &value, strlen(buf), pOut->columnData->info.precision, tsDaylight) != TSDB_CODE_SUCCESS) {
value = 0; value = 0;
} }
colDataAppendInt64(pOut->columnData, rowIndex, &value); colDataAppendInt64(pOut->columnData, rowIndex, &value);
} }
...@@ -300,29 +300,29 @@ static FORCE_INLINE void varToSigned(char *buf, SScalarParam* pOut, int32_t rowI ...@@ -300,29 +300,29 @@ static FORCE_INLINE void varToSigned(char *buf, SScalarParam* pOut, int32_t rowI
*overflow = 0; *overflow = 0;
} }
} }
switch (pOut->columnData->info.type) { switch (pOut->columnData->info.type) {
case TSDB_DATA_TYPE_TINYINT: { case TSDB_DATA_TYPE_TINYINT: {
int8_t value = (int8_t)taosStr2Int8(buf, NULL, 10); int8_t value = (int8_t)taosStr2Int8(buf, NULL, 10);
colDataAppendInt8(pOut->columnData, rowIndex, (int8_t*)&value); colDataAppendInt8(pOut->columnData, rowIndex, (int8_t*)&value);
break; break;
} }
case TSDB_DATA_TYPE_SMALLINT: { case TSDB_DATA_TYPE_SMALLINT: {
int16_t value = (int16_t)taosStr2Int16(buf, NULL, 10); int16_t value = (int16_t)taosStr2Int16(buf, NULL, 10);
colDataAppendInt16(pOut->columnData, rowIndex, (int16_t*)&value); colDataAppendInt16(pOut->columnData, rowIndex, (int16_t*)&value);
break; break;
} }
case TSDB_DATA_TYPE_INT: { case TSDB_DATA_TYPE_INT: {
int32_t value = (int32_t)taosStr2Int32(buf, NULL, 10); int32_t value = (int32_t)taosStr2Int32(buf, NULL, 10);
colDataAppendInt32(pOut->columnData, rowIndex, (int32_t*)&value); colDataAppendInt32(pOut->columnData, rowIndex, (int32_t*)&value);
break; break;
} }
case TSDB_DATA_TYPE_BIGINT: { case TSDB_DATA_TYPE_BIGINT: {
int64_t value = (int64_t)taosStr2Int64(buf, NULL, 10); int64_t value = (int64_t)taosStr2Int64(buf, NULL, 10);
colDataAppendInt64(pOut->columnData, rowIndex, (int64_t*)&value); colDataAppendInt64(pOut->columnData, rowIndex, (int64_t*)&value);
break; break;
} }
} }
} }
...@@ -347,22 +347,22 @@ static FORCE_INLINE void varToUnsigned(char *buf, SScalarParam* pOut, int32_t ro ...@@ -347,22 +347,22 @@ static FORCE_INLINE void varToUnsigned(char *buf, SScalarParam* pOut, int32_t ro
uint8_t value = (uint8_t)taosStr2UInt8(buf, NULL, 10); uint8_t value = (uint8_t)taosStr2UInt8(buf, NULL, 10);
colDataAppendInt8(pOut->columnData, rowIndex, (int8_t*)&value); colDataAppendInt8(pOut->columnData, rowIndex, (int8_t*)&value);
break; break;
} }
case TSDB_DATA_TYPE_USMALLINT: { case TSDB_DATA_TYPE_USMALLINT: {
uint16_t value = (uint16_t)taosStr2UInt16(buf, NULL, 10); uint16_t value = (uint16_t)taosStr2UInt16(buf, NULL, 10);
colDataAppendInt16(pOut->columnData, rowIndex, (int16_t*)&value); colDataAppendInt16(pOut->columnData, rowIndex, (int16_t*)&value);
break; break;
} }
case TSDB_DATA_TYPE_UINT: { case TSDB_DATA_TYPE_UINT: {
uint32_t value = (uint32_t)taosStr2UInt32(buf, NULL, 10); uint32_t value = (uint32_t)taosStr2UInt32(buf, NULL, 10);
colDataAppendInt32(pOut->columnData, rowIndex, (int32_t*)&value); colDataAppendInt32(pOut->columnData, rowIndex, (int32_t*)&value);
break; break;
} }
case TSDB_DATA_TYPE_UBIGINT: { case TSDB_DATA_TYPE_UBIGINT: {
uint64_t value = (uint64_t)taosStr2UInt64(buf, NULL, 10); uint64_t value = (uint64_t)taosStr2UInt64(buf, NULL, 10);
colDataAppendInt64(pOut->columnData, rowIndex, (int64_t*)&value); colDataAppendInt64(pOut->columnData, rowIndex, (int64_t*)&value);
break; break;
} }
} }
} }
...@@ -372,7 +372,7 @@ static FORCE_INLINE void varToFloat(char *buf, SScalarParam* pOut, int32_t rowIn ...@@ -372,7 +372,7 @@ static FORCE_INLINE void varToFloat(char *buf, SScalarParam* pOut, int32_t rowIn
colDataAppendFloat(pOut->columnData, rowIndex, &value); colDataAppendFloat(pOut->columnData, rowIndex, &value);
return; return;
} }
double value = taosStr2Double(buf, NULL); double value = taosStr2Double(buf, NULL);
colDataAppendDouble(pOut->columnData, rowIndex, &value); colDataAppendDouble(pOut->columnData, rowIndex, &value);
} }
...@@ -488,11 +488,11 @@ int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, in ...@@ -488,11 +488,11 @@ int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, in
tmp[len] = 0; tmp[len] = 0;
} }
} }
(*func)(tmp, pOut, i, overflow); (*func)(tmp, pOut, i, overflow);
taosMemoryFreeClear(tmp); taosMemoryFreeClear(tmp);
} }
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -529,24 +529,24 @@ void* ncharTobinary(void *buf){ // todo need to remove , if tobinary ...@@ -529,24 +529,24 @@ void* ncharTobinary(void *buf){ // todo need to remove , if tobinary
bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t typeRight, char **pLeftData, char **pRightData, bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t typeRight, char **pLeftData, char **pRightData,
void *pLeftOut, void *pRightOut, bool *isNull, bool *freeLeft, bool *freeRight){ void *pLeftOut, void *pRightOut, bool *isNull, bool *freeLeft, bool *freeRight){
if(optr == OP_TYPE_JSON_CONTAINS) { if (optr == OP_TYPE_JSON_CONTAINS) {
return true; return true;
} }
if(typeLeft != TSDB_DATA_TYPE_JSON && typeRight != TSDB_DATA_TYPE_JSON){ if (typeLeft != TSDB_DATA_TYPE_JSON && typeRight != TSDB_DATA_TYPE_JSON) {
return true; return true;
} }
if(typeLeft == TSDB_DATA_TYPE_JSON){ if (typeLeft == TSDB_DATA_TYPE_JSON) {
if(tTagIsJson(*pLeftData)){ if (tTagIsJson(*pLeftData)) {
terrno = TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR; terrno = TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR;
return false; return false;
} }
typeLeft = **pLeftData; typeLeft = **pLeftData;
(*pLeftData) ++; (*pLeftData) ++;
} }
if(typeRight == TSDB_DATA_TYPE_JSON){ if (typeRight == TSDB_DATA_TYPE_JSON) {
if(tTagIsJson(*pLeftData)){ if (tTagIsJson(*pLeftData)) {
terrno = TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR; terrno = TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR;
return false; return false;
} }
...@@ -554,71 +554,71 @@ bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t t ...@@ -554,71 +554,71 @@ bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t t
(*pRightData) ++; (*pRightData) ++;
} }
if(optr == OP_TYPE_LIKE || optr == OP_TYPE_NOT_LIKE || optr == OP_TYPE_MATCH || optr == OP_TYPE_NMATCH){ if (optr == OP_TYPE_LIKE || optr == OP_TYPE_NOT_LIKE || optr == OP_TYPE_MATCH || optr == OP_TYPE_NMATCH) {
if(typeLeft != TSDB_DATA_TYPE_NCHAR && typeLeft != TSDB_DATA_TYPE_BINARY){ if (typeLeft != TSDB_DATA_TYPE_NCHAR && typeLeft != TSDB_DATA_TYPE_BINARY) {
return false; return false;
} }
} }
// if types can not comparable // if types can not comparable
if((IS_NUMERIC_TYPE(typeLeft) && !IS_NUMERIC_TYPE(typeRight)) || if ((IS_NUMERIC_TYPE(typeLeft) && !IS_NUMERIC_TYPE(typeRight)) ||
(IS_NUMERIC_TYPE(typeRight) && !IS_NUMERIC_TYPE(typeLeft)) || (IS_NUMERIC_TYPE(typeRight) && !IS_NUMERIC_TYPE(typeLeft)) ||
(IS_VAR_DATA_TYPE(typeLeft) && !IS_VAR_DATA_TYPE(typeRight)) || (IS_VAR_DATA_TYPE(typeLeft) && !IS_VAR_DATA_TYPE(typeRight)) ||
(IS_VAR_DATA_TYPE(typeRight) && !IS_VAR_DATA_TYPE(typeLeft)) || (IS_VAR_DATA_TYPE(typeRight) && !IS_VAR_DATA_TYPE(typeLeft)) ||
((typeLeft == TSDB_DATA_TYPE_BOOL) && (typeRight != TSDB_DATA_TYPE_BOOL)) || ((typeLeft == TSDB_DATA_TYPE_BOOL) && (typeRight != TSDB_DATA_TYPE_BOOL)) ||
((typeRight == TSDB_DATA_TYPE_BOOL) && (typeLeft != TSDB_DATA_TYPE_BOOL))) ((typeRight == TSDB_DATA_TYPE_BOOL) && (typeLeft != TSDB_DATA_TYPE_BOOL)))
return false; return false;
if(typeLeft == TSDB_DATA_TYPE_NULL || typeRight == TSDB_DATA_TYPE_NULL){ if (typeLeft == TSDB_DATA_TYPE_NULL || typeRight == TSDB_DATA_TYPE_NULL) {
*isNull = true; *isNull = true;
return true; return true;
} }
int8_t type = vectorGetConvertType(typeLeft, typeRight); int8_t type = vectorGetConvertType(typeLeft, typeRight);
if(type == 0) { if (type == 0) {
*fp = filterGetCompFunc(typeLeft, optr); *fp = filterGetCompFunc(typeLeft, optr);
return true; return true;
} }
*fp = filterGetCompFunc(type, optr); *fp = filterGetCompFunc(type, optr);
if(IS_NUMERIC_TYPE(type)){ if (IS_NUMERIC_TYPE(type)) {
if(typeLeft == TSDB_DATA_TYPE_NCHAR) { if (typeLeft == TSDB_DATA_TYPE_NCHAR) {
ASSERT(0); ASSERT(0);
// convertNcharToDouble(*pLeftData, pLeftOut); // convertNcharToDouble(*pLeftData, pLeftOut);
// *pLeftData = pLeftOut; // *pLeftData = pLeftOut;
} else if(typeLeft == TSDB_DATA_TYPE_BINARY) { } else if (typeLeft == TSDB_DATA_TYPE_BINARY) {
ASSERT(0); ASSERT(0);
// convertBinaryToDouble(*pLeftData, pLeftOut); // convertBinaryToDouble(*pLeftData, pLeftOut);
// *pLeftData = pLeftOut; // *pLeftData = pLeftOut;
} else if(typeLeft != type) { } else if (typeLeft != type) {
convertNumberToNumber(*pLeftData, pLeftOut, typeLeft, type); convertNumberToNumber(*pLeftData, pLeftOut, typeLeft, type);
*pLeftData = pLeftOut; *pLeftData = pLeftOut;
} }
if(typeRight == TSDB_DATA_TYPE_NCHAR) { if (typeRight == TSDB_DATA_TYPE_NCHAR) {
ASSERT(0); ASSERT(0);
// convertNcharToDouble(*pRightData, pRightOut); // convertNcharToDouble(*pRightData, pRightOut);
// *pRightData = pRightOut; // *pRightData = pRightOut;
} else if(typeRight == TSDB_DATA_TYPE_BINARY) { } else if (typeRight == TSDB_DATA_TYPE_BINARY) {
ASSERT(0); ASSERT(0);
// convertBinaryToDouble(*pRightData, pRightOut); // convertBinaryToDouble(*pRightData, pRightOut);
// *pRightData = pRightOut; // *pRightData = pRightOut;
} else if(typeRight != type) { } else if (typeRight != type) {
convertNumberToNumber(*pRightData, pRightOut, typeRight, type); convertNumberToNumber(*pRightData, pRightOut, typeRight, type);
*pRightData = pRightOut; *pRightData = pRightOut;
} }
}else if(type == TSDB_DATA_TYPE_BINARY){ } else if (type == TSDB_DATA_TYPE_BINARY) {
if(typeLeft == TSDB_DATA_TYPE_NCHAR){ if (typeLeft == TSDB_DATA_TYPE_NCHAR) {
*pLeftData = ncharTobinary(*pLeftData); *pLeftData = ncharTobinary(*pLeftData);
*freeLeft = true; *freeLeft = true;
} }
if(typeRight == TSDB_DATA_TYPE_NCHAR){ if (typeRight == TSDB_DATA_TYPE_NCHAR) {
*pRightData = ncharTobinary(*pRightData); *pRightData = ncharTobinary(*pRightData);
*freeRight = true; *freeRight = true;
} }
}else{ } else {
ASSERT(0); ASSERT(0);
} }
...@@ -636,7 +636,7 @@ int32_t vectorConvertToVarData(const SScalarParam* pIn, SScalarParam* pOut, int1 ...@@ -636,7 +636,7 @@ int32_t vectorConvertToVarData(const SScalarParam* pIn, SScalarParam* pOut, int1
colDataAppendNULL(pOutputCol, i); colDataAppendNULL(pOutputCol, i);
continue; continue;
} }
int64_t value = 0; int64_t value = 0;
GET_TYPED_DATA(value, int64_t, inType, colDataGetData(pInputCol, i)); GET_TYPED_DATA(value, int64_t, inType, colDataGetData(pInputCol, i));
int32_t len = sprintf(varDataVal(tmp), "%" PRId64, value); int32_t len = sprintf(varDataVal(tmp), "%" PRId64, value);
...@@ -653,7 +653,7 @@ int32_t vectorConvertToVarData(const SScalarParam* pIn, SScalarParam* pOut, int1 ...@@ -653,7 +653,7 @@ int32_t vectorConvertToVarData(const SScalarParam* pIn, SScalarParam* pOut, int1
colDataAppendNULL(pOutputCol, i); colDataAppendNULL(pOutputCol, i);
continue; continue;
} }
uint64_t value = 0; uint64_t value = 0;
GET_TYPED_DATA(value, uint64_t, inType, colDataGetData(pInputCol, i)); GET_TYPED_DATA(value, uint64_t, inType, colDataGetData(pInputCol, i));
int32_t len = sprintf(varDataVal(tmp), "%" PRIu64, value); int32_t len = sprintf(varDataVal(tmp), "%" PRIu64, value);
...@@ -670,7 +670,7 @@ int32_t vectorConvertToVarData(const SScalarParam* pIn, SScalarParam* pOut, int1 ...@@ -670,7 +670,7 @@ int32_t vectorConvertToVarData(const SScalarParam* pIn, SScalarParam* pOut, int1
colDataAppendNULL(pOutputCol, i); colDataAppendNULL(pOutputCol, i);
continue; continue;
} }
double value = 0; double value = 0;
GET_TYPED_DATA(value, double, inType, colDataGetData(pInputCol, i)); GET_TYPED_DATA(value, double, inType, colDataGetData(pInputCol, i));
int32_t len = sprintf(varDataVal(tmp), "%lf", value); int32_t len = sprintf(varDataVal(tmp), "%lf", value);
...@@ -698,7 +698,7 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t* ...@@ -698,7 +698,7 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t*
sclError("input column is NULL, hashFilter %p", pIn->pHashFilter); sclError("input column is NULL, hashFilter %p", pIn->pHashFilter);
return TSDB_CODE_APP_ERROR; return TSDB_CODE_APP_ERROR;
} }
int16_t inType = pInputCol->info.type; int16_t inType = pInputCol->info.type;
int16_t outType = pOutputCol->info.type; int16_t outType = pOutputCol->info.type;
...@@ -710,14 +710,14 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t* ...@@ -710,14 +710,14 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t*
ASSERT(1 == pIn->numOfRows); ASSERT(1 == pIn->numOfRows);
pOut->numOfRows = 0; pOut->numOfRows = 0;
if (IS_SIGNED_NUMERIC_TYPE(outType)) { if (IS_SIGNED_NUMERIC_TYPE(outType)) {
int64_t minValue = tDataTypes[outType].minValue; int64_t minValue = tDataTypes[outType].minValue;
int64_t maxValue = tDataTypes[outType].maxValue; int64_t maxValue = tDataTypes[outType].maxValue;
double value = 0; double value = 0;
GET_TYPED_DATA(value, double, inType, colDataGetData(pInputCol, 0)); GET_TYPED_DATA(value, double, inType, colDataGetData(pInputCol, 0));
if (value > maxValue) { if (value > maxValue) {
*overflow = 1; *overflow = 1;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
...@@ -730,10 +730,10 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t* ...@@ -730,10 +730,10 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t*
} else if (IS_UNSIGNED_NUMERIC_TYPE(outType)) { } else if (IS_UNSIGNED_NUMERIC_TYPE(outType)) {
uint64_t minValue = (uint64_t)tDataTypes[outType].minValue; uint64_t minValue = (uint64_t)tDataTypes[outType].minValue;
uint64_t maxValue = (uint64_t)tDataTypes[outType].maxValue; uint64_t maxValue = (uint64_t)tDataTypes[outType].maxValue;
double value = 0; double value = 0;
GET_TYPED_DATA(value, double, inType, colDataGetData(pInputCol, 0)); GET_TYPED_DATA(value, double, inType, colDataGetData(pInputCol, 0));
if (value > maxValue) { if (value > maxValue) {
*overflow = 1; *overflow = 1;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
...@@ -820,7 +820,7 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t* ...@@ -820,7 +820,7 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t*
colDataAppendNULL(pOutputCol, i); colDataAppendNULL(pOutputCol, i);
continue; continue;
} }
uint8_t value = 0; uint8_t value = 0;
GET_TYPED_DATA(value, uint8_t, inType, colDataGetData(pInputCol, i)); GET_TYPED_DATA(value, uint8_t, inType, colDataGetData(pInputCol, i));
colDataAppendInt8(pOutputCol, i, (int8_t *)&value); colDataAppendInt8(pOutputCol, i, (int8_t *)&value);
...@@ -833,7 +833,7 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t* ...@@ -833,7 +833,7 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t*
colDataAppendNULL(pOutputCol, i); colDataAppendNULL(pOutputCol, i);
continue; continue;
} }
uint16_t value = 0; uint16_t value = 0;
GET_TYPED_DATA(value, uint16_t, inType, colDataGetData(pInputCol, i)); GET_TYPED_DATA(value, uint16_t, inType, colDataGetData(pInputCol, i));
colDataAppendInt16(pOutputCol, i, (int16_t *)&value); colDataAppendInt16(pOutputCol, i, (int16_t *)&value);
...@@ -846,7 +846,7 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t* ...@@ -846,7 +846,7 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t*
colDataAppendNULL(pOutputCol, i); colDataAppendNULL(pOutputCol, i);
continue; continue;
} }
uint32_t value = 0; uint32_t value = 0;
GET_TYPED_DATA(value, uint32_t, inType, colDataGetData(pInputCol, i)); GET_TYPED_DATA(value, uint32_t, inType, colDataGetData(pInputCol, i));
colDataAppendInt32(pOutputCol, i, (int32_t *)&value); colDataAppendInt32(pOutputCol, i, (int32_t *)&value);
...@@ -859,7 +859,7 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t* ...@@ -859,7 +859,7 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t*
colDataAppendNULL(pOutputCol, i); colDataAppendNULL(pOutputCol, i);
continue; continue;
} }
uint64_t value = 0; uint64_t value = 0;
GET_TYPED_DATA(value, uint64_t, inType, colDataGetData(pInputCol, i)); GET_TYPED_DATA(value, uint64_t, inType, colDataGetData(pInputCol, i));
colDataAppendInt64(pOutputCol, i, (int64_t*)&value); colDataAppendInt64(pOutputCol, i, (int64_t*)&value);
...@@ -872,12 +872,12 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t* ...@@ -872,12 +872,12 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t*
colDataAppendNULL(pOutputCol, i); colDataAppendNULL(pOutputCol, i);
continue; continue;
} }
float value = 0; float value = 0;
GET_TYPED_DATA(value, float, inType, colDataGetData(pInputCol, i)); GET_TYPED_DATA(value, float, inType, colDataGetData(pInputCol, i));
colDataAppendFloat(pOutputCol, i, (float*)&value); colDataAppendFloat(pOutputCol, i, (float*)&value);
} }
break; break;
} }
case TSDB_DATA_TYPE_DOUBLE: { case TSDB_DATA_TYPE_DOUBLE: {
for (int32_t i = 0; i < pIn->numOfRows; ++i) { for (int32_t i = 0; i < pIn->numOfRows; ++i) {
...@@ -885,14 +885,14 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t* ...@@ -885,14 +885,14 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t*
colDataAppendNULL(pOutputCol, i); colDataAppendNULL(pOutputCol, i);
continue; continue;
} }
double value = 0; double value = 0;
GET_TYPED_DATA(value, double, inType, colDataGetData(pInputCol, i)); GET_TYPED_DATA(value, double, inType, colDataGetData(pInputCol, i));
colDataAppendDouble(pOutputCol, i, (double*)&value); colDataAppendDouble(pOutputCol, i, (double*)&value);
} }
break; break;
} }
case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_BINARY:
case TSDB_DATA_TYPE_NCHAR: { case TSDB_DATA_TYPE_NCHAR: {
return vectorConvertToVarData(pIn, pOut, inType, outType); return vectorConvertToVarData(pIn, pOut, inType, outType);
} }
...@@ -966,10 +966,10 @@ int32_t vectorConvert(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam* p ...@@ -966,10 +966,10 @@ int32_t vectorConvert(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam* p
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
SScalarParam *param1 = NULL, *paramOut1 = NULL; SScalarParam *param1 = NULL, *paramOut1 = NULL;
SScalarParam *param2 = NULL, *paramOut2 = NULL; SScalarParam *param2 = NULL, *paramOut2 = NULL;
int32_t code = 0; int32_t code = 0;
if (leftType < rightType) { if (leftType < rightType) {
param1 = pLeft; param1 = pLeft;
param2 = pRight; param2 = pRight;
...@@ -993,7 +993,7 @@ int32_t vectorConvert(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam* p ...@@ -993,7 +993,7 @@ int32_t vectorConvert(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam* p
return code; return code;
} }
} }
if (type != GET_PARAM_TYPE(param2)) { if (type != GET_PARAM_TYPE(param2)) {
code = vectorConvertScalarParam(param2, paramOut2, type); code = vectorConvertScalarParam(param2, paramOut2, type);
if (code) { if (code) {
...@@ -1136,7 +1136,7 @@ void vectorMathAdd(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut ...@@ -1136,7 +1136,7 @@ void vectorMathAdd(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut
} }
*output = getVectorBigintValueFnLeft(pLeftCol->pData, i) + getVectorBigintValueFnRight(pRightCol->pData, i); *output = getVectorBigintValueFnLeft(pLeftCol->pData, i) + getVectorBigintValueFnRight(pRightCol->pData, i);
} }
} }
} else { } else {
double *output = (double *)pOutputCol->pData; double *output = (double *)pOutputCol->pData;
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type);
...@@ -1198,7 +1198,7 @@ static void vectorMathTsSubHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pR ...@@ -1198,7 +1198,7 @@ static void vectorMathTsSubHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pR
} }
*output = taosTimeAdd(getVectorBigintValueFnLeft(pLeftCol->pData, i), -getVectorBigintValueFnRight(pRightCol->pData, 0), *output = taosTimeAdd(getVectorBigintValueFnLeft(pLeftCol->pData, i), -getVectorBigintValueFnRight(pRightCol->pData, 0),
pRightCol->info.scale, pRightCol->info.precision); pRightCol->info.scale, pRightCol->info.precision);
} }
} }
} }
...@@ -1706,7 +1706,7 @@ void vectorCompareImpl(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam * ...@@ -1706,7 +1706,7 @@ void vectorCompareImpl(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *
int32_t lType = GET_PARAM_TYPE(pLeft); int32_t lType = GET_PARAM_TYPE(pLeft);
int32_t rType = GET_PARAM_TYPE(pRight); int32_t rType = GET_PARAM_TYPE(pRight);
__compar_fn_t fp = NULL; __compar_fn_t fp = NULL;
if (lType == rType) { if (lType == rType) {
fp = filterGetCompFunc(lType, optr); fp = filterGetCompFunc(lType, optr);
} else { } else {
...@@ -1736,9 +1736,9 @@ void vectorCompareImpl(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam * ...@@ -1736,9 +1736,9 @@ void vectorCompareImpl(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *
} }
void vectorCompare(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord, int32_t optr) { void vectorCompare(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord, int32_t optr) {
SScalarParam pLeftOut = {0}; SScalarParam pLeftOut = {0};
SScalarParam pRightOut = {0}; SScalarParam pRightOut = {0};
SScalarParam *param1 = NULL; SScalarParam *param1 = NULL;
SScalarParam *param2 = NULL; SScalarParam *param2 = NULL;
if (SCL_NO_NEED_CONVERT_COMPARISION(GET_PARAM_TYPE(pLeft), GET_PARAM_TYPE(pRight), optr)) { if (SCL_NO_NEED_CONVERT_COMPARISION(GET_PARAM_TYPE(pLeft), GET_PARAM_TYPE(pRight), optr)) {
...@@ -1762,7 +1762,7 @@ void vectorCompare(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut ...@@ -1762,7 +1762,7 @@ void vectorCompare(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut
vectorCompareImpl(param1, param2, pOut, _ord, optr); vectorCompareImpl(param1, param2, pOut, _ord, optr);
sclFreeParam(&pLeftOut); sclFreeParam(&pLeftOut);
sclFreeParam(&pRightOut); sclFreeParam(&pRightOut);
} }
void vectorGreater(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { void vectorGreater(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册