diff --git a/source/common/src/systable.c b/source/common/src/systable.c index db0cc78de682a948126fd476f4129406c50740b8..bb0e882fcdd1fdd77f0af49cbd3a90423bb4edb3 100644 --- a/source/common/src/systable.c +++ b/source/common/src/systable.c @@ -280,7 +280,7 @@ static const SSysDbTableSchema topicSchema[] = { {.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false}, {.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, - {.name = "schema", .bytes = TSDB_SHOW_SCHEMA_JSON_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, + {.name = "schema", .bytes = TSDB_MAX_BINARY_LEN, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, {.name = "meta", .bytes = 4 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, {.name = "type", .bytes = 8 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, }; diff --git a/source/libs/executor/src/aggregateoperator.c b/source/libs/executor/src/aggregateoperator.c index b34c6f4b82842a9080d628b9ef4cc0fcf60f3b6e..a32f48200766ece6c7dfb349bdf816b17e7b2f52 100644 --- a/source/libs/executor/src/aggregateoperator.c +++ b/source/libs/executor/src/aggregateoperator.c @@ -461,8 +461,12 @@ int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t n uint32_t defaultPgsz = 0; uint32_t defaultBufsz = 0; - getBufferPgSize(pAggSup->resultRowSize, &defaultPgsz, &defaultBufsz); - + code = getBufferPgSize(pAggSup->resultRowSize, &defaultPgsz, &defaultBufsz); + if (code) { + qError("failed to get buff page size, rowSize:%d", pAggSup->resultRowSize); + return code; + } + if (!osTempSpaceAvailable()) { code = TSDB_CODE_NO_DISKSPACE; qError("Init stream agg supporter failed since %s, key:%s, tempDir:%s", terrstr(code), pKey, tsTempDir); diff --git a/source/libs/executor/src/executorInt.c b/source/libs/executor/src/executorInt.c index fbc0512a26205d3f04159d5672b894c83ab528b0..42b8a9d31c4afb42b824f0a458bcd3decd2d98a8 100644 --- a/source/libs/executor/src/executorInt.c +++ b/source/libs/executor/src/executorInt.c @@ -922,8 +922,13 @@ void destroyExprInfo(SExprInfo* pExpr, int32_t numOfExprs) { int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, uint32_t* defaultBufsz) { *defaultPgsz = 4096; + uint32_t last = *defaultPgsz; while (*defaultPgsz < rowSize * 4) { *defaultPgsz <<= 1u; + if (*defaultPgsz < last) { + return TSDB_CODE_INVALID_PARA; + } + last = *defaultPgsz; } // The default buffer for each operator in query is 10MB. @@ -932,6 +937,9 @@ int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, uint32_t* defaul *defaultBufsz = 4096 * 2560; if ((*defaultBufsz) <= (*defaultPgsz)) { (*defaultBufsz) = (*defaultPgsz) * 4; + if (*defaultBufsz < ((int64_t)(*defaultPgsz)) * 4) { + return TSDB_CODE_INVALID_PARA; + } } return 0; diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c index 7aac639027fa63e5aee3b1f8a3c834f8999ff7ac..a1d30866436293f406f7143a344963d218e7de38 100644 --- a/source/libs/executor/src/groupoperator.c +++ b/source/libs/executor/src/groupoperator.c @@ -869,7 +869,12 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition uint32_t defaultBufsz = 0; pInfo->binfo.pRes = createDataBlockFromDescNode(pPartNode->node.pOutputDataBlockDesc); - getBufferPgSize(pInfo->binfo.pRes->info.rowSize, &defaultPgsz, &defaultBufsz); + int32_t code = getBufferPgSize(pInfo->binfo.pRes->info.rowSize, &defaultPgsz, &defaultBufsz); + if (code != TSDB_CODE_SUCCESS) { + terrno = code; + pTaskInfo->code = code; + goto _error; + } if (!osTempSpaceAvailable()) { terrno = TSDB_CODE_NO_DISKSPACE; @@ -878,7 +883,7 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition goto _error; } - int32_t code = createDiskbasedBuf(&pInfo->pBuf, defaultPgsz, defaultBufsz, pTaskInfo->id.str, tsTempDir); + code = createDiskbasedBuf(&pInfo->pBuf, defaultPgsz, defaultBufsz, pTaskInfo->id.str, tsTempDir); if (code != TSDB_CODE_SUCCESS) { terrno = code; pTaskInfo->code = code;