diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index 35d3184ccb898e8b11533909df254e0b373ea029..f1b620176d53f24ede3d7a39214a809f54b3fe80 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -84,7 +84,7 @@ typedef struct SSqlExpr { int16_t functionId; // function id in aAgg array int16_t resType; // return value type int16_t resBytes; // length of return value - int16_t interBytes; // inter result buffer size + int32_t interBytes; // inter result buffer size int16_t numOfParams; // argument value of each function tVariant param[3]; // parameters are not more than 3 int32_t offset; // sub result column value of arithmetic expression. diff --git a/src/client/src/tscFunctionImpl.c b/src/client/src/tscFunctionImpl.c index 683da0822c23e975caaf9c94d1152e5c031aaa4d..baefdbe102c074224ba90801cd3ee16a70d64df3 100644 --- a/src/client/src/tscFunctionImpl.c +++ b/src/client/src/tscFunctionImpl.c @@ -153,7 +153,7 @@ typedef struct SRateInfo { int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionId, int32_t param, int16_t *type, - int16_t *bytes, int16_t *interBytes, int16_t extLength, bool isSuperTable) { + int16_t *bytes, int32_t *interBytes, int16_t extLength, bool isSuperTable) { if (!isValidDataType(dataType, dataBytes)) { tscError("Illegal data type %d or data type length %d", dataType, dataBytes); return TSDB_CODE_INVALID_SQL; diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index c24c97e286f34bc3e2dbb1838ac8eaa7116bfe08..965e85efbd3587838f10a7900f0153b9b06fcf45 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -1594,7 +1594,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr int16_t resultType = 0; int16_t resultSize = 0; - int16_t intermediateResSize = 0; + int32_t intermediateResSize = 0; int16_t functionID = 0; if (changeFunctionID(optr, &functionID) != TSDB_CODE_SUCCESS) { @@ -1901,7 +1901,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr int16_t bytes = 0; int16_t type = 0; - int16_t inter = 0; + int32_t inter = 0; int32_t ret = getResultDataInfo(s.type, s.bytes, TSDB_FUNC_TID_TAG, 0, &type, &bytes, &inter, 0, 0); assert(ret == TSDB_CODE_SUCCESS); @@ -2287,7 +2287,7 @@ int32_t tscTansformSQLFuncForSTableQuery(SQueryInfo* pQueryInfo) { int16_t bytes = 0; int16_t type = 0; - int16_t intermediateBytes = 0; + int32_t interBytes = 0; size_t size = tscSqlExprNumOfExprs(pQueryInfo); for (int32_t k = 0; k < size; ++k) { @@ -2301,13 +2301,13 @@ int32_t tscTansformSQLFuncForSTableQuery(SQueryInfo* pQueryInfo) { (functionId >= TSDB_FUNC_FIRST_DST && functionId <= TSDB_FUNC_LAST_DST) || (functionId >= TSDB_FUNC_RATE && functionId <= TSDB_FUNC_AVG_IRATE)) { if (getResultDataInfo(pSrcSchema->type, pSrcSchema->bytes, functionId, pExpr->param[0].i64Key, &type, &bytes, - &intermediateBytes, 0, true) != TSDB_CODE_SUCCESS) { + &interBytes, 0, true) != TSDB_CODE_SUCCESS) { return TSDB_CODE_INVALID_SQL; } tscSqlExprUpdate(pQueryInfo, k, functionId, pExpr->colInfo.colIndex, TSDB_DATA_TYPE_BINARY, bytes); // todo refactor - pExpr->interBytes = intermediateBytes; + pExpr->interBytes = interBytes; } } @@ -2327,27 +2327,23 @@ void tscRestoreSQLFuncForSTableQuery(SQueryInfo* pQueryInfo) { SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i); SSchema* pSchema = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, pExpr->colInfo.colIndex); -// if (/*(pExpr->functionId >= TSDB_FUNC_FIRST_DST && pExpr->functionId <= TSDB_FUNC_LAST_DST) || -// (pExpr->functionId >= TSDB_FUNC_SUM && pExpr->functionId <= TSDB_FUNC_MAX) || -// pExpr->functionId == TSDB_FUNC_LAST_ROW*/) { - // the final result size and type in the same as query on single table. - // so here, set the flag to be false; - int16_t inter = 0; - - int32_t functionId = pExpr->functionId; - if (functionId >= TSDB_FUNC_TS && functionId <= TSDB_FUNC_DIFF) { - continue; - } - - if (functionId == TSDB_FUNC_FIRST_DST) { - functionId = TSDB_FUNC_FIRST; - } else if (functionId == TSDB_FUNC_LAST_DST) { - functionId = TSDB_FUNC_LAST; - } - - getResultDataInfo(pSchema->type, pSchema->bytes, functionId, 0, &pExpr->resType, &pExpr->resBytes, - &inter, 0, false); -// } + // the final result size and type in the same as query on single table. + // so here, set the flag to be false; + int32_t inter = 0; + + int32_t functionId = pExpr->functionId; + if (functionId >= TSDB_FUNC_TS && functionId <= TSDB_FUNC_DIFF) { + continue; + } + + if (functionId == TSDB_FUNC_FIRST_DST) { + functionId = TSDB_FUNC_FIRST; + } else if (functionId == TSDB_FUNC_LAST_DST) { + functionId = TSDB_FUNC_LAST; + } + + getResultDataInfo(pSchema->type, pSchema->bytes, functionId, 0, &pExpr->resType, &pExpr->resBytes, + &inter, 0, false); } } diff --git a/src/client/src/tscSecondaryMerge.c b/src/client/src/tscSecondaryMerge.c index 219819a2b0a28201fe9f28d979a57131f34e667a..57375648770d6083fedf01343de9c5d6fd9acc49 100644 --- a/src/client/src/tscSecondaryMerge.c +++ b/src/client/src/tscSecondaryMerge.c @@ -689,7 +689,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr SSchema *p1 = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, pExpr->colInfo.colIndex); - int16_t inter = 0; + int32_t inter = 0; int16_t type = -1; int16_t bytes = 0; diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 4e34c1028b001d4e4a04a3e05e9ec79ae5a2d2e1..99163ba3270329e6e0bc06963d51c247e689fdf9 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -1084,7 +1084,7 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter int16_t bytes = 0; int16_t type = 0; - int16_t inter = 0; + int32_t inter = 0; getResultDataInfo(s.type, s.bytes, TSDB_FUNC_TID_TAG, 0, &type, &bytes, &inter, 0, 0); diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index b6d45c209176cab8d06cb58b999b136f61b12ac5..da6d0847ec1beacefe4e62d384f5a8bbcee26b1f 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -370,7 +370,7 @@ typedef struct SExprInfo { struct tExprNode* pExpr; int16_t bytes; int16_t type; - int16_t interBytes; + int32_t interBytes; } SExprInfo; typedef struct SColumnFilterInfo { diff --git a/src/query/inc/tsqlfunction.h b/src/query/inc/tsqlfunction.h index e348ceb177a6113517a320026718bf2b3202c809..22d126f7a2cd46e9dff726916d9d61e3d879a5a3 100644 --- a/src/query/inc/tsqlfunction.h +++ b/src/query/inc/tsqlfunction.h @@ -217,7 +217,7 @@ typedef struct SQLAggFuncElem { #define GET_RES_INFO(ctx) ((ctx)->resultInfo) int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionId, int32_t param, int16_t *type, - int16_t *len, int16_t *interBytes, int16_t extLength, bool isSuperTable); + int16_t *len, int32_t *interBytes, int16_t extLength, bool isSuperTable); #define IS_STREAM_QUERY_VALID(x) (((x)&TSDB_FUNCSTATE_STREAM) != 0) #define IS_MULTIOUTPUT(x) (((x)&TSDB_FUNCSTATE_MO) != 0)