Merge pull request #16207 from taosdata/feature/3.0_query_optimize
fix: get meta null if table does not exists
This commit is contained in:
commit
1a5ae2bfdf
|
@ -96,6 +96,7 @@ int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList, SHash
|
||||||
int32_t metaReadNext(SMetaReader *pReader);
|
int32_t metaReadNext(SMetaReader *pReader);
|
||||||
const void *metaGetTableTagVal(void *tag, int16_t type, STagVal *tagVal);
|
const void *metaGetTableTagVal(void *tag, int16_t type, STagVal *tagVal);
|
||||||
int metaGetTableNameByUid(void *meta, uint64_t uid, char *tbName);
|
int metaGetTableNameByUid(void *meta, uint64_t uid, char *tbName);
|
||||||
|
bool metaIsTableExist(SMeta *pMeta, tb_uid_t uid);
|
||||||
|
|
||||||
typedef struct SMetaFltParam {
|
typedef struct SMetaFltParam {
|
||||||
tb_uid_t suid;
|
tb_uid_t suid;
|
||||||
|
|
|
@ -127,6 +127,15 @@ _err:
|
||||||
// return 0;
|
// return 0;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
bool metaIsTableExist(SMeta *pMeta, tb_uid_t uid) {
|
||||||
|
// query uid.idx
|
||||||
|
if (tdbTbGet(pMeta->pUidIdx, &uid, sizeof(uid), NULL, NULL) < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int metaGetTableEntryByUid(SMetaReader *pReader, tb_uid_t uid) {
|
int metaGetTableEntryByUid(SMetaReader *pReader, tb_uid_t uid) {
|
||||||
SMeta *pMeta = pReader->pMeta;
|
SMeta *pMeta = pReader->pMeta;
|
||||||
int64_t version;
|
int64_t version;
|
||||||
|
|
|
@ -533,7 +533,9 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode,
|
||||||
vnodeGetCtbIdList(pVnode, pScanNode->suid, res);
|
vnodeGetCtbIdList(pVnode, pScanNode->suid, res);
|
||||||
}
|
}
|
||||||
} else { // Create one table group.
|
} else { // Create one table group.
|
||||||
taosArrayPush(res, &tableUid);
|
if(metaIsTableExist(metaHandle, tableUid)){
|
||||||
|
taosArrayPush(res, &tableUid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTagCond) {
|
if (pTagCond) {
|
||||||
|
@ -599,7 +601,10 @@ size_t getTableTagsBufLen(const SNodeList* pGroups) {
|
||||||
int32_t getGroupIdFromTagsVal(void* pMeta, uint64_t uid, SNodeList* pGroupNode, char* keyBuf, uint64_t* pGroupId) {
|
int32_t getGroupIdFromTagsVal(void* pMeta, uint64_t uid, SNodeList* pGroupNode, char* keyBuf, uint64_t* pGroupId) {
|
||||||
SMetaReader mr = {0};
|
SMetaReader mr = {0};
|
||||||
metaReaderInit(&mr, pMeta, 0);
|
metaReaderInit(&mr, pMeta, 0);
|
||||||
metaGetTableEntryByUid(&mr, uid);
|
if(metaGetTableEntryByUid(&mr, uid) != 0){ // table not exist
|
||||||
|
metaReaderClear(&mr);
|
||||||
|
return TSDB_CODE_PAR_TABLE_NOT_EXIST;
|
||||||
|
}
|
||||||
|
|
||||||
SNodeList* groupNew = nodesCloneList(pGroupNode);
|
SNodeList* groupNew = nodesCloneList(pGroupNode);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue