diff --git a/include/common/tcommon.h b/include/common/tcommon.h index 891c9ab040cfa6acdff55be1889a2bebe01ec2d3..37db574d98c731699e68b49c4d68108ddf1a670b 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -184,7 +184,6 @@ typedef struct SQueryTableDataCond { STimeWindow twindows; int64_t startVersion; int64_t endVersion; - int64_t schemaVersion; } SQueryTableDataCond; int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock); diff --git a/source/client/src/taosx.c b/source/client/src/taosx.c index f016120a1f5cbe1b4baf4e42f76a0fea7c80d353..cc3a2a198a6b95fe461dd6486a01cde7c526c672 100644 --- a/source/client/src/taosx.c +++ b/source/client/src/taosx.c @@ -765,6 +765,7 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) { } taosArrayPush(pRequest->tableList, &pName); + pCreateReq->flags |= TD_CREATE_IF_NOT_EXISTS; // change tag cid to new cid if(pCreateReq->type == TSDB_CHILD_TABLE){ STableMeta* pTableMeta = NULL; diff --git a/source/dnode/vnode/src/meta/metaQuery.c b/source/dnode/vnode/src/meta/metaQuery.c index 7df355a59b1a1099faf19daf13c73db3cc9ea095..c282f171163438b12a0a75aaf88f38d76e4dcb31 100644 --- a/source/dnode/vnode/src/meta/metaQuery.c +++ b/source/dnode/vnode/src/meta/metaQuery.c @@ -280,6 +280,38 @@ _query: tDecoderClear(&dc); goto _exit; } + { // Traverse to find the previous qualified data + TBC *pCur; + tdbTbcOpen(pMeta->pTbDb, &pCur, NULL); + STbDbKey key = {.version = sver, .uid = INT64_MAX}; + int c = 0; + tdbTbcMoveTo(pCur, &key, sizeof(key), &c); + if(c < 0){ + tdbTbcMoveToPrev(pCur); + } + + void *pKey = NULL; + void *pVal = NULL; + int vLen = 0, kLen = 0; + while(1){ + int32_t ret = tdbTbcPrev(pCur, &pKey, &kLen, &pVal, &vLen); + if (ret < 0) break; + + STbDbKey *tmp = (STbDbKey*)pKey; + if(tmp->uid != uid){ + continue; + } + SDecoder dcNew = {0}; + SMetaEntry meNew = {0}; + tDecoderInit(&dcNew, pVal, vLen); + metaDecodeEntry(&dcNew, &meNew); + pSchema = tCloneSSchemaWrapper(&meNew.stbEntry.schemaRow); + tDecoderClear(&dcNew); + tdbTbcClose(pCur); + goto _exit; + } + tdbTbcClose(pCur); + } } else if (me.type == TSDB_CHILD_TABLE) { uid = me.ctbEntry.suid; tDecoderClear(&dc); diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index a92e8189a1fed7a23be79ded705ad852b74b3a8c..546a20134ec5e145263745b805ab9ec2f852ced7 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -3349,10 +3349,10 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl } if (pCond->suid != 0) { - pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pReader->suid, pCond->schemaVersion); + pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pReader->suid, pCond->endVersion); } else if (taosArrayGetSize(pTableList) > 0) { STableKeyInfo* pKey = taosArrayGet(pTableList, 0); - pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pKey->uid, pCond->schemaVersion); + pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pKey->uid, pCond->endVersion); } int32_t numOfTables = taosArrayGetSize(pTableList); diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 70180d6dc0a3e4b8b84ce68c0be78eef9ffdf8bf..03fbda38532d2f136fdb60631dbce564286575b4 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -1300,7 +1300,6 @@ int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysi pCond->type = TIMEWINDOW_RANGE_CONTAINED; pCond->startVersion = -1; pCond->endVersion = -1; - pCond->schemaVersion = -1; // pCond->type = pTableScanNode->scanFlag; int32_t j = 0; diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index 278f02b2283f0e9ccc037d01f77e5956179a3627..a242db630d3ff4bec2bbdf457d179cd9d31c76dc 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -729,7 +729,6 @@ int32_t initQueryTableDataCondForTmq(SQueryTableDataCond* pCond, SSnapContext* s pCond->type = TIMEWINDOW_RANGE_CONTAINED; pCond->startVersion = -1; pCond->endVersion = sContext->snapVersion; - pCond->schemaVersion = sContext->snapVersion; for (int32_t i = 0; i < pCond->numOfCols; ++i) { pCond->colList[i].type = mtInfo.schema->pSchema[i].type; diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index b53d35a1a19a8c95962e771b4434b82ab30289cd..fd3450260aaf060867594c9a87bf39c53429fdb1 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -3908,7 +3908,6 @@ static int32_t initTableblockDistQueryCond(uint64_t uid, SQueryTableDataCond* pC pCond->type = TIMEWINDOW_RANGE_CONTAINED; pCond->startVersion = -1; pCond->endVersion = -1; - pCond->schemaVersion = -1; return TSDB_CODE_SUCCESS; }