update add/drop index msg
This commit is contained in:
parent
973ebce246
commit
9586f86ceb
|
@ -346,7 +346,7 @@ 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_INDX_ON(s) (((s)->flags & 0x2) == COL_IDX_ON)
|
||||
#define IS_IDX_ON(s) (((s)->flags & 0x2) == COL_IDX_ON)
|
||||
|
||||
#define SSCHMEA_TYPE(s) ((s)->type)
|
||||
#define SSCHMEA_FLAGS(s) ((s)->flags)
|
||||
|
|
|
@ -2632,6 +2632,8 @@ static int32_t mndAddIndex(SMnode *pMnode, SRpcMsg *pReq, SCreateTagIndexReq *ta
|
|||
SField *pField0 = NULL;
|
||||
|
||||
SStbObj stbObj = {0};
|
||||
SStbObj *pNew = &stbObj;
|
||||
|
||||
taosRLockLatch(&pOld->lock);
|
||||
memcpy(&stbObj, pOld, sizeof(SStbObj));
|
||||
taosRUnLockLatch(&pOld->lock);
|
||||
|
@ -2641,6 +2643,28 @@ static int32_t mndAddIndex(SMnode *pMnode, SRpcMsg *pReq, SCreateTagIndexReq *ta
|
|||
stbObj.updateTime = taosGetTimestampMs();
|
||||
stbObj.lock = 0;
|
||||
|
||||
int32_t tag = mndFindSuperTableTagIndex(pOld, tagIdxReq->colName);
|
||||
if (tag < 0) {
|
||||
terrno = TSDB_CODE_MND_TAG_NOT_EXIST;
|
||||
return -1;
|
||||
}
|
||||
col_id_t colId = pOld->pTags[tag].colId;
|
||||
if (mndCheckColAndTagModifiable(pMnode, pOld->name, pOld->uid, colId) != 0) {
|
||||
return -1;
|
||||
}
|
||||
if (mndAllocStbSchemas(pOld, pNew) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
SSchema *pTag = pNew->pTags + tag;
|
||||
if (IS_IDX_ON(pTag)) {
|
||||
terrno = TSDB_CODE_MND_TAG_NOT_EXIST;
|
||||
return -1;
|
||||
} else {
|
||||
pTag->flags |= COL_IDX_ON;
|
||||
}
|
||||
pNew->tagVer++;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
static int32_t mndProcessCreateIndexReq(SRpcMsg *pReq) {
|
||||
|
|
|
@ -653,7 +653,7 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
|
|||
} else {
|
||||
for (int i = 0; i < pTagSchema->nCols; i++) {
|
||||
pTagColumn = &stbEntry.stbEntry.schemaTag.pSchema[i];
|
||||
if (!IS_INDX_ON(pTagColumn)) continue;
|
||||
if (!IS_IDX_ON(pTagColumn)) continue;
|
||||
STagIdxKey *pTagIdxKey = NULL;
|
||||
int32_t nTagIdxKey;
|
||||
|
||||
|
@ -1436,7 +1436,7 @@ static int metaDropTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterT
|
|||
goto _err;
|
||||
}
|
||||
|
||||
if (IS_INDX_ON(pCol)) {
|
||||
if (IS_IDX_ON(pCol)) {
|
||||
terrno = TSDB_CODE_VND_COL_ALREADY_EXISTS;
|
||||
goto _err;
|
||||
}
|
||||
|
@ -1664,7 +1664,7 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
|
|||
} else {
|
||||
for (int i = 0; i < pTagSchema->nCols; i++) {
|
||||
pTagColumn = &pTagSchema->pSchema[i];
|
||||
if (!IS_INDX_ON(pTagColumn)) continue;
|
||||
if (!IS_IDX_ON(pTagColumn)) continue;
|
||||
|
||||
STagVal tagVal = {.cid = pTagColumn->colId};
|
||||
tTagGet((const STag *)pCtbEntry->ctbEntry.pTags, &tagVal);
|
||||
|
|
Loading…
Reference in New Issue