diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 9e46002936..b78598a3f6 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -358,9 +358,19 @@ void tFreeSSubmitRsp(SSubmitRsp* pRsp); #define COL_CLR_SET(FLG) ((FLG) &= (~(COL_SET_VAL | COL_SET_NULL))) #define IS_BSMA_ON(s) (((s)->flags & 0x01) == COL_SMA_ON) -#define IS_IDX_ON(s) (((s)->flags & 0x2) == COL_IDX_ON) +#define IS_IDX_ON(s) (((s)->flags & 0x02) == COL_IDX_ON) #define IS_SET_NULL(s) (((s)->flags & COL_SET_NULL) == COL_SET_NULL) +#define SSCHMEA_SET_IDX_ON(s) \ + do { \ + (s)->flags |= COL_IDX_ON; \ + } while (0) + +#define SSCHMEA_SET_IDX_OFF(s) \ + do { \ + (s)->flags &= (~COL_IDX_ON); \ + } while (0) + #define SSCHMEA_TYPE(s) ((s)->type) #define SSCHMEA_FLAGS(s) ((s)->flags) #define SSCHMEA_COLID(s) ((s)->colId) diff --git a/source/dnode/mnode/impl/src/mndIndex.c b/source/dnode/mnode/impl/src/mndIndex.c index f5eee32e66..49d2bf439d 100644 --- a/source/dnode/mnode/impl/src/mndIndex.c +++ b/source/dnode/mnode/impl/src/mndIndex.c @@ -595,12 +595,13 @@ static int32_t mndSetUpdateIdxStbCommitLogs(SMnode *pMnode, STrans *pTrans, SStb terrno = TSDB_CODE_MND_TAG_INDEX_ALREADY_EXIST; return -1; } else { - pTag->flags |= COL_IDX_ON; + SSCHMEA_SET_IDX_ON(pTag); } } else { if (!IS_IDX_ON(pTag)) { terrno = TSDB_CODE_MND_SMA_NOT_EXIST; } else { + SSCHMEA_SET_IDX_OFF(pTag); pTag->flags = 0; } } diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 969a628dca..24d837ae22 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -809,6 +809,9 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat SSchema *pSchema = &pDst->pTags[i]; pSchema->type = pField->type; pSchema->bytes = pField->bytes; + if (i == 0) { + SSCHMEA_SET_IDX_ON(pSchema) + } memcpy(pSchema->name, pField->name, TSDB_COL_NAME_LEN); pSchema->colId = pDst->nextColId; pDst->nextColId++; @@ -2227,9 +2230,7 @@ static int32_t mndCheckDropStbForStream(SMnode *pMnode, const char *stbFullName, return 0; } -static int32_t mndProcessDropTtltbReq(SRpcMsg *pRsp) { - return 0; -} +static int32_t mndProcessDropTtltbReq(SRpcMsg *pRsp) { return 0; } static int32_t mndProcessDropStbReq(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 591cdc0ccc..94aa464354 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -652,7 +652,7 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq) } // clear idx flag - pCol->flags = 0; + SSCHMEA_SET_IDX_OFF(pCol); nStbEntry.version = version; nStbEntry.type = TSDB_SUPER_TABLE;