diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index c37cecc06d95bb8a7f369f481ca8144d2cda478b..2cc22a42981ca7882532042dd57590a0ffa427b4 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -100,6 +100,7 @@ int32_t metaReadNext(SMetaReader *pReader); const void *metaGetTableTagVal(void *tag, int16_t type, STagVal *tagVal); int metaGetTableNameByUid(void *meta, uint64_t uid, char *tbName); int metaGetTableUidByName(void *meta, char *tbName, uint64_t *uid); +int metaGetTableTypeByName(void *meta, char *tbName, ETableType *tbType); bool metaIsTableExist(SMeta *pMeta, tb_uid_t uid); typedef struct SMetaFltParam { diff --git a/source/dnode/vnode/src/meta/metaQuery.c b/source/dnode/vnode/src/meta/metaQuery.c index a20bae8a2dc138ef82a72eaf406a300f3cfaac0d..d499db4958e2d5423128eb366b13081029b0ec6f 100644 --- a/source/dnode/vnode/src/meta/metaQuery.c +++ b/source/dnode/vnode/src/meta/metaQuery.c @@ -223,6 +223,18 @@ int metaGetTableUidByName(void *meta, char *tbName, uint64_t *uid) { return 0; } +int metaGetTableTypeByName(void *meta, char *tbName, ETableType *tbType) { + int code = 0; + SMetaReader mr = {0}; + metaReaderInit(&mr, (SMeta *)meta, 0); + + if (metaGetTableEntryByName(&mr, tbName) == 0) { + *tbType = mr.me.type; + } + metaReaderClear(&mr); + return 0; +} + int metaReadNext(SMetaReader *pReader) { SMeta *pMeta = pReader->pMeta; @@ -1130,7 +1142,8 @@ int32_t metaGetTableTagsOpt(SMeta *pMeta, uint64_t suid, SArray *uidList, SHashO void *val = NULL; int32_t len = 0; - if (0 == tdbTbGet(pMeta->pCtbIdx, &ctbIdxKey, sizeof(SCtbIdxKey), &val, &len)) { + if (taosHashGet(tags, id, sizeof(tb_uid_t)) == NULL && + 0 == tdbTbGet(pMeta->pCtbIdx, &ctbIdxKey, sizeof(SCtbIdxKey), &val, &len)) { taosHashPut(tags, id, sizeof(tb_uid_t), val, len); } } diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 82ee6265f8f26ceb77b9f5bc65c2baa76cefdd64..38304bcc76ed03fb80af23aa9b29be1b1c8a89e1 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -823,7 +823,13 @@ static int32_t optimizeTbnameInCondImpl(void* metaHandle, int64_t suid, SArray* char* name = taosArrayGetP(pTbList, i); uint64_t uid = 0; if (metaGetTableUidByName(metaHandle, name, &uid) == 0) { - taosArrayPush(list, &uid); + ETableType tbType = TSDB_TABLE_MAX; + if (metaGetTableTypeByName(metaHandle, name, &tbType) == 0 && tbType == TSDB_CHILD_TABLE) { + taosArrayPush(list, &uid); + } else { + taosArrayDestroy(pTbList); + return -1; + } } else { qWarn("failed to get tableIds from by table name: %s, reason: %s", name, tstrerror(terrno)); terrno = 0;