enh: support drop table with uid
This commit is contained in:
parent
8a5c47a9c2
commit
3efa99520a
|
@ -85,6 +85,7 @@ int32_t vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
|||
// query meta
|
||||
metaReaderDoInit(&mer1, pVnode->pMeta, META_READER_LOCK);
|
||||
if (reqTbUid) {
|
||||
errno = 0;
|
||||
uint64_t tbUid = taosStr2UInt64(infoReq.tbName, NULL, 10);
|
||||
if (errno == ERANGE || tbUid == 0) {
|
||||
code = TSDB_CODE_TDB_TABLE_NOT_EXIST;
|
||||
|
|
|
@ -851,7 +851,7 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const
|
|||
int32_t viewNum = (int32_t)ctgGetTablesReqNum(pReq->pView);
|
||||
int32_t tbTsmaNum = (int32_t)taosArrayGetSize(pReq->pTableTSMAs);
|
||||
int32_t tsmaNum = (int32_t)taosArrayGetSize(pReq->pTSMAs);
|
||||
int32_t tbNameNum = (int32_t)taosArrayGetSize(pReq->pTableName);
|
||||
int32_t tbNameNum = (int32_t)ctgGetTablesReqNum(pReq->pTableName);
|
||||
|
||||
int32_t taskNum = tbMetaNum + dbVgNum + udfNum + tbHashNum + qnodeNum + dnodeNum + svrVerNum + dbCfgNum + indexNum +
|
||||
userNum + dbInfoNum + tbIndexNum + tbCfgNum + tbTagNum + viewNum + tbTsmaNum + tbNameNum;
|
||||
|
@ -2075,13 +2075,7 @@ _return:
|
|||
taskDone = true;
|
||||
}
|
||||
if (TDMT_VND_TABLE_NAME == reqType) {
|
||||
if (taskDone == true) {
|
||||
if (pRes->pRes) {
|
||||
code = 0; // already get tbMeta from one request, reset code to 0
|
||||
} else {
|
||||
pRes->code = code;
|
||||
}
|
||||
}
|
||||
if (!pRes->pRes && (0 == pRes->code)) pRes->code = code;
|
||||
} else {
|
||||
pRes->pRes = NULL;
|
||||
pRes->code = code;
|
||||
|
|
|
@ -1172,6 +1172,8 @@ int32_t ctgGenerateVgList(SCatalog* pCtg, SHashObj* vgHash, SArray** pList) {
|
|||
pIter = taosHashIterate(vgHash, pIter);
|
||||
}
|
||||
|
||||
taosArraySort(vgList, ctgVgInfoComp);
|
||||
|
||||
*pList = vgList;
|
||||
|
||||
ctgDebug("Got vgList from cache, vgNum:%d", vgNum);
|
||||
|
|
|
@ -14533,11 +14533,12 @@ static int32_t rewriteDropTableWithOpt(STranslateContext* pCxt, SQuery* pQuery)
|
|||
char pTableName[TSDB_TABLE_NAME_LEN] = {0};
|
||||
FOREACH(pNode, pStmt->pTables) {
|
||||
SDropTableClause* pClause = (SDropTableClause*)pNode;
|
||||
SName name = {0};
|
||||
SName name = {0};
|
||||
toName(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, &name);
|
||||
int32_t code = getTargetName(pCxt, &name, pTableName);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, code, "Table uid does not exist: '%s'", pClause->tableName);
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, code, "Table uid does not exist: '%s.%s'", pClause->dbName,
|
||||
pClause->tableName);
|
||||
}
|
||||
tstrncpy(pClause->tableName, pTableName, TSDB_TABLE_NAME_LEN); // rewrite table uid to table name
|
||||
}
|
||||
|
@ -14574,7 +14575,7 @@ static int32_t rewriteDropTable(STranslateContext* pCxt, SQuery* pQuery) {
|
|||
taosHashCleanup(pVgroupHashmap);
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DROP_STABLE);
|
||||
}
|
||||
if (pCxt->withOpt) continue; // TODO
|
||||
if (pCxt->withOpt) continue;
|
||||
if (pCxt->pMetaCache) code = getTableTsmasFromCache(pCxt->pMetaCache, &name, &pTsmas);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
taosHashCleanup(pVgroupHashmap);
|
||||
|
@ -14647,7 +14648,8 @@ static int32_t rewriteDropSuperTablewithOpt(STranslateContext* pCxt, SQuery* pQu
|
|||
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name);
|
||||
code = getTargetName(pCxt, &name, pTableName);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, code, "Table uid does not exist: '%s'", pStmt->tableName);
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, code, "Table uid does not exist: '%s.%s'", pStmt->dbName,
|
||||
pStmt->tableName);
|
||||
}
|
||||
tstrncpy(pStmt->tableName, pTableName, TSDB_TABLE_NAME_LEN); // rewrite table uid to table name
|
||||
|
||||
|
|
|
@ -1054,8 +1054,8 @@ int32_t getTableNameFromCache(SParseMetaCache* pMetaCache, const SName* pName, c
|
|||
}
|
||||
const STableMeta* pMeta = NULL;
|
||||
code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pTableName, (void**)&pMeta);
|
||||
if (!pMeta) code = TSDB_CODE_PAR_TABLE_NOT_EXIST;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
if (!pMeta) code = TSDB_CODE_PAR_INTERNAL_ERROR;
|
||||
int32_t metaSize =
|
||||
sizeof(STableMeta) + sizeof(SSchema) * (pMeta->tableInfo.numOfColumns + pMeta->tableInfo.numOfTags);
|
||||
int32_t schemaExtSize =
|
||||
|
@ -1177,14 +1177,11 @@ int32_t getDbTableVgroupFromCache(SParseMetaCache* pMetaCache, const SName* pNam
|
|||
for (int32_t i = 0; i < vgSize; ++i) {
|
||||
uint32_t hashValue =
|
||||
taosGetTbHashVal(fullName, fullTbLen, pDbCfg->hashMethod, pDbCfg->hashPrefix, pDbCfg->hashSuffix);
|
||||
// void* pVg = taosArraySearch(pVgArray, &hashValue, ctgHashValueComp, TD_EQ);
|
||||
SVgroupInfo* pVg = taosArrayGet(pVgArray, i);
|
||||
SVgroupInfo* pVg = taosArraySearch(pVgArray, &hashValue, ctgHashValueComp, TD_EQ);
|
||||
if (pVg) {
|
||||
if (hashValue >= pVg->hashBegin && hashValue <= pVg->hashEnd) {
|
||||
memcpy(pVgroup, pVg, sizeof(SVgroupInfo));
|
||||
code = TSDB_CODE_SUCCESS;
|
||||
break;
|
||||
}
|
||||
memcpy(pVgroup, pVg, sizeof(SVgroupInfo));
|
||||
code = TSDB_CODE_SUCCESS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue