Merge pull request #27816 from taosdata/enh/TD-31903-3.0

enh(query)[TD-31903]. Handle return values for function calls
This commit is contained in:
Pan Wei 2024-09-14 11:28:19 +08:00 committed by GitHub
commit 42abc16774
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 63 additions and 38 deletions

View File

@ -2516,24 +2516,25 @@ int32_t dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf
pDataBlock->info.id.groupId, pDataBlock->info.id.uid, pDataBlock->info.rows, pDataBlock->info.version,
pDataBlock->info.calWin.skey, pDataBlock->info.calWin.ekey, pDataBlock->info.parTbName);
if (len >= size - 1) {
return code;
goto _exit;
}
for (int32_t j = 0; j < rows; j++) {
len += snprintf(dumpBuf + len, size - len, "%s|", flag);
if (len >= size - 1) {
return code;
goto _exit;
}
for (int32_t k = 0; k < colNum; k++) {
SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, k);
if (pColInfoData == NULL) {
return terrno;
code = terrno;
goto _exit;
}
if (colDataIsNull(pColInfoData, rows, j, NULL) || !pColInfoData->pData) {
len += snprintf(dumpBuf + len, size - len, " %15s |", "NULL");
if (len >= size - 1) return 0;
if (len >= size - 1) goto _exit;
continue;
}
@ -2543,51 +2544,51 @@ int32_t dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf
memset(pBuf, 0, sizeof(pBuf));
(void)formatTimestamp(pBuf, *(uint64_t*)var, pColInfoData->info.precision);
len += snprintf(dumpBuf + len, size - len, " %25s |", pBuf);
if (len >= size - 1) return 0;
if (len >= size - 1) goto _exit;
break;
case TSDB_DATA_TYPE_TINYINT:
len += snprintf(dumpBuf + len, size - len, " %15d |", *(int8_t*)var);
if (len >= size - 1) return 0;
if (len >= size - 1) goto _exit;
break;
case TSDB_DATA_TYPE_UTINYINT:
len += snprintf(dumpBuf + len, size - len, " %15d |", *(uint8_t*)var);
if (len >= size - 1) return 0;
if (len >= size - 1) goto _exit;
break;
case TSDB_DATA_TYPE_SMALLINT:
len += snprintf(dumpBuf + len, size - len, " %15d |", *(int16_t*)var);
if (len >= size - 1) return 0;
if (len >= size - 1) goto _exit;
break;
case TSDB_DATA_TYPE_USMALLINT:
len += snprintf(dumpBuf + len, size - len, " %15d |", *(uint16_t*)var);
if (len >= size - 1) return 0;
if (len >= size - 1) goto _exit;
break;
case TSDB_DATA_TYPE_INT:
len += snprintf(dumpBuf + len, size - len, " %15d |", *(int32_t*)var);
if (len >= size - 1) return 0;
if (len >= size - 1) goto _exit;
break;
case TSDB_DATA_TYPE_UINT:
len += snprintf(dumpBuf + len, size - len, " %15u |", *(uint32_t*)var);
if (len >= size - 1) return 0;
if (len >= size - 1) goto _exit;
break;
case TSDB_DATA_TYPE_BIGINT:
len += snprintf(dumpBuf + len, size - len, " %15" PRId64 " |", *(int64_t*)var);
if (len >= size - 1) return 0;
if (len >= size - 1) goto _exit;
break;
case TSDB_DATA_TYPE_UBIGINT:
len += snprintf(dumpBuf + len, size - len, " %15" PRIu64 " |", *(uint64_t*)var);
if (len >= size - 1) return 0;
if (len >= size - 1) goto _exit;
break;
case TSDB_DATA_TYPE_FLOAT:
len += snprintf(dumpBuf + len, size - len, " %15f |", *(float*)var);
if (len >= size - 1) return 0;
if (len >= size - 1) goto _exit;
break;
case TSDB_DATA_TYPE_DOUBLE:
len += snprintf(dumpBuf + len, size - len, " %15f |", *(double*)var);
if (len >= size - 1) return 0;
if (len >= size - 1) goto _exit;
break;
case TSDB_DATA_TYPE_BOOL:
len += snprintf(dumpBuf + len, size - len, " %15d |", *(bool*)var);
if (len >= size - 1) return 0;
if (len >= size - 1) goto _exit;
break;
case TSDB_DATA_TYPE_VARCHAR:
case TSDB_DATA_TYPE_VARBINARY:
@ -2598,24 +2599,33 @@ int32_t dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf
dataSize = TMIN(dataSize, 50);
memcpy(pBuf, varDataVal(pData), dataSize);
len += snprintf(dumpBuf + len, size - len, " %15s |", pBuf);
if (len >= size - 1) return 0;
if (len >= size - 1) goto _exit;
} break;
case TSDB_DATA_TYPE_NCHAR: {
char* pData = colDataGetVarData(pColInfoData, j);
int32_t dataSize = TMIN(sizeof(pBuf), varDataLen(pData));
memset(pBuf, 0, sizeof(pBuf));
(void)taosUcs4ToMbs((TdUcs4*)varDataVal(pData), dataSize, pBuf);
code = taosUcs4ToMbs((TdUcs4*)varDataVal(pData), dataSize, pBuf);
if (code < 0) {
uError("func %s failed to convert to ucs charset since %s", __func__, tstrerror(code));
goto _exit;
}
len += snprintf(dumpBuf + len, size - len, " %15s |", pBuf);
if (len >= size - 1) return 0;
if (len >= size - 1) goto _exit;
} break;
}
}
len += snprintf(dumpBuf + len, size - len, "%d\n", j);
if (len >= size - 1) return code;
if (len >= size - 1) goto _exit;
}
len += snprintf(dumpBuf + len, size - len, "%s |end\n", flag);
*pDataBuf = dumpBuf;
dumpBuf = NULL;
_exit:
if (dumpBuf) {
taosMemoryFree(dumpBuf);
}
return code;
}

