From 3c11dc4ec1f6c6b5d2cfa1f835b3759443ab91a1 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 13 Mar 2024 09:54:14 +0000 Subject: [PATCH] fix show create table crash --- source/dnode/mnode/impl/src/mndInfoSchema.c | 3 ++- source/dnode/mnode/impl/src/mndStb.c | 10 +++++++++- source/dnode/vnode/src/vnd/vnodeQuery.c | 11 +++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndInfoSchema.c b/source/dnode/mnode/impl/src/mndInfoSchema.c index 689da5a855..2c7eca28ae 100644 --- a/source/dnode/mnode/impl/src/mndInfoSchema.c +++ b/source/dnode/mnode/impl/src/mndInfoSchema.c @@ -88,7 +88,6 @@ int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char * return -1; } - *pRsp = *pMeta; pRsp->pSchemas = taosMemoryCalloc(pMeta->numOfColumns, sizeof(SSchema)); @@ -130,6 +129,8 @@ int32_t mndBuildInsTableCfg(SMnode *pMnode, const char *dbFName, const char *tbN } memcpy(pRsp->pSchemas, pMeta->pSchemas, pMeta->numOfColumns * sizeof(SSchema)); + + pRsp->pSchemaExt = taosMemoryCalloc(pMeta->numOfColumns, sizeof(SSchemaExt)); return 0; } diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index b6a15d4ef6..7a5cacc015 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -2039,7 +2039,15 @@ static int32_t mndBuildStbCfgImp(SDbObj *pDb, SStbObj *pStb, const char *tbName, if (pStb->numOfFuncs > 0) { pRsp->pFuncs = taosArrayDup(pStb->pFuncs, NULL); } - + + pRsp->pSchemaExt = taosMemoryCalloc(pStb->numOfColumns, sizeof(SSchemaExt)); + for (int32_t i = 0; i < pStb->numOfColumns; i++) { + SCmprObj *pCmpr = &pStb->pCmpr[i]; + + SSchemaExt *pSchExt = &pRsp->pSchemaExt[i]; + pSchExt->colId = pCmpr->colId; + pSchExt->compress = pCmpr->cmprAlg; + } taosRUnLockLatch(&pStb->lock); return 0; diff --git a/source/dnode/vnode/src/vnd/vnodeQuery.c b/source/dnode/vnode/src/vnd/vnodeQuery.c index 124a56c144..7f01b05223 100644 --- a/source/dnode/vnode/src/vnd/vnodeQuery.c +++ b/source/dnode/vnode/src/vnd/vnodeQuery.c @@ -247,12 +247,23 @@ int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) { cfgRsp.numOfTags = schemaTag.nCols; cfgRsp.numOfColumns = schema.nCols; cfgRsp.pSchemas = (SSchema *)taosMemoryMalloc(sizeof(SSchema) * (cfgRsp.numOfColumns + cfgRsp.numOfTags)); + cfgRsp.pSchemaExt = (SSchemaExt *)taosMemoryMalloc(cfgRsp.numOfColumns * sizeof(SSchemaExt)); memcpy(cfgRsp.pSchemas, schema.pSchema, sizeof(SSchema) * schema.nCols); if (schemaTag.nCols) { memcpy(cfgRsp.pSchemas + schema.nCols, schemaTag.pSchema, sizeof(SSchema) * schemaTag.nCols); } + if (useCompress(cfgRsp.tableType)) { + SColCmprWrapper *pColCmpr = &mer1.me.colCmpr; + for (int32_t i = 0; i < cfgRsp.numOfColumns; i++) { + SColCmpr *pCmpr = &pColCmpr->pColCmpr[i]; + SSchemaExt *pSchExt = cfgRsp.pSchemaExt + i; + pSchExt->colId = pCmpr->id; + pSchExt->compress = pCmpr->alg; + } + } + // encode and send response rspLen = tSerializeSTableCfgRsp(NULL, 0, &cfgRsp); if (rspLen < 0) {