From c589835bf45f7ee402d6c81eaf52826beb9ea32f Mon Sep 17 00:00:00 2001 From: xywang Date: Tue, 28 Sep 2021 01:21:42 +0800 Subject: [PATCH] [TS-401]: fixed bug that update didn't work in some conditions --- src/client/src/tscParseInsert.c | 8 ++++++++ src/client/src/tscUtil.c | 1 + src/inc/taosmsg.h | 1 + src/mnode/src/mnodeTable.c | 2 ++ src/query/inc/qTableMeta.h | 1 + src/query/src/qTableMeta.c | 1 + 6 files changed, 14 insertions(+) diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index 1bf27e6cad..de512c457c 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -771,6 +771,10 @@ void tscSortRemoveDataBlockDupRowsRaw(STableDataBlocks *dataBuf) { TSKEY tj = *(TSKEY *)(pBlockData + dataBuf->rowSize * j); if (ti == tj) { + if (dataBuf->pTableMeta && dataBuf->pTableMeta->tableInfo.update != TD_ROW_DISCARD_UPDATE) { + memmove(pBlockData + dataBuf->rowSize * i, pBlockData + dataBuf->rowSize * j, dataBuf->rowSize); + } + ++j; continue; } @@ -841,6 +845,10 @@ int tscSortRemoveDataBlockDupRows(STableDataBlocks *dataBuf, SBlockKeyInfo *pBlk TSKEY tj = (pBlkKeyTuple + j)->skey; if (ti == tj) { + if (dataBuf->pTableMeta && dataBuf->pTableMeta->tableInfo.update != TD_ROW_DISCARD_UPDATE) { + memmove(pBlkKeyTuple + i, pBlkKeyTuple + j, sizeof(SBlockKeyTuple)); + } + ++j; continue; } diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 04d1472bb0..56a9e6f612 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -4509,6 +4509,7 @@ STableMeta* createSuperTableMeta(STableMetaMsg* pChild) { pTableMeta->tableInfo.numOfTags = pChild->numOfTags; pTableMeta->tableInfo.numOfColumns = pChild->numOfColumns; pTableMeta->tableInfo.precision = pChild->precision; + pTableMeta->tableInfo.update = pChild->update; pTableMeta->id.tid = 0; pTableMeta->id.uid = pChild->suid; diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index c3c8625fec..2c35767606 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -780,6 +780,7 @@ typedef struct STableMetaMsg { char tableFname[TSDB_TABLE_FNAME_LEN]; // table id uint8_t numOfTags; uint8_t precision; + uint8_t update; uint8_t tableType; int16_t numOfColumns; int16_t sversion; diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index a6158906a7..6cbb50cf3f 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -1792,6 +1792,7 @@ static int32_t mnodeDoGetSuperTableMeta(SMnodeMsg *pMsg, STableMetaMsg* pMeta) { pMeta->sversion = htons(pTable->sversion); pMeta->tversion = htons(pTable->tversion); pMeta->precision = pMsg->pDb->cfg.precision; + pMeta->update = pMsg->pDb->cfg.update; pMeta->numOfTags = (uint8_t)pTable->numOfTags; pMeta->numOfColumns = htons((int16_t)pTable->numOfColumns); pMeta->tableType = pTable->info.type; @@ -2509,6 +2510,7 @@ static int32_t mnodeDoGetChildTableMeta(SMnodeMsg *pMsg, STableMetaMsg *pMeta) { pMeta->uid = htobe64(pTable->uid); pMeta->tid = htonl(pTable->tid); pMeta->precision = pDb->cfg.precision; + pMeta->update = pDb->cfg.update; pMeta->tableType = pTable->info.type; tstrncpy(pMeta->tableFname, pTable->info.tableId, TSDB_TABLE_FNAME_LEN); diff --git a/src/query/inc/qTableMeta.h b/src/query/inc/qTableMeta.h index 948a1ae91e..3fb489f17e 100644 --- a/src/query/inc/qTableMeta.h +++ b/src/query/inc/qTableMeta.h @@ -56,6 +56,7 @@ typedef struct SGroupbyExpr { typedef struct STableComInfo { uint8_t numOfTags; uint8_t precision; + uint8_t update; int16_t numOfColumns; int32_t rowSize; } STableComInfo; diff --git a/src/query/src/qTableMeta.c b/src/query/src/qTableMeta.c index f687b8aa1f..f786f4438c 100644 --- a/src/query/src/qTableMeta.c +++ b/src/query/src/qTableMeta.c @@ -84,6 +84,7 @@ STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg) { pTableMeta->tableInfo = (STableComInfo) { .numOfTags = pTableMetaMsg->numOfTags, .precision = pTableMetaMsg->precision, + .update = pTableMetaMsg->update, .numOfColumns = pTableMetaMsg->numOfColumns, }; -- GitLab