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