From 6d79a5f58967bfe9ef2277f12aca59a10afa3b02 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Tue, 6 Sep 2022 12:52:47 +0800 Subject: [PATCH] fix(query): save row count with int16_t smaller --- src/common/inc/texpr.h | 2 +- src/common/src/texpr.c | 42 ++++++++++++++++++++++-------------------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/common/inc/texpr.h b/src/common/inc/texpr.h index 5fdb56703d..3ce519c140 100644 --- a/src/common/inc/texpr.h +++ b/src/common/inc/texpr.h @@ -85,7 +85,7 @@ struct SSchema; typedef struct { int16_t type; int16_t bytes; - int16_t numOfRows; + int32_t numOfRows; char* data; } tExprOperandInfo; diff --git a/src/common/src/texpr.c b/src/common/src/texpr.c index 7198c3d464..1acfd3c4f9 100644 --- a/src/common/src/texpr.c +++ b/src/common/src/texpr.c @@ -668,55 +668,56 @@ void exprTreeExprNodeTraverse(tExprNode *pExpr, int32_t numOfRows, tExprOperandI pl = ltmp; pt = transl; + int32_t i; switch (left.type) { case TSDB_DATA_TYPE_TINYINT: - for (int16_t i = 0; i < left.numOfRows; i++) { + for (i = 0; i < left.numOfRows; i++) { *((int64_t *) pt + i) = (int64_t)(*((int8_t *) pl + i)); } break; case TSDB_DATA_TYPE_SMALLINT: - for (int16_t i = 0; i < left.numOfRows; i++) { + for (i = 0; i < left.numOfRows; i++) { *((int64_t *) pt + i) = (int64_t)(*((int16_t *) pl + i)); } break; case TSDB_DATA_TYPE_INT: - for (int16_t i = 0; i < left.numOfRows; i++) { + for (i = 0; i < left.numOfRows; i++) { *((int64_t *) pt + i) = (int64_t)(*((int32_t *) pl + i)); } break; case TSDB_DATA_TYPE_BIGINT: - for (int16_t i = 0; i < left.numOfRows; i++) { + for (i = 0; i < left.numOfRows; i++) { *((int64_t *) pt + i) = (int64_t)(*((int64_t *) pl + i)); } break; case TSDB_DATA_TYPE_UTINYINT: - for (int16_t i = 0; i < left.numOfRows; i++) { + for (i = 0; i < left.numOfRows; i++) { *((int64_t *) pt + i) = (int64_t)(*((uint8_t *) pl + i)); } break; case TSDB_DATA_TYPE_USMALLINT: - for (int16_t i = 0; i < left.numOfRows; i++) { + for (i = 0; i < left.numOfRows; i++) { *((int64_t *) pt + i) = (int64_t)(*((uint16_t *) pl + i)); } break; case TSDB_DATA_TYPE_UINT: - for (int16_t i = 0; i < left.numOfRows; i++) { + for (i = 0; i < left.numOfRows; i++) { *((int64_t *) pt + i) = (int64_t)(*((uint32_t *) pl + i)); } break; case TSDB_DATA_TYPE_UBIGINT: - for (int16_t i = 0; i < left.numOfRows; i++) { + for (i = 0; i < left.numOfRows; i++) { *((int64_t *) pt + i) = (int64_t)(*((uint64_t *) pl + i)); } break; case TSDB_DATA_TYPE_FLOAT: - for (int16_t i = 0; i < left.numOfRows; i++) { + for (i = 0; i < left.numOfRows; i++) { *((int64_t *) pt + i) = (int64_t)(*((float *) pl + i)); } break; case TSDB_DATA_TYPE_DOUBLE: - for (int16_t i = 0; i < left.numOfRows; i++) { + for (i = 0; i < left.numOfRows; i++) { *((int64_t *) pt + i) = (int64_t)(*((double *) pl + i)); } break; @@ -766,55 +767,56 @@ void exprTreeExprNodeTraverse(tExprNode *pExpr, int32_t numOfRows, tExprOperandI pr = rtmp; pt = transr; + int32_t i; switch (right.type) { case TSDB_DATA_TYPE_TINYINT: - for (int16_t i = 0; i < right.numOfRows; i++) { + for (i = 0; i < right.numOfRows; i++) { *((int64_t *) pt + i) = (int64_t)(*((int8_t *) pr + i)); } break; case TSDB_DATA_TYPE_SMALLINT: - for (int16_t i = 0; i < right.numOfRows; i++) { + for (i = 0; i < right.numOfRows; i++) { *((int64_t *) pt + i) = (int64_t)(*((int16_t *) pr + i)); } break; case TSDB_DATA_TYPE_INT: - for (int16_t i = 0; i < right.numOfRows; i++) { + for (i = 0; i < right.numOfRows; i++) { *((int64_t *) pt + i) = (int64_t)(*((int32_t *) pr + i)); } break; case TSDB_DATA_TYPE_BIGINT: - for (int16_t i = 0; i < right.numOfRows; i++) { + for (i = 0; i < right.numOfRows; i++) { *((int64_t *) pt + i) = (int64_t)(*((int64_t *) pr + i)); } break; case TSDB_DATA_TYPE_UTINYINT: - for (int16_t i = 0; i < right.numOfRows; i++) { + for (i = 0; i < right.numOfRows; i++) { *((int64_t *) pt + i) = (int64_t)(*((uint8_t *) pr + i)); } break; case TSDB_DATA_TYPE_USMALLINT: - for (int16_t i = 0; i < right.numOfRows; i++) { + for (i = 0; i < right.numOfRows; i++) { *((int64_t *) pt + i) = (int64_t)(*((uint16_t *) pr + i)); } break; case TSDB_DATA_TYPE_UINT: - for (int16_t i = 0; i < right.numOfRows; i++) { + for (i = 0; i < right.numOfRows; i++) { *((int64_t *) pt + i) = (int64_t)(*((uint32_t *) pr + i)); } break; case TSDB_DATA_TYPE_UBIGINT: - for (int16_t i = 0; i < right.numOfRows; i++) { + for (i = 0; i < right.numOfRows; i++) { *((int64_t *) pt + i) = (int64_t)(*((uint64_t *) pr + i)); } break; case TSDB_DATA_TYPE_FLOAT: - for (int16_t i = 0; i < right.numOfRows; i++) { + for (i = 0; i < right.numOfRows; i++) { *((int64_t *) pt + i) = (int64_t)(*((float *) pr + i)); } break; case TSDB_DATA_TYPE_DOUBLE: - for (int16_t i = 0; i < right.numOfRows; i++) { + for (i = 0; i < right.numOfRows; i++) { *((int64_t *) pt + i) = (int64_t)(*((double *) pr + i)); } break; -- GitLab