From 9c737612d50424037a61d34258eacdd2db113415 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 19 Jun 2020 11:07:10 +0800 Subject: [PATCH] [td-225] update the error code when system related error happens. --- src/query/inc/qextbuffer.h | 2 +- src/query/src/qextbuffer.c | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/query/inc/qextbuffer.h b/src/query/inc/qextbuffer.h index 23b67083e5..2cbef2b1be 100644 --- a/src/query/inc/qextbuffer.h +++ b/src/query/inc/qextbuffer.h @@ -149,7 +149,7 @@ int16_t tExtMemBufferPut(tExtMemBuffer *pMemBuffer, void *data, int32_t numOfRow * @param pMemBuffer * @return */ -bool tExtMemBufferFlush(tExtMemBuffer *pMemBuffer); +int32_t tExtMemBufferFlush(tExtMemBuffer *pMemBuffer); /** * diff --git a/src/query/src/qextbuffer.c b/src/query/src/qextbuffer.c index e0a90e0408..35f5e22ed5 100644 --- a/src/query/src/qextbuffer.c +++ b/src/query/src/qextbuffer.c @@ -245,30 +245,29 @@ static void tExtMemBufferClearFlushoutInfo(tExtMemBuffer *pMemBuffer) { memset(pFileMeta->flushoutData.pFlushoutInfo, 0, sizeof(tFlushoutInfo) * pFileMeta->flushoutData.nAllocSize); } -bool tExtMemBufferFlush(tExtMemBuffer *pMemBuffer) { +int32_t tExtMemBufferFlush(tExtMemBuffer *pMemBuffer) { + int32_t ret = 0; if (pMemBuffer->numOfTotalElems == 0) { - return true; + return ret; } if (pMemBuffer->file == NULL) { if ((pMemBuffer->file = fopen(pMemBuffer->path, "wb+")) == NULL) { - return false; + ret = TAOS_SYSTEM_ERROR(errno); + return ret; } } /* all data has been flushed to disk, ignore flush operation */ if (pMemBuffer->numOfElemsInBuffer == 0) { - return true; + return ret; } - bool ret = true; - tFilePagesItem *first = pMemBuffer->pHead; - while (first != NULL) { size_t retVal = fwrite((char *)&(first->item), pMemBuffer->pageSize, 1, pMemBuffer->file); if (retVal <= 0) { // failed to write to buffer, may be not enough space - ret = false; + ret = TAOS_SYSTEM_ERROR(errno); } pMemBuffer->fileMeta.numOfElemsInFile += first->item.num;