From 5c67a6736369ae2029feb852338724148111b74c Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 13 Mar 2024 08:33:53 +0000 Subject: [PATCH] fix desc crash --- source/common/src/tmsg.c | 13 +++++++------ source/dnode/vnode/src/meta/metaTable.c | 8 ++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 2942491dca..12f62c3d7a 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -4494,13 +4494,13 @@ static int32_t tDecodeSTableMetaRsp(SDecoder *pDecoder, STableMetaRsp *pRsp) { if (!tDecodeIsEnd(pDecoder)) { if (useCompress(pRsp->tableType) && pRsp->numOfColumns > 0) { - pRsp->pSchemaExt = taosMemoryMalloc(sizeof(SSchemaExt) * pRsp->numOfColumns); - if (pRsp->pSchemaExt == NULL) return -1; + pRsp->pSchemaExt = taosMemoryMalloc(sizeof(SSchemaExt) * pRsp->numOfColumns); + if (pRsp->pSchemaExt == NULL) return -1; - for (int32_t i = 0; i < pRsp->numOfColumns; ++i) { - SSchemaExt *pSchemaExt = &pRsp->pSchemaExt[i]; - if (tDecodeSSchemaExt(pDecoder, pSchemaExt) < 0) return -1; - } + for (int32_t i = 0; i < pRsp->numOfColumns; ++i) { + SSchemaExt *pSchemaExt = &pRsp->pSchemaExt[i]; + if (tDecodeSSchemaExt(pDecoder, pSchemaExt) < 0) return -1; + } } else { pRsp->pSchemaExt = NULL; } @@ -7852,6 +7852,7 @@ void tFreeSVCreateTbRsp(void *param) { SVCreateTbRsp *pRsp = (SVCreateTbRsp *)param; if (pRsp->pMeta) { taosMemoryFree(pRsp->pMeta->pSchemas); + taosMemoryFree(pRsp->pMeta->pSchemaExt); taosMemoryFree(pRsp->pMeta); } } diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 96c7458b60..76890cde8c 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -55,11 +55,14 @@ static void metaGetEntryInfo(const SMetaEntry *pEntry, SMetaInfo *pInfo) { static int metaUpdateMetaRsp(tb_uid_t uid, char *tbName, SSchemaWrapper *pSchema, STableMetaRsp *pMetaRsp) { pMetaRsp->pSchemas = taosMemoryMalloc(pSchema->nCols * sizeof(SSchema)); + if (NULL == pMetaRsp->pSchemas) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } + pMetaRsp->pSchemaExt = taosMemoryMalloc(pSchema->nCols * sizeof(SSchemaExt)); + tstrncpy(pMetaRsp->tbName, tbName, TSDB_TABLE_NAME_LEN); pMetaRsp->numOfColumns = pSchema->nCols; pMetaRsp->tableType = TSDB_NORMAL_TABLE; @@ -943,6 +946,11 @@ int metaCreateTable(SMeta *pMeta, int64_t ver, SVCreateTbReq *pReq, STableMetaRs strcpy((*pMetaRsp)->tbName, pReq->name); } else { metaUpdateMetaRsp(pReq->uid, pReq->name, &pReq->ntb.schemaRow, *pMetaRsp); + for (int32_t i = 0; i < pReq->colCmpr.nCols; i++) { + SColCmpr *p = &pReq->colCmpr.pColCmpr[i]; + (*pMetaRsp)->pSchemaExt[i].colId = p->id; + (*pMetaRsp)->pSchemaExt[i].compress = p->alg; + } } } }