From 01ee8b36a4424a98a0d3002ffc6969972df8e9ef Mon Sep 17 00:00:00 2001 From: Yihao Deng Date: Wed, 19 Jun 2024 12:35:38 +0000 Subject: [PATCH] update case --- source/dnode/mnode/impl/src/mndStb.c | 6 +++++- source/dnode/vnode/src/meta/metaTable.c | 7 ++++++- source/util/src/tcompression.c | 10 ++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 0d3affe6e5..41ca6aadc2 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -1766,7 +1766,7 @@ static int32_t mndUpdateSuperTableColumnCompress(SMnode *pMnode, const SStbObj * uint32_t dst = 0; updated = tUpdateCompress(pCmpr->alg, p->bytes, TSDB_COLVAL_COMPRESS_DISABLED, TSDB_COLVAL_LEVEL_DISABLED, TSDB_COLVAL_LEVEL_MEDIUM, &dst); - if (updated) pCmpr->alg = dst; + if (updated > 0) pCmpr->alg = dst; break; } } @@ -1774,7 +1774,11 @@ static int32_t mndUpdateSuperTableColumnCompress(SMnode *pMnode, const SStbObj * if (updated == 0) { terrno = TSDB_CODE_MND_COLUMN_COMPRESS_ALREADY_EXIST; return -1; + } else if (update == -1) { + terrno = TSDB_CODE_TSC_COMPRESS_LEVEL_ERROR; + return -1; } + pNew->colVer++; return 0; diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 2a122081b8..4c0091fcb7 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -2240,7 +2240,7 @@ int32_t metaUpdateTableColCompress(SMeta *pMeta, int64_t version, SVAlterTbReq * uint32_t dst = 0; updated = tUpdateCompress(p->alg, pReq->compress, TSDB_COLVAL_COMPRESS_DISABLED, TSDB_COLVAL_LEVEL_DISABLED, TSDB_COLVAL_LEVEL_MEDIUM, &dst); - if (updated) { + if (updated > 0) { p->alg = dst; } } @@ -2250,6 +2250,11 @@ int32_t metaUpdateTableColCompress(SMeta *pMeta, int64_t version, SVAlterTbReq * tDecoderClear(&dc); terrno = TSDB_CODE_VND_COLUMN_COMPRESS_ALREADY_EXIST; goto _err; + } else if (update < 0) { + tdbFree(pVal); + tDecoderClear(&dc); + terrno = TSDB_CODE_TSC_COMPRESS_LEVEL_ERROR; + goto _err; } tbEntry.version = version; diff --git a/source/util/src/tcompression.c b/source/util/src/tcompression.c index 0cc822da4c..92d8ca3313 100644 --- a/source/util/src/tcompression.c +++ b/source/util/src/tcompression.c @@ -2953,8 +2953,14 @@ int8_t tUpdateCompress(uint32_t oldCmpr, uint32_t newCmpr, uint8_t l2Disabled, u } if (nlvl != 0 && olvl != nlvl) { - SET_COMPRESS(ol1, ol2, nlvl, *dst); - update = 1; + if (update == 0) { + if (ol2 == L2_DISABLED) { + update = -1; + } + } else { + SET_COMPRESS(ol1, ol2, nlvl, *dst); + update = 1; + } } return update;