opt sys query
This commit is contained in:
parent
54c7d6cbb9
commit
f612eafee8
|
@ -1106,8 +1106,41 @@ int32_t metaFilterTableName(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
|
||||||
pCursor->cid = param->cid;
|
pCursor->cid = param->cid;
|
||||||
pCursor->type = param->type;
|
pCursor->type = param->type;
|
||||||
|
|
||||||
|
char *pName = param->val;
|
||||||
|
|
||||||
metaRLock(pMeta);
|
metaRLock(pMeta);
|
||||||
ret = tdbTbcOpen(pMeta->pNameIdx, &pCursor->pCur, NULL);
|
ret = tdbTbcOpen(pMeta->pNameIdx, &pCursor->pCur, NULL);
|
||||||
|
if (ret != 0) {
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
int cmp = 0;
|
||||||
|
if (tdbTbcMoveTo(pCursor->pCur, pName, strlen(pName) + 1, &cmp) < 0) {
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
bool first = true;
|
||||||
|
int32_t valid = 0;
|
||||||
|
while (1) {
|
||||||
|
void *pEntryKey = NULL, *pEntryVal = NULL;
|
||||||
|
int32_t nEntryKey = -1, nEntryVal = 0;
|
||||||
|
valid = tdbTbcGet(pCursor->pCur, (const void **)pEntryKey, &nEntryKey, (const void **)&pEntryVal, &nEntryVal);
|
||||||
|
if (valid < 0) break;
|
||||||
|
|
||||||
|
char *pTableKey = (char *)pEntryKey;
|
||||||
|
int32_t cmp = (*param->filterFunc)(pTableKey, pName, pCursor->type);
|
||||||
|
if (cmp == 0) {
|
||||||
|
tb_uid_t tuid = *(tb_uid_t *)pEntryVal;
|
||||||
|
taosArrayPush(pUids, &tuid);
|
||||||
|
} else if (cmp == 1) {
|
||||||
|
// next
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
valid = param->reverse ? tdbTbcMoveToPrev(pCursor->pCur) : tdbTbcMoveToNext(pCursor->pCur);
|
||||||
|
if (valid < 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
END:
|
END:
|
||||||
if (pCursor->pMeta) metaULock(pCursor->pMeta);
|
if (pCursor->pMeta) metaULock(pCursor->pMeta);
|
||||||
|
@ -1215,6 +1248,7 @@ int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
|
||||||
|
|
||||||
valid = tdbTbcGet(pCursor->pCur, (const void **)&entryKey, &nEntryKey, (const void **)&entryVal, &nEntryVal);
|
valid = tdbTbcGet(pCursor->pCur, (const void **)&entryKey, &nEntryKey, (const void **)&entryVal, &nEntryVal);
|
||||||
if (valid < 0) {
|
if (valid < 0) {
|
||||||
|
tdbFree(entryVal);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
STagIdxKey *p = entryKey;
|
STagIdxKey *p = entryKey;
|
||||||
|
|
|
@ -3213,25 +3213,9 @@ static int32_t optSysTabFilte(void* arg, SNode* cond, SArray* result) {
|
||||||
return hasIdx == true ? 0 : -1;
|
return hasIdx == true ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSDataBlock* sysTableScanUserTables(SOperatorInfo* pOperator) {
|
static SSDataBlock* sysTableBuildUserTables(SOperatorInfo* pOperator) {
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
SSysTableScanInfo* pInfo = pOperator->info;
|
SSysTableScanInfo* pInfo = pOperator->info;
|
||||||
|
|
||||||
SNode* pCondtion = pInfo->pCondition;
|
|
||||||
if (pOperator->status == OP_EXEC_DONE) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// the retrieve is executed on the mnode, so return tables that belongs to the information schema database.
|
|
||||||
if (pInfo->readHandle.mnd != NULL) {
|
|
||||||
buildSysDbTableInfo(pInfo, pOperator->resultInfo.capacity);
|
|
||||||
|
|
||||||
doFilterResult(pInfo);
|
|
||||||
pInfo->loadInfo.totalRows += pInfo->pRes->info.rows;
|
|
||||||
|
|
||||||
doSetOperatorCompleted(pOperator);
|
|
||||||
return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes;
|
|
||||||
} else {
|
|
||||||
if (pInfo->pCur == NULL) {
|
if (pInfo->pCur == NULL) {
|
||||||
pInfo->pCur = metaOpenTbCursor(pInfo->readHandle.meta);
|
pInfo->pCur = metaOpenTbCursor(pInfo->readHandle.meta);
|
||||||
}
|
}
|
||||||
|
@ -3405,6 +3389,32 @@ static SSDataBlock* sysTableScanUserTables(SOperatorInfo* pOperator) {
|
||||||
pInfo->loadInfo.totalRows += pInfo->pRes->info.rows;
|
pInfo->loadInfo.totalRows += pInfo->pRes->info.rows;
|
||||||
return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes;
|
return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes;
|
||||||
}
|
}
|
||||||
|
static SSDataBlock* sysTableScanUserTables(SOperatorInfo* pOperator) {
|
||||||
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
SSysTableScanInfo* pInfo = pOperator->info;
|
||||||
|
|
||||||
|
SNode* pCondition = pInfo->pCondition;
|
||||||
|
if (pOperator->status == OP_EXEC_DONE) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// the retrieve is executed on the mnode, so return tables that belongs to the information schema database.
|
||||||
|
if (pInfo->readHandle.mnd != NULL) {
|
||||||
|
buildSysDbTableInfo(pInfo, pOperator->resultInfo.capacity);
|
||||||
|
|
||||||
|
doFilterResult(pInfo);
|
||||||
|
pInfo->loadInfo.totalRows += pInfo->pRes->info.rows;
|
||||||
|
|
||||||
|
doSetOperatorCompleted(pOperator);
|
||||||
|
return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes;
|
||||||
|
} else {
|
||||||
|
if (pCondition != NULL) {
|
||||||
|
return NULL;
|
||||||
|
} else {
|
||||||
|
return sysTableBuildUserTables(pOperator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSDataBlock* sysTableScanUserSTables(SOperatorInfo* pOperator) {
|
static SSDataBlock* sysTableScanUserSTables(SOperatorInfo* pOperator) {
|
||||||
|
|
Loading…
Reference in New Issue