View File

@ -229,7 +229,7 @@ int32_t doSortMerge(SOperatorInfo* pOperator, SSDataBlock** pResBlock) {
resetLimitInfoForNextGroup(&pInfo->limitInfo);
}
(void)applyLimitOffset(&pInfo->limitInfo, p, pTaskInfo);
bool limitReached = applyLimitOffset(&pInfo->limitInfo, p, pTaskInfo);
if (p->info.rows > 0) {
break;

View File

@ -150,10 +150,11 @@ static void doRemoveFromBucket(SFilePage* pPage, SLHashNode* pNode, SLHashBucket
pBucket->size -= 1;
}
static void doTrimBucketPages(SLHashObj* pHashObj, SLHashBucket* pBucket) {
static int32_t doTrimBucketPages(SLHashObj* pHashObj, SLHashBucket* pBucket) {
int32_t code = 0;
size_t numOfPages = taosArrayGetSize(pBucket->pPageIdList);
if (numOfPages <= 1) {
return;
return code;
}
int32_t* firstPage = taosArrayGet(pBucket->pPageIdList, 0);
@ -164,11 +165,14 @@ static void doTrimBucketPages(SLHashObj* pHashObj, SLHashBucket* pBucket) {
if (pLast->num <= sizeof(SFilePage)) {
// this is empty
// TODO check ret
(void)dBufSetBufPageRecycled(pHashObj->pBuf, pLast);
code = dBufSetBufPageRecycled(pHashObj->pBuf, pLast);
if (code != TSDB_CODE_SUCCESS) {
qError("%s failed to recycle buf page since %s", __func__, tstrerror(code));
return code;
}
releaseBufPage(pHashObj->pBuf, pFirst);
taosArrayRemove(pBucket->pPageIdList, numOfPages - 1);
return;
return code;
}
char* pStart = pLast->data;
@ -191,8 +195,11 @@ static void doTrimBucketPages(SLHashObj* pHashObj, SLHashBucket* pBucket) {
pStart += nodeSize;
if (pLast->num <= sizeof(SFilePage)) {
// this is empty
// TODO check ret
(void)dBufSetBufPageRecycled(pHashObj->pBuf, pLast);
code = dBufSetBufPageRecycled(pHashObj->pBuf, pLast);
if (code != TSDB_CODE_SUCCESS) {
qError("%s failed to recycle buf page since %s", __func__, tstrerror(code));
return code;
}
releaseBufPage(pHashObj->pBuf, pFirst);
taosArrayRemove(pBucket->pPageIdList, numOfPages - 1);
break;
@ -210,6 +217,7 @@ static void doTrimBucketPages(SLHashObj* pHashObj, SLHashBucket* pBucket) {
break;
}
}
return code;
}
static int32_t doAddNewBucket(SLHashObj* pHashObj) {
@ -403,7 +411,10 @@ int32_t tHashPut(SLHashObj* pHashObj, const void* key, size_t keyLen, void* data
releaseBufPage(pHashObj->pBuf, p);
}
doTrimBucketPages(pHashObj, pBucket);
code = doTrimBucketPages(pHashObj, pBucket);
if (code != TSDB_CODE_SUCCESS) {
return code;
}
}
return code;

View File

@ -1308,8 +1308,7 @@ static int32_t getRowBufFromExtMemFile(SSortHandle* pHandle, int32_t regionId, i
return terrno;
}
// todo
(void)taosSeekCFile(pMemFile->pTdFile, pRegion->fileOffset, SEEK_SET);
TAOS_CHECK_RETURN(taosSeekCFile(pMemFile->pTdFile, pRegion->fileOffset, SEEK_SET));
int32_t readBytes = TMIN(pMemFile->blockSize, pRegion->regionSize);
int32_t ret = taosReadFromCFile(pRegion->buf, readBytes, 1, pMemFile->pTdFile);

View File

@ -1535,8 +1535,9 @@ int taosSeekCFile(FILE *file, int64_t offset, int whence) {
int code = fseeko(file, offset, whence);
if (-1 == code) {
terrno = TAOS_SYSTEM_ERROR(errno);
code = terrno;
}
return terrno;
return code;
#endif
}

View File

@ -351,7 +351,8 @@ int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs) {
int32_t code = 0;
iconv_t conv = taosAcquireConv(&idx, C2M);
if ((iconv_t)-1 == conv || (iconv_t)0 == conv) {
return TSDB_CODE_APP_ERROR;
code = TAOS_SYSTEM_ERROR(errno);;
return code;
}
size_t ucs4_input_len = ucs4_max_len;

View File

@ -316,7 +316,7 @@ static char* evictBufPage(SDiskbasedBuf* pBuf) {
}
terrno = 0;
(void)tdListPopNode(pBuf->lruList, pn);
pn = tdListPopNode(pBuf->lruList, pn);
SPageInfo* d = *(SPageInfo**)pn->data;
@ -337,7 +337,7 @@ static int32_t lruListPushFront(SList* pList, SPageInfo* pi) {
}
static void lruListMoveToFront(SList* pList, SPageInfo* pi) {
(void)tdListPopNode(pList, pi->pn);
pi->pn = tdListPopNode(pList, pi->pn);
tdListPrependNode(pList, pi->pn);
}
@ -474,8 +474,11 @@ void* getNewBufPage(SDiskbasedBuf* pBuf, int32_t* pageId) {
pBuf->totalBufSize += pBuf->pageSize;
} else {
taosMemoryFree(availablePage);
(void)taosArrayPop(pBuf->pIdList);
(void)tSimpleHashRemove(pBuf->all, pageId, sizeof(int32_t));
SPageInfo **pLast = taosArrayPop(pBuf->pIdList);
int32_t ret = tSimpleHashRemove(pBuf->all, pageId, sizeof(int32_t));
if (ret != TSDB_CODE_SUCCESS) {
uError("%s failed to clear pageId %d from buf hash-set since %s", __func__, *pageId, tstrerror(ret));
}
taosMemoryFree(pi);
terrno = code;
return NULL;