未验证 提交 4305ed31 编写于 作者: wmmhello's avatar wmmhello 提交者: GitHub

Merge pull request #11877 from taosdata/fix/TD-14916

fix: coredump if mode function with interval
...@@ -3362,14 +3362,8 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col ...@@ -3362,14 +3362,8 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
tVariantDump(pVariant, val, TSDB_DATA_TYPE_BIGINT, true); tVariantDump(pVariant, val, TSDB_DATA_TYPE_BIGINT, true);
if(functionId == TSDB_FUNC_UNIQUE){ // consider of memory size if(functionId == TSDB_FUNC_UNIQUE){ // consider of memory size
if(pSchema->bytes < 10){
GET_INT64_VAL(val) = MAX_UNIQUE_RESULT_ROWS * 100;
}else if(pSchema->bytes < 100){
GET_INT64_VAL(val) = MAX_UNIQUE_RESULT_ROWS * 10;
}else{
GET_INT64_VAL(val) = MAX_UNIQUE_RESULT_ROWS; GET_INT64_VAL(val) = MAX_UNIQUE_RESULT_ROWS;
} }
}
int64_t numRowsSelected = GET_INT64_VAL(val); int64_t numRowsSelected = GET_INT64_VAL(val);
if (functionId != TSDB_FUNC_UNIQUE && (numRowsSelected <= 0 || numRowsSelected > 100)) { // todo use macro if (functionId != TSDB_FUNC_UNIQUE && (numRowsSelected <= 0 || numRowsSelected > 100)) { // todo use macro
......
...@@ -1528,6 +1528,11 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue ...@@ -1528,6 +1528,11 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue
tscDebug("0x%"PRIx64" create QInfo 0x%"PRIx64" to execute the main query while all nest queries are ready", pSql->self, pSql->self); tscDebug("0x%"PRIx64" create QInfo 0x%"PRIx64" to execute the main query while all nest queries are ready", pSql->self, pSql->self);
px->pQInfo = createQInfoFromQueryNode(px, &tableGroupInfo, pSourceOperator, NULL, NULL, MASTER_SCAN, pSql->self); px->pQInfo = createQInfoFromQueryNode(px, &tableGroupInfo, pSourceOperator, NULL, NULL, MASTER_SCAN, pSql->self);
if (px->pQInfo == NULL) {
tscAsyncResultOnError(pSql);
pOutput->code = TSDB_CODE_QRY_OUT_OF_MEMORY;
return;
}
px->pQInfo->runtimeEnv.udfIsCopy = true; px->pQInfo->runtimeEnv.udfIsCopy = true;
px->pQInfo->runtimeEnv.pUdfInfo = pUdfInfo; px->pQInfo->runtimeEnv.pUdfInfo = pUdfInfo;
......
...@@ -79,9 +79,9 @@ typedef struct SDiskbasedResultBuf { ...@@ -79,9 +79,9 @@ typedef struct SDiskbasedResultBuf {
#define DEFAULT_INTERN_BUF_PAGE_SIZE (1024L) // in bytes #define DEFAULT_INTERN_BUF_PAGE_SIZE (1024L) // in bytes
#define PAGE_INFO_INITIALIZER (SPageDiskInfo){-1, -1} #define PAGE_INFO_INITIALIZER (SPageDiskInfo){-1, -1}
#define MAX_UNIQUE_RESULT_ROWS (10000) #define MAX_UNIQUE_RESULT_ROWS (10000)
#define MAX_UNIQUE_RESULT_SIZE (1024*1024*10) #define MAX_UNIQUE_RESULT_SIZE (1024*1024)
#define MAX_MODE_INNER_RESULT_ROWS (1000000) #define MAX_MODE_INNER_RESULT_ROWS (10000)
#define MAX_MODE_INNER_RESULT_SIZE (1024*1024*10) #define MAX_MODE_INNER_RESULT_SIZE (1024*1024)
/** /**
* create disk-based result buffer * create disk-based result buffer
* @param pResultBuf * @param pResultBuf
......
...@@ -330,11 +330,11 @@ SSDataBlock* createOutputBuf(SExprInfo* pExpr, int32_t numOfOutput, int32_t numO ...@@ -330,11 +330,11 @@ SSDataBlock* createOutputBuf(SExprInfo* pExpr, int32_t numOfOutput, int32_t numO
int64_t tmp = idata.info.bytes; int64_t tmp = idata.info.bytes;
tmp *= numOfRows; tmp *= numOfRows;
if (tmp >= 1024*1024*1024) { // 1G if (tmp >= INT32_MAX) {
qError("size is too large, failed to allocate column buffer for output buffer"); qError("size is too large, failed to allocate column buffer for output buffer:%" PRId64, tmp);
tmp = 128*1024*1024; tmp = 128*1024*1024;
} }
int32_t size = (int32_t)MAX(tmp, minSize); size_t size = (size_t)MAX(tmp, minSize);
idata.pData = calloc(1, size); // at least to hold a pointer on x64 platform idata.pData = calloc(1, size); // at least to hold a pointer on x64 platform
if (idata.pData == NULL) { if (idata.pData == NULL) {
qError("failed to allocate column buffer for output buffer"); qError("failed to allocate column buffer for output buffer");
...@@ -2131,7 +2131,7 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOf ...@@ -2131,7 +2131,7 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOf
pRuntimeEnv->sasArray = calloc(pQueryAttr->numOfOutput, sizeof(SScalarExprSupport)); pRuntimeEnv->sasArray = calloc(pQueryAttr->numOfOutput, sizeof(SScalarExprSupport));
if (pRuntimeEnv->sasArray == NULL || pRuntimeEnv->pResultRowHashTable == NULL || pRuntimeEnv->keyBuf == NULL || if (pRuntimeEnv->sasArray == NULL || pRuntimeEnv->pResultRowHashTable == NULL || pRuntimeEnv->keyBuf == NULL ||
pRuntimeEnv->prevRow == NULL || pRuntimeEnv->tagVal == NULL) { pRuntimeEnv->prevRow == NULL || pRuntimeEnv->tagVal == NULL || pRuntimeEnv->pool == NULL) {
goto _clean; goto _clean;
} }
......
...@@ -204,9 +204,9 @@ SResultRowPool* initResultRowPool(size_t size) { ...@@ -204,9 +204,9 @@ SResultRowPool* initResultRowPool(size_t size) {
p->elemSize = (int32_t) size; p->elemSize = (int32_t) size;
int64_t tmp = p->elemSize; int64_t tmp = p->elemSize;
tmp *= p->numOfElemPerBlock; tmp *= p->numOfElemPerBlock;
if (tmp > 1024*1024*1024){ if (tmp > INT32_MAX){
qError("ResultRow blockSize is too large:%" PRId64, tmp); qError("ResultRow blockSize is too large:%" PRId64, tmp);
tmp = 128*1024*1024; return NULL;
} }
p->blockSize = (int32_t)tmp; p->blockSize = (int32_t)tmp;
p->position.pos = 0; p->position.pos = 0;
...@@ -223,6 +223,7 @@ SResultRow* getNewResultRow(SResultRowPool* p) { ...@@ -223,6 +223,7 @@ SResultRow* getNewResultRow(SResultRowPool* p) {
void* ptr = NULL; void* ptr = NULL;
if (p->position.pos == 0) { if (p->position.pos == 0) {
ptr = calloc(1, p->blockSize); ptr = calloc(1, p->blockSize);
if(ptr == NULL) return NULL;
taosArrayPush(p->pData, &ptr); taosArrayPush(p->pData, &ptr);
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册