diff --git a/src/common/inc/texpr.h b/src/common/inc/texpr.h index 3ce519c140a2e13c48f3d0eb2f8140d979241b62..03b181aa8b6e36af43d56a2f969fe216f744ec29 100644 --- a/src/common/inc/texpr.h +++ b/src/common/inc/texpr.h @@ -83,10 +83,10 @@ struct SSchema; #define TSDB_FUNC_SCALAR_NAME_MAX_LEN 16 typedef struct { - int16_t type; - int16_t bytes; - int32_t numOfRows; - char* data; + int16_t type; + uint16_t bytes; + int32_t numOfRows; + char *data; } tExprOperandInfo; typedef void (*_expr_scalar_function_t)(int16_t functionId, tExprOperandInfo* pInputs, int32_t numInputs, tExprOperandInfo* pOutput, int32_t order); @@ -149,9 +149,9 @@ typedef struct tExprNode { TAOS_FIELD *pType; }; - int16_t resultType; - int16_t resultBytes; - int32_t precision; + int16_t resultType; + uint16_t resultBytes; + int32_t precision; } tExprNode; typedef struct SExprTraverseSupp { diff --git a/src/common/inc/tname.h b/src/common/inc/tname.h index ba9705b9be54b3102a4957db310dcc4579a7dcde..ef98b607d88d29ff03e6a673e82fe037e7b6e082 100644 --- a/src/common/inc/tname.h +++ b/src/common/inc/tname.h @@ -55,7 +55,8 @@ typedef struct SSqlExpr { int32_t interBytes; // inter result buffer size int16_t colType; // table column type - int16_t colBytes; // table column bytes,it should be int32_t, because it is too small for globale merge stage, pQueryAttr->interBytesForGlobal + uint16_t colBytes; // table column bytes,it should be int32_t, because it is too small for globale merge stage, + // pQueryAttr->interBytesForGlobal int16_t numOfParams; // argument value of each function tVariant param[3]; // parameters are not more than 3 diff --git a/src/common/src/texpr.c b/src/common/src/texpr.c index 1acfd3c4f9b87041abb888b878306743230e17e2..72b303bb14f8302ced115fa03af1367834846154 100644 --- a/src/common/src/texpr.c +++ b/src/common/src/texpr.c @@ -891,7 +891,7 @@ static void exprTreeToBinaryImpl(SBufferWriter* bw, tExprNode* expr) { } else if (expr->nodeType == TSQL_NODE_COL) { SSchema* pSchema = expr->pSchema; tbufWriteInt16(bw, pSchema->colId); - tbufWriteInt16(bw, pSchema->bytes); + tbufWriteUint16(bw, pSchema->bytes); tbufWriteUint8(bw, pSchema->type); tbufWriteString(bw, pSchema->name); @@ -908,7 +908,7 @@ static void exprTreeToBinaryImpl(SBufferWriter* bw, tExprNode* expr) { } } tbufWriteInt16(bw, expr->resultType); - tbufWriteInt16(bw, expr->resultBytes); + tbufWriteUint16(bw, expr->resultBytes); } void exprTreeToBinary(SBufferWriter* bw, tExprNode* expr) { @@ -963,7 +963,7 @@ static tExprNode* exprTreeFromBinaryImpl(SBufferReader* br) { pExpr->pSchema = pSchema; pSchema->colId = tbufReadInt16(br); - pSchema->bytes = tbufReadInt16(br); + pSchema->bytes = tbufReadUint16(br); pSchema->type = tbufReadUint8(br); tbufReadToString(br, pSchema->name, TSDB_COL_NAME_LEN); @@ -982,7 +982,7 @@ static tExprNode* exprTreeFromBinaryImpl(SBufferReader* br) { } } pExpr->resultType = tbufReadInt16(br); - pExpr->resultBytes = tbufReadInt16(br); + pExpr->resultBytes = tbufReadUint16(br); CLEANUP_EXECUTE_TO(anchor, false); return pExpr; } @@ -1288,10 +1288,10 @@ int32_t exprValidateStringConcatNode(tExprNode *pExpr) { } char* payload = malloc((child->pVal->nLen+1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE); tVariantDump(child->pVal, payload, resultType, true); - int16_t resultBytes = varDataTLen(payload); + uint16_t resultBytes = varDataTLen(payload); free(payload); child->resultType = resultType; - child->resultBytes = (int16_t)(resultBytes); + child->resultBytes = resultBytes; } } } else { @@ -1308,7 +1308,7 @@ int32_t exprValidateStringConcatNode(tExprNode *pExpr) { } pExpr->resultType = resultType; - int16_t resultBytes = 0; + uint16_t resultBytes = 0; for (int32_t i = 0; i < pExpr->_func.numChildren; ++i) { tExprNode *child = pExpr->_func.pChildren[i]; if (resultBytes <= resultBytes + child->resultBytes - VARSTR_HEADER_SIZE) { @@ -1360,10 +1360,10 @@ int32_t exprValidateStringConcatWsNode(tExprNode *pExpr) { } char* payload = malloc((child->pVal->nLen+1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE); tVariantDump(child->pVal, payload, resultType, true); - int16_t resultBytes = varDataTLen(payload); + uint16_t resultBytes = varDataTLen(payload); free(payload); child->resultType = resultType; - child->resultBytes = (int16_t)(resultBytes); + child->resultBytes = resultBytes; } } } else { @@ -1380,7 +1380,7 @@ int32_t exprValidateStringConcatWsNode(tExprNode *pExpr) { } pExpr->resultType = resultType; - int16_t resultBytes = 0; + uint16_t resultBytes = 0; for (int32_t i = 1; i < pExpr->_func.numChildren; ++i) { tExprNode *child = pExpr->_func.pChildren[i]; if (resultBytes <= resultBytes + child->resultBytes - VARSTR_HEADER_SIZE) { @@ -1390,7 +1390,7 @@ int32_t exprValidateStringConcatWsNode(tExprNode *pExpr) { } } tExprNode* wsNode = pExpr->_func.pChildren[0]; - int16_t wsResultBytes = wsNode->resultBytes - VARSTR_HEADER_SIZE; + uint16_t wsResultBytes = wsNode->resultBytes - VARSTR_HEADER_SIZE; resultBytes += wsResultBytes * (pExpr->_func.numChildren - 2); pExpr->resultBytes = resultBytes + VARSTR_HEADER_SIZE; return TSDB_CODE_SUCCESS; @@ -1406,7 +1406,7 @@ int32_t exprValidateStringLengthNode(tExprNode *pExpr) { if (child1->nodeType == TSQL_NODE_VALUE) { child1->resultType = (int16_t)child1->pVal->nType; - child1->resultBytes = (int16_t)(child1->pVal->nLen + VARSTR_HEADER_SIZE); + child1->resultBytes = (uint16_t)(child1->pVal->nLen + VARSTR_HEADER_SIZE); } if (!IS_VAR_DATA_TYPE(child1->resultType)) { @@ -1428,7 +1428,7 @@ int32_t exprValidateStringLowerUpperTrimNode(char* msgBuf, tExprNode *pExpr) { if (child1->nodeType == TSQL_NODE_VALUE) { child1->resultType = (int16_t)child1->pVal->nType; - child1->resultBytes = (int16_t)(child1->pVal->nLen + VARSTR_HEADER_SIZE); + child1->resultBytes = (uint16_t)(child1->pVal->nLen + VARSTR_HEADER_SIZE); } if (!IS_VAR_DATA_TYPE(child1->resultType)) { @@ -1450,7 +1450,7 @@ int32_t exprValidateStringSubstrNode(char* msgBuf, tExprNode *pExpr) { if (child1->nodeType == TSQL_NODE_VALUE) { child1->resultType = (int16_t)child1->pVal->nType; - child1->resultBytes = (int16_t)(child1->pVal->nLen + VARSTR_HEADER_SIZE); + child1->resultBytes = (uint16_t)(child1->pVal->nLen + VARSTR_HEADER_SIZE); } if (!IS_VAR_DATA_TYPE(child1->resultType)) { @@ -1629,7 +1629,7 @@ int32_t exprValidateTimeNode(char *msgbuf, tExprNode *pExpr) { } child->nodeType = TSQL_NODE_VALUE; child->resultType = TSDB_DATA_TYPE_TIMESTAMP; - child->resultBytes = (int16_t)tDataTypes[child->resultType].bytes; + child->resultBytes = (uint16_t)tDataTypes[child->resultType].bytes; child->pVal = (tVariant *)tcalloc(1, sizeof(tVariant)); if (!child->pVal) { @@ -1662,7 +1662,7 @@ int32_t exprValidateTimeNode(char *msgbuf, tExprNode *pExpr) { child->pVal->i64 = convertTimePrecision(timeVal, TSDB_TIME_PRECISION_MILLI, pExpr->precision); } pExpr->resultType = TSDB_DATA_TYPE_TIMESTAMP; - pExpr->resultBytes = (int16_t)tDataTypes[pExpr->resultType].bytes; + pExpr->resultBytes = (uint16_t)tDataTypes[pExpr->resultType].bytes; break; } case TSDB_FUNC_SCALAR_TIMEZONE: { @@ -1769,7 +1769,7 @@ int32_t exprValidateTimeNode(char *msgbuf, tExprNode *pExpr) { child1->pVal->i64 = (int64_t)pExpr->precision; pExpr->resultType = TSDB_DATA_TYPE_BIGINT; - pExpr->resultBytes = (int16_t)tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes; + pExpr->resultBytes = (uint16_t)tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes; break; } case TSDB_FUNC_SCALAR_TIMETRUNCATE: { @@ -1835,7 +1835,7 @@ int32_t exprValidateTimeNode(char *msgbuf, tExprNode *pExpr) { } child2->nodeType = TSQL_NODE_VALUE; child2->resultType = TSDB_DATA_TYPE_BIGINT; - child2->resultBytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes; + child2->resultBytes = (uint16_t)tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes; child2->pVal = (tVariant *)tcalloc(1, sizeof(tVariant)); if (!child2->pVal) { @@ -1846,7 +1846,7 @@ int32_t exprValidateTimeNode(char *msgbuf, tExprNode *pExpr) { child2->pVal->i64 = (int64_t)pExpr->precision; pExpr->resultType = TSDB_DATA_TYPE_TIMESTAMP; - pExpr->resultBytes = (int16_t)tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes; + pExpr->resultBytes = (uint16_t)tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes; break; } case TSDB_FUNC_SCALAR_TIMEDIFF: { @@ -1924,7 +1924,7 @@ int32_t exprValidateTimeNode(char *msgbuf, tExprNode *pExpr) { } childPrec->nodeType = TSQL_NODE_VALUE; childPrec->resultType = TSDB_DATA_TYPE_BIGINT; - childPrec->resultBytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes; + childPrec->resultBytes = (uint16_t)tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes; childPrec->pVal = (tVariant *)tcalloc(1, sizeof(tVariant)); if (!childPrec->pVal) { @@ -1937,7 +1937,7 @@ int32_t exprValidateTimeNode(char *msgbuf, tExprNode *pExpr) { free(child); pExpr->resultType = TSDB_DATA_TYPE_BIGINT; - pExpr->resultBytes = (int16_t)tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes; + pExpr->resultBytes = (uint16_t)tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes; break; } default: {