[TD-5474]<fix> fix runtime bug
This commit is contained in:
parent
be4e4c3889
commit
ff9748b473
|
@ -97,12 +97,47 @@ static UNUSED_FUNC void* u_realloc(void* p, size_t __size) {
|
||||||
#define GET_NUM_OF_TABLEGROUP(q) taosArrayGetSize((q)->tableqinfoGroupInfo.pGroupList)
|
#define GET_NUM_OF_TABLEGROUP(q) taosArrayGetSize((q)->tableqinfoGroupInfo.pGroupList)
|
||||||
#define QUERY_IS_INTERVAL_QUERY(_q) ((_q)->interval.interval > 0)
|
#define QUERY_IS_INTERVAL_QUERY(_q) ((_q)->interval.interval > 0)
|
||||||
|
|
||||||
|
#define TSKEY_MAX_ADD(a,b) \
|
||||||
|
do { \
|
||||||
|
if (a < 0) { a = a + b; break;} \
|
||||||
|
if (sizeof(a) == sizeof(int32_t)) { \
|
||||||
|
if((b) > 0 && ((b) >= INT32_MAX - (a))){\
|
||||||
|
a = INT32_MAX; \
|
||||||
|
} else { \
|
||||||
|
a = a + b; \
|
||||||
|
} \
|
||||||
|
} else { \
|
||||||
|
if((b) > 0 && ((b) >= INT64_MAX - (a))){\
|
||||||
|
a = INT64_MAX; \
|
||||||
|
} else { \
|
||||||
|
a = a + b; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
|
#define TSKEY_MIN_SUB(a,b) \
|
||||||
|
do { \
|
||||||
|
if (a >= 0) { a = a + b; break;} \
|
||||||
|
if (sizeof(a) == sizeof(int32_t)){ \
|
||||||
|
if((b) < 0 && ((b) <= INT32_MIN - (a))){\
|
||||||
|
a = INT32_MIN; \
|
||||||
|
} else { \
|
||||||
|
a = a + b; \
|
||||||
|
} \
|
||||||
|
} else { \
|
||||||
|
if((b) < 0 && ((b) <= INT64_MIN-(a))) {\
|
||||||
|
a = INT64_MIN; \
|
||||||
|
} else { \
|
||||||
|
a = a + b; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
uint64_t queryHandleId = 0;
|
uint64_t queryHandleId = 0;
|
||||||
|
|
||||||
int32_t getMaximumIdleDurationSec() {
|
int32_t getMaximumIdleDurationSec() {
|
||||||
return tsShellActivityTimer * 2;
|
return tsShellActivityTimer * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t genQueryId(void) {
|
int64_t genQueryId(void) {
|
||||||
int64_t uid = 0;
|
int64_t uid = 0;
|
||||||
int64_t did = tsDnodeId;
|
int64_t did = tsDnodeId;
|
||||||
|
@ -3124,7 +3159,9 @@ void setTagValue(SOperatorInfo* pOperatorInfo, void *pTable, SQLFunctionCtx* pCt
|
||||||
|| pLocalExprInfo->base.resType == TSDB_DATA_TYPE_TIMESTAMP) {
|
|| pLocalExprInfo->base.resType == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||||
memcpy(pRuntimeEnv->tagVal + offset, &pCtx[idx].tag.i64, pLocalExprInfo->base.resBytes);
|
memcpy(pRuntimeEnv->tagVal + offset, &pCtx[idx].tag.i64, pLocalExprInfo->base.resBytes);
|
||||||
} else {
|
} else {
|
||||||
memcpy(pRuntimeEnv->tagVal + offset, pCtx[idx].tag.pz, pCtx[idx].tag.nLen);
|
if (pCtx[idx].tag.pz != NULL) {
|
||||||
|
memcpy(pRuntimeEnv->tagVal + offset, pCtx[idx].tag.pz, pCtx[idx].tag.nLen);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
offset += pLocalExprInfo->base.resBytes;
|
offset += pLocalExprInfo->base.resBytes;
|
||||||
|
@ -3934,8 +3971,8 @@ static void toSSDataBlock(SGroupResInfo *pGroupResInfo, SQueryRuntimeEnv* pRunti
|
||||||
|
|
||||||
// refactor : extract method
|
// refactor : extract method
|
||||||
SColumnInfoData* pInfoData = taosArrayGet(pBlock->pDataBlock, 0);
|
SColumnInfoData* pInfoData = taosArrayGet(pBlock->pDataBlock, 0);
|
||||||
|
//add condition (pBlock->info.rows >= 1) just to runtime happy
|
||||||
if (pInfoData->info.type == TSDB_DATA_TYPE_TIMESTAMP) {
|
if (pInfoData->info.type == TSDB_DATA_TYPE_TIMESTAMP && pBlock->info.rows >= 1) {
|
||||||
STimeWindow* w = &pBlock->info.window;
|
STimeWindow* w = &pBlock->info.window;
|
||||||
w->skey = *(int64_t*)pInfoData->pData;
|
w->skey = *(int64_t*)pInfoData->pData;
|
||||||
w->ekey = *(int64_t*)(((char*)pInfoData->pData) + TSDB_KEYSIZE * (pBlock->info.rows - 1));
|
w->ekey = *(int64_t*)(((char*)pInfoData->pData) + TSDB_KEYSIZE * (pBlock->info.rows - 1));
|
||||||
|
@ -5273,7 +5310,15 @@ static SSDataBlock* doSTableAggregate(void* param, bool* newgroup) {
|
||||||
// the pDataBlock are always the same one, no need to call this again
|
// the pDataBlock are always the same one, no need to call this again
|
||||||
setInputDataBlock(pOperator, pInfo->pCtx, pBlock, order);
|
setInputDataBlock(pOperator, pInfo->pCtx, pBlock, order);
|
||||||
|
|
||||||
TSKEY key = QUERY_IS_ASC_QUERY(pQueryAttr)? pBlock->info.window.ekey + 1:pBlock->info.window.skey-1;
|
TSKEY key = 0;
|
||||||
|
if (QUERY_IS_ASC_QUERY(pQueryAttr)) {
|
||||||
|
key = pBlock->info.window.ekey;
|
||||||
|
TSKEY_MAX_ADD(key, 1);
|
||||||
|
} else {
|
||||||
|
key = pBlock->info.window.skey;
|
||||||
|
TSKEY_MIN_SUB(key, -1);
|
||||||
|
}
|
||||||
|
|
||||||
setExecutionContext(pRuntimeEnv, pInfo, pOperator->numOfOutput, pRuntimeEnv->current->groupIndex, key);
|
setExecutionContext(pRuntimeEnv, pInfo, pOperator->numOfOutput, pRuntimeEnv->current->groupIndex, key);
|
||||||
doAggregateImpl(pOperator, pQueryAttr->window.skey, pInfo->pCtx, pBlock);
|
doAggregateImpl(pOperator, pQueryAttr->window.skey, pInfo->pCtx, pBlock);
|
||||||
}
|
}
|
||||||
|
|
|
@ -640,7 +640,7 @@ static STableGroupInfo* trimTableGroup(STimeWindow* window, STableGroupInfo* pGr
|
||||||
size_t numOfGroup = taosArrayGetSize(pGroupList->pGroupList);
|
size_t numOfGroup = taosArrayGetSize(pGroupList->pGroupList);
|
||||||
|
|
||||||
STableGroupInfo* pNew = calloc(1, sizeof(STableGroupInfo));
|
STableGroupInfo* pNew = calloc(1, sizeof(STableGroupInfo));
|
||||||
pNew->pGroupList = taosArrayInit(numOfGroup, sizeof(SArray));
|
pNew->pGroupList = taosArrayInit(numOfGroup, POINTER_BYTES);
|
||||||
|
|
||||||
for(int32_t i = 0; i < numOfGroup; ++i) {
|
for(int32_t i = 0; i < numOfGroup; ++i) {
|
||||||
SArray* oneGroup = taosArrayGetP(pGroupList->pGroupList, i);
|
SArray* oneGroup = taosArrayGetP(pGroupList->pGroupList, i);
|
||||||
|
@ -3383,11 +3383,13 @@ static int32_t tableGroupComparFn(const void *p1, const void *p2, const void *pa
|
||||||
type = TSDB_DATA_TYPE_BINARY;
|
type = TSDB_DATA_TYPE_BINARY;
|
||||||
bytes = tGetTbnameColumnSchema()->bytes;
|
bytes = tGetTbnameColumnSchema()->bytes;
|
||||||
} else {
|
} else {
|
||||||
STColumn* pCol = schemaColAt(pTableGroupSupp->pTagSchema, colIndex);
|
if (pTableGroupSupp->pTagSchema && colIndex < pTableGroupSupp->pTagSchema->numOfCols) {
|
||||||
bytes = pCol->bytes;
|
STColumn* pCol = schemaColAt(pTableGroupSupp->pTagSchema, colIndex);
|
||||||
type = pCol->type;
|
bytes = pCol->bytes;
|
||||||
f1 = tdGetKVRowValOfCol(pTable1->tagVal, pCol->colId);
|
type = pCol->type;
|
||||||
f2 = tdGetKVRowValOfCol(pTable2->tagVal, pCol->colId);
|
f1 = tdGetKVRowValOfCol(pTable1->tagVal, pCol->colId);
|
||||||
|
f2 = tdGetKVRowValOfCol(pTable2->tagVal, pCol->colId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// this tags value may be NULL
|
// this tags value may be NULL
|
||||||
|
|
|
@ -159,7 +159,7 @@ int tsCompressINTImp(const char *const input, const int nelements, char *const o
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Get difference.
|
// Get difference.
|
||||||
if (!safeInt64Add(curr_value, -prev_value)) goto _copy_and_exit;
|
if (!safeInt64Add(curr_value, -prev_value_tmp)) goto _copy_and_exit;
|
||||||
|
|
||||||
int64_t diff = curr_value - prev_value_tmp;
|
int64_t diff = curr_value - prev_value_tmp;
|
||||||
// Zigzag encode the value.
|
// Zigzag encode the value.
|
||||||
|
|
Loading…
Reference in New Issue