diff --git a/source/common/src/tdataformat.c b/source/common/src/tdataformat.c index 07ece3b8a2855af16a0013231dbc2da30bc7b338..0886e4bc74ade848c5be0a9aec50ae95c2539807 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 2a7f7343c08db019c05e6e34058d9667fd5b6662..49bffccd9998163c4864b797dc7490a228fb55a3 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 1592f9d7e1be57432e8ee60b557804caf18b98d4..a138b684d1b5877f9c2f356278b99e281070906a 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); }