Merge pull request #13567 from taosdata/feature/3_liaohj_wxy

fix: a problem of parser async
This commit is contained in:
Xiaoyu Wang 2022-06-07 17:15:26 +08:00 committed by GitHub
commit 01a0194f4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 118 additions and 157 deletions

View File

@ -108,7 +108,7 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt);
static EDealRes collectMetaKeyFromFunction(SCollectMetaKeyFromExprCxt* pCxt, SFunctionNode* pFunc) { static EDealRes collectMetaKeyFromFunction(SCollectMetaKeyFromExprCxt* pCxt, SFunctionNode* pFunc) {
if (fmIsBuiltinFunc(pFunc->functionName)) { if (fmIsBuiltinFunc(pFunc->functionName)) {
return TSDB_CODE_SUCCESS; return DEAL_RES_CONTINUE;
} }
pCxt->errCode = reserveUdfInCache(pFunc->functionName, pCxt->pComCxt->pMetaCache); pCxt->errCode = reserveUdfInCache(pFunc->functionName, pCxt->pComCxt->pMetaCache);
return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_CONTINUE : DEAL_RES_ERROR; return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_CONTINUE : DEAL_RES_ERROR;

View File

@ -482,20 +482,6 @@ static int32_t buildDbReq(SHashObj* pDbsHash, SArray** pDbs) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static int32_t buildTableMetaReq(SHashObj* pTableMetaHash, SArray** pTableMeta) {
return buildTableReq(pTableMetaHash, pTableMeta);
}
static int32_t buildDbVgroupReq(SHashObj* pDbVgroupHash, SArray** pDbVgroup) {
return buildDbReq(pDbVgroupHash, pDbVgroup);
}
static int32_t buildTableVgroupReq(SHashObj* pTableVgroupHash, SArray** pTableVgroup) {
return buildTableReq(pTableVgroupHash, pTableVgroup);
}
static int32_t buildDbCfgReq(SHashObj* pDbCfgHash, SArray** pDbCfg) { return buildDbReq(pDbCfgHash, pDbCfg); }
static int32_t buildUserAuthReq(SHashObj* pUserAuthHash, SArray** pUserAuth) { static int32_t buildUserAuthReq(SHashObj* pUserAuthHash, SArray** pUserAuth) {
if (NULL != pUserAuthHash) { if (NULL != pUserAuthHash) {
*pUserAuth = taosArrayInit(taosHashGetSize(pUserAuthHash), sizeof(SUserAuthInfo)); *pUserAuth = taosArrayInit(taosHashGetSize(pUserAuthHash), sizeof(SUserAuthInfo));
@ -535,15 +521,18 @@ static int32_t buildUdfReq(SHashObj* pUdfHash, SArray** pUdf) {
} }
int32_t buildCatalogReq(const SParseMetaCache* pMetaCache, SCatalogReq* pCatalogReq) { int32_t buildCatalogReq(const SParseMetaCache* pMetaCache, SCatalogReq* pCatalogReq) {
int32_t code = buildTableMetaReq(pMetaCache->pTableMeta, &pCatalogReq->pTableMeta); int32_t code = buildTableReq(pMetaCache->pTableMeta, &pCatalogReq->pTableMeta);
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = buildDbVgroupReq(pMetaCache->pDbVgroup, &pCatalogReq->pDbVgroup); code = buildDbReq(pMetaCache->pDbVgroup, &pCatalogReq->pDbVgroup);
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = buildTableVgroupReq(pMetaCache->pTableVgroup, &pCatalogReq->pTableHash); code = buildTableReq(pMetaCache->pTableVgroup, &pCatalogReq->pTableHash);
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = buildDbCfgReq(pMetaCache->pDbCfg, &pCatalogReq->pDbCfg); code = buildDbReq(pMetaCache->pDbCfg, &pCatalogReq->pDbCfg);
}
if (TSDB_CODE_SUCCESS == code) {
code = buildDbReq(pMetaCache->pDbInfo, &pCatalogReq->pDbInfo);
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = buildUserAuthReq(pMetaCache->pUserAuth, &pCatalogReq->pUser); code = buildUserAuthReq(pMetaCache->pUserAuth, &pCatalogReq->pUser);
@ -554,51 +543,39 @@ int32_t buildCatalogReq(const SParseMetaCache* pMetaCache, SCatalogReq* pCatalog
return code; return code;
} }
static int32_t putTableMetaToCache(const SArray* pTableMetaReq, const SArray* pTableMetaData, SHashObj* pTableMeta) { static int32_t putMetaDataToHash(const char* pKey, int32_t len, const SArray* pData, int32_t index, SHashObj* pHash) {
int32_t ntables = taosArrayGetSize(pTableMetaReq); SMetaRes* pRes = taosArrayGet(pData, index);
return taosHashPut(pHash, pKey, len, &pRes, POINTER_BYTES);
}
static int32_t getMetaDataFromHash(const char* pKey, int32_t len, SHashObj* pHash, void** pOutput) {
SMetaRes** pRes = taosHashGet(pHash, pKey, len);
if (NULL == pRes || NULL == *pRes) {
return TSDB_CODE_PAR_INTERNAL_ERROR;
}
if (TSDB_CODE_SUCCESS == (*pRes)->code) {
*pOutput = (*pRes)->pRes;
}
return (*pRes)->code;
}
static int32_t putTableDataToCache(const SArray* pTableReq, const SArray* pTableData, SHashObj* pTable) {
int32_t ntables = taosArrayGetSize(pTableReq);
for (int32_t i = 0; i < ntables; ++i) { for (int32_t i = 0; i < ntables; ++i) {
char fullName[TSDB_TABLE_FNAME_LEN]; char fullName[TSDB_TABLE_FNAME_LEN];
tNameExtractFullName(taosArrayGet(pTableMetaReq, i), fullName); tNameExtractFullName(taosArrayGet(pTableReq, i), fullName);
if (TSDB_CODE_SUCCESS != if (TSDB_CODE_SUCCESS != putMetaDataToHash(fullName, strlen(fullName), pTableData, i, pTable)) {
taosHashPut(pTableMeta, fullName, strlen(fullName), taosArrayGet(pTableMetaData, i), POINTER_BYTES)) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
} }
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static int32_t putDbVgroupToCache(const SArray* pDbVgroupReq, const SArray* pDbVgroupData, SHashObj* pDbVgroup) { static int32_t putDbDataToCache(const SArray* pDbReq, const SArray* pDbData, SHashObj* pDb) {
int32_t nvgs = taosArrayGetSize(pDbVgroupReq); int32_t nvgs = taosArrayGetSize(pDbReq);
for (int32_t i = 0; i < nvgs; ++i) { for (int32_t i = 0; i < nvgs; ++i) {
char* pDbFName = taosArrayGet(pDbVgroupReq, i); char* pDbFName = taosArrayGet(pDbReq, i);
if (TSDB_CODE_SUCCESS != if (TSDB_CODE_SUCCESS != putMetaDataToHash(pDbFName, strlen(pDbFName), pDbData, i, pDb)) {
taosHashPut(pDbVgroup, pDbFName, strlen(pDbFName), taosArrayGet(pDbVgroupData, i), POINTER_BYTES)) {
return TSDB_CODE_OUT_OF_MEMORY;
}
}
return TSDB_CODE_SUCCESS;
}
static int32_t putTableVgroupToCache(const SArray* pTableVgroupReq, const SArray* pTableVgroupData,
SHashObj* pTableVgroup) {
int32_t ntables = taosArrayGetSize(pTableVgroupReq);
for (int32_t i = 0; i < ntables; ++i) {
char fullName[TSDB_TABLE_FNAME_LEN];
tNameExtractFullName(taosArrayGet(pTableVgroupReq, i), fullName);
SVgroupInfo* pInfo = taosArrayGet(pTableVgroupData, i);
if (TSDB_CODE_SUCCESS != taosHashPut(pTableVgroup, fullName, strlen(fullName), &pInfo, POINTER_BYTES)) {
return TSDB_CODE_OUT_OF_MEMORY;
}
}
return TSDB_CODE_SUCCESS;
}
static int32_t putDbCfgToCache(const SArray* pDbCfgReq, const SArray* pDbCfgData, SHashObj* pDbCfg) {
int32_t nvgs = taosArrayGetSize(pDbCfgReq);
for (int32_t i = 0; i < nvgs; ++i) {
char* pDbFName = taosArrayGet(pDbCfgReq, i);
SDbCfgInfo* pInfo = taosArrayGet(pDbCfgData, i);
if (TSDB_CODE_SUCCESS != taosHashPut(pDbCfg, pDbFName, strlen(pDbFName), &pInfo, POINTER_BYTES)) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
} }
@ -611,7 +588,7 @@ static int32_t putUserAuthToCache(const SArray* pUserAuthReq, const SArray* pUse
SUserAuthInfo* pUser = taosArrayGet(pUserAuthReq, i); SUserAuthInfo* pUser = taosArrayGet(pUserAuthReq, i);
char key[USER_AUTH_KEY_MAX_LEN] = {0}; char key[USER_AUTH_KEY_MAX_LEN] = {0};
int32_t len = userAuthToStringExt(pUser->user, pUser->dbFName, pUser->type, key); int32_t len = userAuthToStringExt(pUser->user, pUser->dbFName, pUser->type, key);
if (TSDB_CODE_SUCCESS != taosHashPut(pUserAuth, key, len, taosArrayGet(pUserAuthData, i), sizeof(bool))) { if (TSDB_CODE_SUCCESS != putMetaDataToHash(key, len, pUserAuthData, i, pUserAuth)) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
} }
@ -621,9 +598,8 @@ static int32_t putUserAuthToCache(const SArray* pUserAuthReq, const SArray* pUse
static int32_t putUdfToCache(const SArray* pUdfReq, const SArray* pUdfData, SHashObj* pUdf) { static int32_t putUdfToCache(const SArray* pUdfReq, const SArray* pUdfData, SHashObj* pUdf) {
int32_t num = taosArrayGetSize(pUdfReq); int32_t num = taosArrayGetSize(pUdfReq);
for (int32_t i = 0; i < num; ++i) { for (int32_t i = 0; i < num; ++i) {
char* pFunc = taosArrayGet(pUdfReq, i); char* pFunc = taosArrayGet(pUdfReq, i);
SFuncInfo* pInfo = taosArrayGet(pUdfData, i); if (TSDB_CODE_SUCCESS != putMetaDataToHash(pFunc, strlen(pFunc), pUdfData, i, pUdf)) {
if (TSDB_CODE_SUCCESS != taosHashPut(pUdf, pFunc, strlen(pFunc), &pInfo, POINTER_BYTES)) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
} }
@ -631,15 +607,18 @@ static int32_t putUdfToCache(const SArray* pUdfReq, const SArray* pUdfData, SHas
} }
int32_t putMetaDataToCache(const SCatalogReq* pCatalogReq, const SMetaData* pMetaData, SParseMetaCache* pMetaCache) { int32_t putMetaDataToCache(const SCatalogReq* pCatalogReq, const SMetaData* pMetaData, SParseMetaCache* pMetaCache) {
int32_t code = putTableMetaToCache(pCatalogReq->pTableMeta, pMetaData->pTableMeta, pMetaCache->pTableMeta); int32_t code = putTableDataToCache(pCatalogReq->pTableMeta, pMetaData->pTableMeta, pMetaCache->pTableMeta);
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = putDbVgroupToCache(pCatalogReq->pDbVgroup, pMetaData->pDbVgroup, pMetaCache->pDbVgroup); code = putDbDataToCache(pCatalogReq->pDbVgroup, pMetaData->pDbVgroup, pMetaCache->pDbVgroup);
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = putTableVgroupToCache(pCatalogReq->pTableHash, pMetaData->pTableHash, pMetaCache->pTableVgroup); code = putTableDataToCache(pCatalogReq->pTableHash, pMetaData->pTableHash, pMetaCache->pTableVgroup);
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = putDbCfgToCache(pCatalogReq->pDbCfg, pMetaData->pDbCfg, pMetaCache->pDbCfg); code = putDbDataToCache(pCatalogReq->pDbCfg, pMetaData->pDbCfg, pMetaCache->pDbCfg);
}
if (TSDB_CODE_SUCCESS == code) {
code = putDbDataToCache(pCatalogReq->pDbInfo, pMetaData->pDbInfo, pMetaCache->pDbInfo);
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = putUserAuthToCache(pCatalogReq->pUser, pMetaData->pUser, pMetaCache->pUserAuth); code = putUserAuthToCache(pCatalogReq->pUser, pMetaData->pUser, pMetaCache->pUserAuth);
@ -679,16 +658,15 @@ int32_t reserveTableMetaInCacheExt(const SName* pName, SParseMetaCache* pMetaCac
int32_t getTableMetaFromCache(SParseMetaCache* pMetaCache, const SName* pName, STableMeta** pMeta) { int32_t getTableMetaFromCache(SParseMetaCache* pMetaCache, const SName* pName, STableMeta** pMeta) {
char fullName[TSDB_TABLE_FNAME_LEN]; char fullName[TSDB_TABLE_FNAME_LEN];
tNameExtractFullName(pName, fullName); tNameExtractFullName(pName, fullName);
STableMeta** pRes = taosHashGet(pMetaCache->pTableMeta, fullName, strlen(fullName)); STableMeta* pTableMeta = NULL;
if (NULL == pRes || NULL == *pRes) { int32_t code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pTableMeta, (void**)&pTableMeta);
parserError("getTableMetaFromCache error: %s", fullName); if (TSDB_CODE_SUCCESS == code) {
return TSDB_CODE_PAR_INTERNAL_ERROR; *pMeta = tableMetaDup(pTableMeta);
if (NULL == *pMeta) {
code = TSDB_CODE_OUT_OF_MEMORY;
}
} }
*pMeta = tableMetaDup(*pRes); return code;
if (NULL == *pMeta) {
return TSDB_CODE_OUT_OF_MEMORY;
}
return TSDB_CODE_SUCCESS;
} }
static int32_t reserveDbReqInCache(int32_t acctId, const char* pDb, SHashObj** pDbs) { static int32_t reserveDbReqInCache(int32_t acctId, const char* pDb, SHashObj** pDbs) {
@ -708,19 +686,16 @@ int32_t reserveDbVgInfoInCache(int32_t acctId, const char* pDb, SParseMetaCache*
} }
int32_t getDbVgInfoFromCache(SParseMetaCache* pMetaCache, const char* pDbFName, SArray** pVgInfo) { int32_t getDbVgInfoFromCache(SParseMetaCache* pMetaCache, const char* pDbFName, SArray** pVgInfo) {
SArray** pRes = taosHashGet(pMetaCache->pDbVgroup, pDbFName, strlen(pDbFName)); SArray* pVgList = NULL;
if (NULL == pRes) { int32_t code = getMetaDataFromHash(pDbFName, strlen(pDbFName), pMetaCache->pDbVgroup, (void**)&pVgList);
parserError("getDbVgInfoFromCache error: %s", pDbFName); // pVgList is null, which is a legal value, indicating that the user DB has not been created
return TSDB_CODE_PAR_INTERNAL_ERROR; if (TSDB_CODE_SUCCESS == code && NULL != pVgList) {
} *pVgInfo = taosArrayDup(pVgList);
// *pRes is null, which is a legal value, indicating that the user DB has not been created
if (NULL != *pRes) {
*pVgInfo = taosArrayDup(*pRes);
if (NULL == *pVgInfo) { if (NULL == *pVgInfo) {
return TSDB_CODE_OUT_OF_MEMORY; code = TSDB_CODE_OUT_OF_MEMORY;
} }
} }
return TSDB_CODE_SUCCESS; return code;
} }
int32_t reserveTableVgroupInCache(int32_t acctId, const char* pDb, const char* pTable, SParseMetaCache* pMetaCache) { int32_t reserveTableVgroupInCache(int32_t acctId, const char* pDb, const char* pTable, SParseMetaCache* pMetaCache) {
@ -736,30 +711,28 @@ int32_t reserveTableVgroupInCacheExt(const SName* pName, SParseMetaCache* pMetaC
int32_t getTableVgroupFromCache(SParseMetaCache* pMetaCache, const SName* pName, SVgroupInfo* pVgroup) { int32_t getTableVgroupFromCache(SParseMetaCache* pMetaCache, const SName* pName, SVgroupInfo* pVgroup) {
char fullName[TSDB_TABLE_FNAME_LEN]; char fullName[TSDB_TABLE_FNAME_LEN];
tNameExtractFullName(pName, fullName); tNameExtractFullName(pName, fullName);
SVgroupInfo** pRes = taosHashGet(pMetaCache->pTableVgroup, fullName, strlen(fullName)); SVgroupInfo* pVg = NULL;
if (NULL == pRes || NULL == *pRes) { int32_t code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pTableVgroup, (void**)&pVg);
parserError("getTableVgroupFromCache error: %s", fullName); if (TSDB_CODE_SUCCESS == code) {
return TSDB_CODE_PAR_INTERNAL_ERROR; memcpy(pVgroup, pVg, sizeof(SVgroupInfo));
} }
memcpy(pVgroup, *pRes, sizeof(SVgroupInfo)); return code;
return TSDB_CODE_SUCCESS;
} }
int32_t reserveDbVgVersionInCache(int32_t acctId, const char* pDb, SParseMetaCache* pMetaCache) { int32_t reserveDbVgVersionInCache(int32_t acctId, const char* pDb, SParseMetaCache* pMetaCache) {
return reserveDbReqInCache(acctId, pDb, &pMetaCache->pDbCfg); return reserveDbReqInCache(acctId, pDb, &pMetaCache->pDbInfo);
} }
int32_t getDbVgVersionFromCache(SParseMetaCache* pMetaCache, const char* pDbFName, int32_t* pVersion, int64_t* pDbId, int32_t getDbVgVersionFromCache(SParseMetaCache* pMetaCache, const char* pDbFName, int32_t* pVersion, int64_t* pDbId,
int32_t* pTableNum) { int32_t* pTableNum) {
SDbInfo** pRes = taosHashGet(pMetaCache->pDbCfg, pDbFName, strlen(pDbFName)); SDbInfo* pDbInfo = NULL;
if (NULL == pRes || NULL == *pRes) { int32_t code = getMetaDataFromHash(pDbFName, strlen(pDbFName), pMetaCache->pDbInfo, (void**)&pDbInfo);
parserError("getDbVgVersionFromCache error: %s", pDbFName); if (TSDB_CODE_SUCCESS == code) {
return TSDB_CODE_PAR_INTERNAL_ERROR; *pVersion = pDbInfo->vgVer;
*pDbId = pDbInfo->dbId;
*pTableNum = pDbInfo->tbNum;
} }
*pVersion = (*pRes)->vgVer; return code;
*pDbId = (*pRes)->dbId;
*pTableNum = (*pRes)->tbNum;
return TSDB_CODE_SUCCESS;
} }
int32_t reserveDbCfgInCache(int32_t acctId, const char* pDb, SParseMetaCache* pMetaCache) { int32_t reserveDbCfgInCache(int32_t acctId, const char* pDb, SParseMetaCache* pMetaCache) {
@ -767,13 +740,12 @@ int32_t reserveDbCfgInCache(int32_t acctId, const char* pDb, SParseMetaCache* pM
} }
int32_t getDbCfgFromCache(SParseMetaCache* pMetaCache, const char* pDbFName, SDbCfgInfo* pInfo) { int32_t getDbCfgFromCache(SParseMetaCache* pMetaCache, const char* pDbFName, SDbCfgInfo* pInfo) {
SDbCfgInfo** pRes = taosHashGet(pMetaCache->pDbCfg, pDbFName, strlen(pDbFName)); SDbCfgInfo* pDbCfg = NULL;
if (NULL == pRes || NULL == *pRes) { int32_t code = getMetaDataFromHash(pDbFName, strlen(pDbFName), pMetaCache->pDbCfg, (void**)&pDbCfg);
parserError("getDbCfgFromCache error: %s", pDbFName); if (TSDB_CODE_SUCCESS == code) {
return TSDB_CODE_PAR_INTERNAL_ERROR; memcpy(pInfo, pDbCfg, sizeof(SDbCfgInfo));
} }
memcpy(pInfo, *pRes, sizeof(SDbCfgInfo)); return code;
return TSDB_CODE_SUCCESS;
} }
static int32_t reserveUserAuthInCacheImpl(const char* pKey, int32_t len, SParseMetaCache* pMetaCache) { static int32_t reserveUserAuthInCacheImpl(const char* pKey, int32_t len, SParseMetaCache* pMetaCache) {
@ -806,13 +778,12 @@ int32_t getUserAuthFromCache(SParseMetaCache* pMetaCache, const char* pUser, con
bool* pPass) { bool* pPass) {
char key[USER_AUTH_KEY_MAX_LEN] = {0}; char key[USER_AUTH_KEY_MAX_LEN] = {0};
int32_t len = userAuthToStringExt(pUser, pDbFName, type, key); int32_t len = userAuthToStringExt(pUser, pDbFName, type, key);
bool* pRes = taosHashGet(pMetaCache->pUserAuth, key, len); bool* pRes = NULL;
if (NULL == pRes) { int32_t code = getMetaDataFromHash(key, len, pMetaCache->pUserAuth, (void**)&pRes);
parserError("getUserAuthFromCache error: %s, %s, %d", pUser, pDbFName, type); if (TSDB_CODE_SUCCESS == code) {
return TSDB_CODE_PAR_INTERNAL_ERROR; *pPass = *pRes;
} }
*pPass = *pRes; return code;
return TSDB_CODE_SUCCESS;
} }
int32_t reserveUdfInCache(const char* pFunc, SParseMetaCache* pMetaCache) { int32_t reserveUdfInCache(const char* pFunc, SParseMetaCache* pMetaCache) {
@ -826,11 +797,10 @@ int32_t reserveUdfInCache(const char* pFunc, SParseMetaCache* pMetaCache) {
} }
int32_t getUdfInfoFromCache(SParseMetaCache* pMetaCache, const char* pFunc, SFuncInfo* pInfo) { int32_t getUdfInfoFromCache(SParseMetaCache* pMetaCache, const char* pFunc, SFuncInfo* pInfo) {
SFuncInfo** pRes = taosHashGet(pMetaCache->pUdf, pFunc, strlen(pFunc)); SFuncInfo* pFuncInfo = NULL;
if (NULL == pRes || NULL == *pRes) { int32_t code = getMetaDataFromHash(pFunc, strlen(pFunc), pMetaCache->pUdf, (void**)&pFuncInfo);
parserError("getUdfInfoFromCache error: %s", pFunc); if (TSDB_CODE_SUCCESS == code) {
return TSDB_CODE_PAR_INTERNAL_ERROR; memcpy(pInfo, pFuncInfo, sizeof(SFuncInfo));
} }
memcpy(pInfo, *pRes, sizeof(SFuncInfo)); return code;
return TSDB_CODE_SUCCESS;
} }

View File

@ -367,49 +367,40 @@ class MockCatalogServiceImpl {
} }
int32_t getAllTableMeta(SArray* pTableMetaReq, SArray** pTableMetaData) const { int32_t getAllTableMeta(SArray* pTableMetaReq, SArray** pTableMetaData) const {
int32_t code = TSDB_CODE_SUCCESS;
if (NULL != pTableMetaReq) { if (NULL != pTableMetaReq) {
int32_t ntables = taosArrayGetSize(pTableMetaReq); int32_t ntables = taosArrayGetSize(pTableMetaReq);
*pTableMetaData = taosArrayInit(ntables, POINTER_BYTES); *pTableMetaData = taosArrayInit(ntables, sizeof(SMetaRes));
for (int32_t i = 0; i < ntables; ++i) { for (int32_t i = 0; i < ntables; ++i) {
STableMeta* pMeta = NULL; SMetaRes res = {0};
code = catalogGetTableMeta((const SName*)taosArrayGet(pTableMetaReq, i), &pMeta); res.code = catalogGetTableMeta((const SName*)taosArrayGet(pTableMetaReq, i), (STableMeta**)&res.pRes);
if (TSDB_CODE_SUCCESS == code) { taosArrayPush(*pTableMetaData, &res);
taosArrayPush(*pTableMetaData, &pMeta);
} else {
break;
}
} }
} }
return code; return TSDB_CODE_SUCCESS;
} }
int32_t getAllTableVgroup(SArray* pTableVgroupReq, SArray** pTableVgroupData) const { int32_t getAllTableVgroup(SArray* pTableVgroupReq, SArray** pTableVgroupData) const {
int32_t code = TSDB_CODE_SUCCESS;
if (NULL != pTableVgroupReq) { if (NULL != pTableVgroupReq) {
int32_t ntables = taosArrayGetSize(pTableVgroupReq); int32_t ntables = taosArrayGetSize(pTableVgroupReq);
*pTableVgroupData = taosArrayInit(ntables, sizeof(SVgroupInfo)); *pTableVgroupData = taosArrayInit(ntables, sizeof(SMetaRes));
for (int32_t i = 0; i < ntables; ++i) { for (int32_t i = 0; i < ntables; ++i) {
SVgroupInfo vgInfo = {0}; SMetaRes res = {0};
code = catalogGetTableHashVgroup((const SName*)taosArrayGet(pTableVgroupReq, i), &vgInfo); res.pRes = taosMemoryCalloc(1, sizeof(SVgroupInfo));
if (TSDB_CODE_SUCCESS == code) { res.code = catalogGetTableHashVgroup((const SName*)taosArrayGet(pTableVgroupReq, i), (SVgroupInfo*)res.pRes);
taosArrayPush(*pTableVgroupData, &vgInfo); taosArrayPush(*pTableVgroupData, &res);
} else {
break;
}
} }
} }
return code; return TSDB_CODE_SUCCESS;
} }
int32_t getAllDbVgroup(SArray* pDbVgroupReq, SArray** pDbVgroupData) const { int32_t getAllDbVgroup(SArray* pDbVgroupReq, SArray** pDbVgroupData) const {
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
if (NULL != pDbVgroupReq) { if (NULL != pDbVgroupReq) {
int32_t ndbs = taosArrayGetSize(pDbVgroupReq); int32_t ndbs = taosArrayGetSize(pDbVgroupReq);
*pDbVgroupData = taosArrayInit(ndbs, POINTER_BYTES); *pDbVgroupData = taosArrayInit(ndbs, sizeof(SMetaRes));
for (int32_t i = 0; i < ndbs; ++i) { for (int32_t i = 0; i < ndbs; ++i) {
int64_t zeroVg = 0; SMetaRes res = {0};
taosArrayPush(*pDbVgroupData, &zeroVg); taosArrayPush(*pDbVgroupData, &res);
} }
} }
return code; return code;
@ -419,10 +410,11 @@ class MockCatalogServiceImpl {
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
if (NULL != pDbCfgReq) { if (NULL != pDbCfgReq) {
int32_t ndbs = taosArrayGetSize(pDbCfgReq); int32_t ndbs = taosArrayGetSize(pDbCfgReq);
*pDbCfgData = taosArrayInit(ndbs, sizeof(SDbCfgInfo)); *pDbCfgData = taosArrayInit(ndbs, sizeof(SMetaRes));
for (int32_t i = 0; i < ndbs; ++i) { for (int32_t i = 0; i < ndbs; ++i) {
SDbCfgInfo dbCfg = {0}; SMetaRes res = {0};
taosArrayPush(*pDbCfgData, &dbCfg); res.pRes = taosMemoryCalloc(1, sizeof(SDbCfgInfo));
taosArrayPush(*pDbCfgData, &res);
} }
} }
return code; return code;
@ -432,10 +424,11 @@ class MockCatalogServiceImpl {
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
if (NULL != pDbInfoReq) { if (NULL != pDbInfoReq) {
int32_t ndbs = taosArrayGetSize(pDbInfoReq); int32_t ndbs = taosArrayGetSize(pDbInfoReq);
*pDbInfoData = taosArrayInit(ndbs, sizeof(SDbCfgInfo)); *pDbInfoData = taosArrayInit(ndbs, sizeof(SMetaRes));
for (int32_t i = 0; i < ndbs; ++i) { for (int32_t i = 0; i < ndbs; ++i) {
SDbInfo dbInfo = {0}; SMetaRes res = {0};
taosArrayPush(*pDbInfoData, &dbInfo); res.pRes = taosMemoryCalloc(1, sizeof(SDbInfo));
taosArrayPush(*pDbInfoData, &res);
} }
} }
return code; return code;
@ -445,31 +438,29 @@ class MockCatalogServiceImpl {
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
if (NULL != pUserAuthReq) { if (NULL != pUserAuthReq) {
int32_t num = taosArrayGetSize(pUserAuthReq); int32_t num = taosArrayGetSize(pUserAuthReq);
*pUserAuthData = taosArrayInit(num, sizeof(bool)); *pUserAuthData = taosArrayInit(num, sizeof(SMetaRes));
for (int32_t i = 0; i < num; ++i) { for (int32_t i = 0; i < num; ++i) {
bool pass = true; SMetaRes res = {0};
taosArrayPush(*pUserAuthData, &pass); res.pRes = taosMemoryCalloc(1, sizeof(bool));
*(bool*)(res.pRes) = true;
taosArrayPush(*pUserAuthData, &res);
} }
} }
return code; return code;
} }
int32_t getAllUdf(SArray* pUdfReq, SArray** pUdfData) const { int32_t getAllUdf(SArray* pUdfReq, SArray** pUdfData) const {
int32_t code = TSDB_CODE_SUCCESS;
if (NULL != pUdfReq) { if (NULL != pUdfReq) {
int32_t num = taosArrayGetSize(pUdfReq); int32_t num = taosArrayGetSize(pUdfReq);
*pUdfData = taosArrayInit(num, sizeof(SFuncInfo)); *pUdfData = taosArrayInit(num, sizeof(SMetaRes));
for (int32_t i = 0; i < num; ++i) { for (int32_t i = 0; i < num; ++i) {
SFuncInfo info = {0}; SMetaRes res = {0};
code = catalogGetUdfInfo((char*)taosArrayGet(pUdfReq, i), &info); res.pRes = taosMemoryCalloc(1, sizeof(SFuncInfo));
if (TSDB_CODE_SUCCESS == code) { res.code = catalogGetUdfInfo((char*)taosArrayGet(pUdfReq, i), (SFuncInfo*)res.pRes);
taosArrayPush(*pUdfData, &info); taosArrayPush(*pUdfData, &res);
} else {
break;
}
} }
} }
return code; return TSDB_CODE_SUCCESS;
} }
uint64_t id_; uint64_t id_;