diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index db3e36bfc3340872605fa123798d8b969671d550..6cbb2c4ebb38862bff2dacb6623bde6713d5fb62 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -481,7 +481,6 @@ static SResultRow* doSetResultOutBufByKey(SQueryRuntimeEnv* pRuntimeEnv, SResult longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_TOO_MANY_TIMEWINDOW); } - memset(pRuntimeEnv->keyBuf, 0, GET_RES_WINDOW_KEY_LEN(bytes)); return pResultRowInfo->pResult[pResultRowInfo->curPos]; } @@ -1497,11 +1496,12 @@ static void buildGroupbyKeyBuf(const SSDataBlock *pSDataBlock, SGroupbyOperatorI } if (IS_VAR_DATA_TYPE(pDataInfo->type)) { memcpy(p, varDataVal(val), varDataLen(val)); + p += varDataLen(val); } else { memcpy(p, val, pDataInfo->bytes); + p += pDataInfo->bytes; } *isNullKey = false; - p += pDataInfo->bytes; } } static bool isGroupbyKeyEqual(void *a, void *b, void *ext) { @@ -1529,8 +1529,9 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SGroupbyOperatorInfo *pIn qError("QInfo:0x%"PRIx64" group by not supported on double/float columns, abort", GET_QID(pRuntimeEnv)); return; } + //realloc pRuntimeEnv->keyBuf + pRuntimeEnv->keyBuf = realloc(pRuntimeEnv->keyBuf, pInfo->totalBytes + sizeof(int64_t) + POINTER_BYTES); - SColumnInfoData* pFirstColData = taosArrayGet(pSDataBlock->pDataBlock, 0); int64_t* tsList = (pFirstColData->info.type == TSDB_DATA_TYPE_TIMESTAMP)? (int64_t*) pFirstColData->pData:NULL; @@ -1588,7 +1589,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SGroupbyOperatorInfo *pIn doApplyFunctions(pRuntimeEnv, pInfo->binfo.pCtx, &w, pSDataBlock->info.rows - num, num, tsList, pSDataBlock->info.rows, pOperator->numOfOutput); } - //tfree(pInfo->prevData); + tfree(pInfo->prevData); } static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSWindowOperatorInfo *pInfo, SSDataBlock *pSDataBlock) { diff --git a/tests/script/general/parser/groupby.sim b/tests/script/general/parser/groupby.sim index 1fe19714bbd516c2e8938ce1290f04f8d2053839..faa71cf8977227a1ec7c3f4cf4e34c70908b2047 100644 --- a/tests/script/general/parser/groupby.sim +++ b/tests/script/general/parser/groupby.sim @@ -782,13 +782,13 @@ if $data11 != 2 then return -1 endi -sql_error select count(*) from m1 group by tbname,k,f1; -sql_error select count(*) from m1 group by tbname,k,a; -sql_error select count(*) from m1 group by k, tbname; -sql_error select count(*) from m1 group by k,f1; +#sql_error select count(*) from m1 group by tbname,k,f1; +#select count(*) from m1 group by tbname,k,a; +#sql_error select count(*) from m1 group by k, tbname; +#sql_error select count(*) from m1 group by k,f1; sql_error select count(*) from tm0 group by tbname; sql_error select count(*) from tm0 group by a; -sql_error select count(*) from tm0 group by k,f1; +#select count(*) from tm0 group by k,f1; sql_error select count(*),f1 from m1 group by tbname,k;