From 2d804fa48f8e758af181e05ca34102ceb86e3a46 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 29 Nov 2022 21:30:08 +0800 Subject: [PATCH] more code --- source/common/src/tdataformat.c | 9 +++----- source/common/src/tmsg.c | 30 +++++++++++++++----------- source/libs/parser/src/parInsertUtil.c | 5 ++++- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/source/common/src/tdataformat.c b/source/common/src/tdataformat.c index 07ece3b8a2..0886e4bc74 100644 --- a/source/common/src/tdataformat.c +++ b/source/common/src/tdataformat.c @@ -120,7 +120,6 @@ int32_t tRowBuild(SArray *aColVal, STSchema *pTSchema, SRow **ppRow) { while (pTColumn) { if (pColVal) { if (pColVal->cid == pTColumn->colId) { - ntp += TYPE_BYTES[pTColumn->type]; if (COL_VAL_IS_VALUE(pColVal)) { // VALUE flag |= HAS_VALUE; maxIdx = nkv; @@ -146,14 +145,12 @@ int32_t tRowBuild(SArray *aColVal, STSchema *pTSchema, SRow **ppRow) { pColVal = (++iColVal < nColVal) ? &colVals[iColVal] : NULL; } else if (pColVal->cid > pTColumn->colId) { // NONE flag |= HAS_NONE; - ntp += TYPE_BYTES[pTColumn->type]; pTColumn = (++iTColumn < pTSchema->numOfCols) ? pTSchema->columns + iTColumn : NULL; } else { pColVal = (++iColVal < nColVal) ? &colVals[iColVal] : NULL; } } else { // NONE flag |= HAS_NONE; - ntp += TYPE_BYTES[pTColumn->type]; pTColumn = (++iTColumn < pTSchema->numOfCols) ? pTSchema->columns + iTColumn : NULL; } } @@ -165,17 +162,17 @@ int32_t tRowBuild(SArray *aColVal, STSchema *pTSchema, SRow **ppRow) { ntp = sizeof(SRow); break; case HAS_VALUE: - ntp = sizeof(SRow) + ntp; + ntp = sizeof(SRow) + pTSchema->flen; break; case (HAS_NULL | HAS_NONE): ntp = sizeof(SRow) + BIT1_SIZE(pTSchema->numOfCols - 1); break; case (HAS_VALUE | HAS_NONE): case (HAS_VALUE | HAS_NULL): - ntp = sizeof(SRow) + BIT1_SIZE(pTSchema->numOfCols - 1) + ntp; + ntp = sizeof(SRow) + BIT1_SIZE(pTSchema->numOfCols - 1) + pTSchema->flen + ntp; break; case (HAS_VALUE | HAS_NULL | HAS_NONE): - ntp = sizeof(SRow) + BIT2_SIZE(pTSchema->numOfCols - 1) + ntp; + ntp = sizeof(SRow) + BIT2_SIZE(pTSchema->numOfCols - 1) + pTSchema->flen + ntp; break; default: ASSERT(0); diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 2a7f7343c0..49bffccd99 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -6807,26 +6807,30 @@ _exit: return code; } -void destroySSubmitTbData(SSubmitTbData *pTbData) { - // if (pTbData->isColFmt) { - // // todo - // } else { - // taosArrayDestroyP(pTbData->aRowP, (FDelete)tRowDestroy); - // } -} - void tDestroySSubmitTbData(SSubmitTbData *pTbData) { - if (NULL == pTbData) { - return; + if (pTbData->pCreateTbReq) { + // todo + taosMemoryFree(pTbData->pCreateTbReq); + } + + if (pTbData->flags & SUBMIT_REQ_COLUMN_DATA_FORMAT) { + ASSERT(0); // TODO + } else { + if (pTbData->aRowP) { + int32_t nRow = TARRAY_SIZE(pTbData->aRowP); + SRow **rows = (SRow **)TARRAY_DATA(pTbData->aRowP); + for (int32_t i = 0; i < nRow; ++i) { + tRowDestroy(rows[i]); + } + taosArrayDestroy(pTbData->aRowP); + } } - destroySSubmitTbData(pTbData); - taosMemoryFree(pTbData); } void tDestroySSubmitReq2(SSubmitReq2 *pReq) { if (NULL == pReq) return; - taosArrayDestroyEx(pReq->aSubmitTbData, (FDelete)destroySSubmitTbData); + taosArrayDestroyEx(pReq->aSubmitTbData, (FDelete)tDestroySSubmitTbData); } int32_t tEncodeSSubmitRsp2(SEncoder *pCoder, const SSubmitRsp2 *pRsp) { diff --git a/source/libs/parser/src/parInsertUtil.c b/source/libs/parser/src/parInsertUtil.c index 1592f9d7e1..a138b684d1 100644 --- a/source/libs/parser/src/parInsertUtil.c +++ b/source/libs/parser/src/parInsertUtil.c @@ -1069,7 +1069,10 @@ void insDestroyTableDataCxt(STableDataCxt* pTableCxt) { tDestroyTSchema(pTableCxt->pSchema); destroyBoundColInfo(&pTableCxt->boundColsInfo); taosArrayDestroyEx(pTableCxt->pValues, destroyColVal); - tDestroySSubmitTbData(pTableCxt->pData); + if (pTableCxt->pData) { + tDestroySSubmitTbData(pTableCxt->pData); + taosMemoryFree(pTableCxt->pData); + } taosMemoryFree(pTableCxt); } -- GitLab