From def7200d7caa437f6228e1e97c0e3cd4446329b4 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 18 May 2022 05:22:48 +0000 Subject: [PATCH] feat: return sver in submit rsp --- include/common/tmsg.h | 1 + source/common/src/tmsg.c | 2 ++ source/dnode/vnode/src/tsdb/tsdbMemTable.c | 8 ++++++++ 3 files changed, 11 insertions(+) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 6af4325371..3ff566afe2 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -258,6 +258,7 @@ typedef struct { char* tblFName; int32_t numOfRows; int32_t affectedRows; + int64_t sver; } SSubmitBlkRsp; typedef struct { diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index d180c2ff6e..4e97ebbe47 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -4093,6 +4093,7 @@ static int32_t tEncodeSSubmitBlkRsp(SEncoder *pEncoder, const SSubmitBlkRsp *pBl } if (tEncodeI32v(pEncoder, pBlock->numOfRows) < 0) return -1; if (tEncodeI32v(pEncoder, pBlock->affectedRows) < 0) return -1; + if (tEncodeI64v(pEncoder, pBlock->sver) < 0) return -1; tEndEncode(pEncoder); return 0; @@ -4111,6 +4112,7 @@ static int32_t tDecodeSSubmitBlkRsp(SDecoder *pDecoder, SSubmitBlkRsp *pBlock) { } if (tDecodeI32v(pDecoder, &pBlock->numOfRows) < 0) return -1; if (tDecodeI32v(pDecoder, &pBlock->affectedRows) < 0) return -1; + if (tDecodeI64v(pDecoder, &pBlock->sver) < 0) return -1; tEndDecode(pDecoder); return 0; diff --git a/source/dnode/vnode/src/tsdb/tsdbMemTable.c b/source/dnode/vnode/src/tsdb/tsdbMemTable.c index 037b099345..2fdbfdd206 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMemTable.c +++ b/source/dnode/vnode/src/tsdb/tsdbMemTable.c @@ -309,6 +309,7 @@ int tsdbInsertTableData(STsdb *pTsdb, SSubmitMsgIter *pMsgIter, SSubmitBlk *pBlo TSKEY keyMin; TSKEY keyMax; SSubmitBlk *pBlkCopy; + int64_t sverNew; // check if table exists SMetaReader mr = {0}; @@ -319,6 +320,12 @@ int tsdbInsertTableData(STsdb *pTsdb, SSubmitMsgIter *pMsgIter, SSubmitBlk *pBlo terrno = TSDB_CODE_PAR_TABLE_NOT_EXIST; return -1; } + if (mr.me.type == TSDB_NORMAL_TABLE) { + sverNew = mr.me.ntbEntry.schema.sver; + } else { + metaGetTableEntryByUid(&mr, mr.me.ctbEntry.suid); + sverNew = mr.me.stbEntry.schema.sver; + } metaReaderClear(&mr); // create container is nedd @@ -367,6 +374,7 @@ int tsdbInsertTableData(STsdb *pTsdb, SSubmitMsgIter *pMsgIter, SSubmitBlk *pBlo pRsp->numOfRows = pMsgIter->numOfRows; pRsp->affectedRows = pMsgIter->numOfRows; + pRsp->sver = sverNew; return 0; } -- GitLab