enh: drop table with uid
This commit is contained in:
parent
cac1ce28ad
commit
9cc0702a77
|
@ -2046,11 +2046,13 @@ typedef struct {
|
|||
int32_t tSerializeSAlterVnodeHashRangeReq(void* buf, int32_t bufLen, SAlterVnodeHashRangeReq* pReq);
|
||||
int32_t tDeserializeSAlterVnodeHashRangeReq(void* buf, int32_t bufLen, SAlterVnodeHashRangeReq* pReq);
|
||||
|
||||
#define REQ_OPT_TBNAME 0x0
|
||||
#define REQ_OPT_TBUID 0x01
|
||||
typedef struct {
|
||||
SMsgHead header;
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
char tbName[TSDB_TABLE_NAME_LEN];
|
||||
uint8_t option; // 0x01 for table uid
|
||||
uint8_t option;
|
||||
} STableInfoReq;
|
||||
|
||||
int32_t tSerializeSTableInfoReq(void* buf, int32_t bufLen, STableInfoReq* pReq);
|
||||
|
|
|
@ -72,6 +72,7 @@ typedef struct SParseContext {
|
|||
int64_t requestRid;
|
||||
int32_t acctId;
|
||||
const char* db;
|
||||
bool topicQuery;
|
||||
void* pTransporter;
|
||||
SEpSet mgmtEpSet;
|
||||
const char* pSql; // sql string
|
||||
|
@ -82,7 +83,6 @@ typedef struct SParseContext {
|
|||
SStmtCallback* pStmtCb;
|
||||
const char* pUser;
|
||||
const char* pEffectiveUser;
|
||||
bool topicQuery;
|
||||
bool parseOnly;
|
||||
bool isSuperUser;
|
||||
bool enableSysInfo;
|
||||
|
@ -92,14 +92,13 @@ typedef struct SParseContext {
|
|||
bool isAudit;
|
||||
bool nodeOffline;
|
||||
bool isStmtBind;
|
||||
// bool withOpt;
|
||||
int8_t biMode;
|
||||
const char* svrVer;
|
||||
SArray* pTableMetaPos; // sql table pos => catalog data pos
|
||||
SArray* pTableVgroupPos; // sql table pos => catalog data pos
|
||||
int64_t allocatorId;
|
||||
parseSqlFn parseSqlFp;
|
||||
void* parseSqlParam;
|
||||
int8_t biMode;
|
||||
SArray* pSubMetaList;
|
||||
setQueryFn setQueryFp;
|
||||
} SParseContext;
|
||||
|
|
|
@ -123,7 +123,6 @@ typedef struct STableMeta {
|
|||
// the schema content.
|
||||
SSchema schema[];
|
||||
} STableMeta;
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
typedef struct SViewMeta {
|
||||
|
|
|
@ -5761,10 +5761,10 @@ int32_t tDeserializeSTableInfoReq(void *buf, int32_t bufLen, STableInfoReq *pReq
|
|||
TAOS_CHECK_EXIT(tStartDecode(&decoder));
|
||||
TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, pReq->dbFName));
|
||||
TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, pReq->tbName));
|
||||
if (tDecodeIsEnd(&decoder)) {
|
||||
pReq->option = 0;
|
||||
} else {
|
||||
if (!tDecodeIsEnd(&decoder)) {
|
||||
TAOS_CHECK_EXIT(tDecodeU8(&decoder, &pReq->option));
|
||||
} else {
|
||||
pReq->option = 0;
|
||||
}
|
||||
|
||||
tEndDecode(&decoder);
|
||||
|
|
|
@ -55,7 +55,7 @@ int32_t vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
|||
SMetaReader mer1 = {0};
|
||||
SMetaReader mer2 = {0};
|
||||
char tableFName[TSDB_TABLE_FNAME_LEN];
|
||||
bool reqFromUid = false;
|
||||
bool optTbUid = false;
|
||||
SRpcMsg rpcMsg = {0};
|
||||
int32_t code = 0;
|
||||
int32_t rspLen = 0;
|
||||
|
@ -69,12 +69,12 @@ int32_t vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
|||
goto _exit4;
|
||||
}
|
||||
|
||||
if (infoReq.option == 0x01) reqFromUid = true;
|
||||
if (infoReq.option == REQ_OPT_TBUID) optTbUid = true;
|
||||
metaRsp.dbId = pVnode->config.dbId;
|
||||
(void)strcpy(metaRsp.tbName, infoReq.tbName);
|
||||
(void)memcpy(metaRsp.dbFName, infoReq.dbFName, sizeof(metaRsp.dbFName));
|
||||
|
||||
if (!reqFromUid) {
|
||||
if (!optTbUid) {
|
||||
TAOS_UNUSED(sprintf(tableFName, "%s.%s", infoReq.dbFName, infoReq.tbName));
|
||||
code = vnodeValidateTableHash(pVnode, tableFName);
|
||||
if (code) {
|
||||
|
@ -84,7 +84,7 @@ int32_t vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
|||
|
||||
// query meta
|
||||
metaReaderDoInit(&mer1, pVnode->pMeta, META_READER_LOCK);
|
||||
if (reqFromUid) {
|
||||
if (optTbUid) {
|
||||
uint64_t tbUid = taosStr2UInt64(infoReq.tbName, NULL, 10);
|
||||
if (errno == ERANGE || tbUid == 0) {
|
||||
code = TSDB_CODE_TDB_TABLE_NOT_EXIST;
|
||||
|
|
|
@ -599,9 +599,9 @@ static int32_t ctgInitGetTbNamesTask(SCtgJob* pJob, int32_t taskId, void* param)
|
|||
CTG_ERR_RET(terrno);
|
||||
}
|
||||
task.taskCtx = pTaskCtx;
|
||||
taosInitRWLatch(&pTaskCtx->lock);
|
||||
pTaskCtx->pNames = param;
|
||||
pTaskCtx->pResList = taosArrayInit(pJob->tbNameNum, sizeof(SMetaRes));
|
||||
taosInitRWLatch(&pTaskCtx->lock);
|
||||
if (NULL == pTaskCtx->pResList) {
|
||||
qError("qid:0x%" PRIx64 " taosArrayInit %d SMetaRes %d failed", pJob->queryId, pJob->tbNameNum,
|
||||
(int32_t)sizeof(SMetaRes));
|
||||
|
@ -2083,7 +2083,7 @@ _return:
|
|||
}
|
||||
}
|
||||
} else {
|
||||
pRes->pRes == NULL;
|
||||
pRes->pRes = NULL;
|
||||
pRes->code = code;
|
||||
}
|
||||
if (taskDone == true) {
|
||||
|
|
|
@ -669,7 +669,7 @@ int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo* pConn, SCtgT
|
|||
(void)tNameGetFullDbName(pName, newBatch.dbFName);
|
||||
}
|
||||
|
||||
newBatch.msgType = (vgId > 1) ? TDMT_VND_BATCH_META : TDMT_MND_BATCH_META;
|
||||
newBatch.msgType = (vgId > 0) ? TDMT_VND_BATCH_META : TDMT_MND_BATCH_META;
|
||||
newBatch.batchId = atomic_add_fetch_32(&pJob->batchId, 1);
|
||||
|
||||
if (0 != taosHashPut(pBatchs, &vgId, sizeof(vgId), &newBatch, sizeof(newBatch))) {
|
||||
|
@ -1376,7 +1376,7 @@ int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SNa
|
|||
vgroupInfo->epSet.numOfEps, pEp->fqdn, pEp->port, tbFName);
|
||||
|
||||
SBuildTableInput bInput = {.vgId = vgroupInfo->vgId,
|
||||
.option = reqType == TDMT_VND_TABLE_NAME ? 0x01 : 0x00,
|
||||
.option = reqType == TDMT_VND_TABLE_NAME ? REQ_OPT_TBNAME : REQ_OPT_TBUID,
|
||||
.dbFName = dbFName,
|
||||
.tbName = (char*)tNameGetTableName(pTableName)};
|
||||
char* msg = NULL;
|
||||
|
|
|
@ -115,7 +115,6 @@ typedef struct SParseMetaCache {
|
|||
SHashObj* pTableName; // key is tbFUid, elements is STableMeta*(append with tbName)
|
||||
SArray* pDnodes; // element is SEpSet
|
||||
bool dnodeRequired;
|
||||
bool qnodeRequired;
|
||||
} SParseMetaCache;
|
||||
|
||||
int32_t generateSyntaxErrMsg(SMsgBuf* pBuf, int32_t errCode, ...);
|
||||
|
|
|
@ -389,12 +389,10 @@ static int32_t collectMetaKeyFromDropTable(SCollectMetaKeyCxt* pCxt, SDropTableS
|
|||
}
|
||||
} else {
|
||||
code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, pCxt->pMetaCache);
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code =
|
||||
reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, pCxt->pMetaCache);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pClause->dbName,
|
||||
pClause->tableName, AUTH_TYPE_WRITE, pCxt->pMetaCache);
|
||||
|
|
|
@ -14523,8 +14523,8 @@ int32_t serializeVgroupsDropTableBatch(SHashObj* pVgroupHashmap, SArray** pOut)
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t rewriteDropTablewithOpt(STranslateContext* pCxt, SQuery* pQuery) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
static int32_t rewriteDropTableWithOpt(STranslateContext* pCxt, SQuery* pQuery) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SDropTableStmt* pStmt = (SDropTableStmt*)pQuery->pRoot;
|
||||
if (!pStmt->withOpt) return code;
|
||||
pCxt->withOpt = true;
|
||||
|
@ -14533,7 +14533,6 @@ 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};
|
||||
toName(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, &name);
|
||||
int32_t code = getTargetName(pCxt, &name, pTableName);
|
||||
|
@ -14554,7 +14553,7 @@ static int32_t rewriteDropTable(STranslateContext* pCxt, SQuery* pQuery) {
|
|||
SNode* pNode;
|
||||
SArray* pTsmas = NULL;
|
||||
|
||||
TAOS_CHECK_RETURN(rewriteDropTablewithOpt(pCxt, pQuery));
|
||||
TAOS_CHECK_RETURN(rewriteDropTableWithOpt(pCxt, pQuery));
|
||||
|
||||
SHashObj* pVgroupHashmap = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK);
|
||||
if (NULL == pVgroupHashmap) {
|
||||
|
@ -14575,7 +14574,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;
|
||||
if (pCxt->withOpt) continue; // TODO
|
||||
if (pCxt->pMetaCache) code = getTableTsmasFromCache(pCxt->pMetaCache, &name, &pTsmas);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
taosHashCleanup(pVgroupHashmap);
|
||||
|
|
|
@ -76,7 +76,8 @@ int32_t queryBuildTableMetaReqMsg(void *input, char **msg, int32_t msgSize, int3
|
|||
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||
}
|
||||
|
||||
STableInfoReq infoReq = {.option = pInput->option};
|
||||
STableInfoReq infoReq = {0};
|
||||
infoReq.option = pInput->option;
|
||||
infoReq.header.vgId = pInput->vgId;
|
||||
if (pInput->dbFName) {
|
||||
tstrncpy(infoReq.dbFName, pInput->dbFName, TSDB_DB_FNAME_LEN);
|
||||
|
@ -627,10 +628,10 @@ int32_t queryCreateTableMetaExFromMsg(STableMetaRsp *msg, bool isStb, STableMeta
|
|||
pTableMeta->tableInfo.precision = msg->precision;
|
||||
pTableMeta->tableInfo.numOfColumns = msg->numOfColumns;
|
||||
|
||||
memcpy(pTableMeta->schema, msg->pSchemas, sizeof(SSchema) * total);
|
||||
TAOS_MEMCPY(pTableMeta->schema, msg->pSchemas, sizeof(SSchema) * total);
|
||||
if (useCompress(msg->tableType) && msg->pSchemaExt) {
|
||||
pTableMeta->schemaExt = pSchemaExt;
|
||||
memcpy(pSchemaExt, msg->pSchemaExt, schemaExtSize);
|
||||
TAOS_MEMCPY(pSchemaExt, msg->pSchemaExt, schemaExtSize);
|
||||
} else {
|
||||
pTableMeta->schemaExt = NULL;
|
||||
}
|
||||
|
|
|
@ -956,8 +956,6 @@ void* varObtainThread(void* param) {
|
|||
// return true is need update value by async
|
||||
bool updateTireValue(int type, bool autoFill) {
|
||||
// TYPE CONTEXT GET FROM DB
|
||||
return true;
|
||||
#if 0
|
||||
taosThreadMutexLock(&tiresMutex);
|
||||
|
||||
// check need obtain from server
|
||||
|
@ -984,7 +982,6 @@ bool updateTireValue(int type, bool autoFill) {
|
|||
}
|
||||
taosThreadMutexUnlock(&tiresMutex);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
// only match next one word from all match words, return valuue must free by caller
|
||||
|
|
Loading…
Reference in New Issue