Fix(stmt): skip stmt while use ctg cache.

This commit is contained in:
xiao-77 2025-03-04 15:10:47 +08:00
parent be9732d774
commit 69e88f9f5c
2 changed files with 8 additions and 3 deletions

View File

@ -1367,6 +1367,7 @@ int32_t ctgGetTbMetaFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SNa
int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SVgroupInfo* vgroupInfo, int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SVgroupInfo* vgroupInfo,
STableMetaOutput* out, SCtgTaskReq* tReq) { STableMetaOutput* out, SCtgTaskReq* tReq) {
SCtgTask* pTask = tReq ? tReq->pTask : NULL; SCtgTask* pTask = tReq ? tReq->pTask : NULL;
uint8_t autoCreateCtb = tReq ? tReq->autoCreateCtb : 0;
char dbFName[TSDB_DB_FNAME_LEN]; char dbFName[TSDB_DB_FNAME_LEN];
(void)tNameGetFullDbName(pTableName, dbFName); (void)tNameGetFullDbName(pTableName, dbFName);
int32_t reqType = (pTask && pTask->type == CTG_TASK_GET_TB_NAME ? TDMT_VND_TABLE_NAME : TDMT_VND_TABLE_META); int32_t reqType = (pTask && pTask->type == CTG_TASK_GET_TB_NAME ? TDMT_VND_TABLE_NAME : TDMT_VND_TABLE_META);
@ -1380,7 +1381,7 @@ int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SNa
SBuildTableInput bInput = {.vgId = vgroupInfo->vgId, SBuildTableInput bInput = {.vgId = vgroupInfo->vgId,
.option = reqType == TDMT_VND_TABLE_NAME ? REQ_OPT_TBUID : REQ_OPT_TBNAME, .option = reqType == TDMT_VND_TABLE_NAME ? REQ_OPT_TBUID : REQ_OPT_TBNAME,
.autoCreateCtb = tReq->autoCreateCtb, .autoCreateCtb = autoCreateCtb,
.dbFName = dbFName, .dbFName = dbFName,
.tbName = (char*)tNameGetTableName(pTableName)}; .tbName = (char*)tNameGetTableName(pTableName)};
char* msg = NULL; char* msg = NULL;

View File

@ -1328,6 +1328,9 @@ static int32_t getUsingTableSchema(SInsertParseContext* pCxt, SVnodeModifyOpStmt
bool bUsingTable = true; bool bUsingTable = true;
code = getTableMeta(pCxt, &pStmt->usingTableName, &pStableMeta, &pCxt->missCache, bUsingTable); code = getTableMeta(pCxt, &pStmt->usingTableName, &pStableMeta, &pCxt->missCache, bUsingTable);
} }
if (pCxt->isStmtBind) {
goto _no_ctb_cache;
}
if (TSDB_CODE_SUCCESS == code && !pCxt->missCache) { if (TSDB_CODE_SUCCESS == code && !pCxt->missCache) {
bool bUsingTable = false; bool bUsingTable = false;
@ -1338,11 +1341,12 @@ static int32_t getUsingTableSchema(SInsertParseContext* pCxt, SVnodeModifyOpStmt
code = (pStableMeta->suid == pCtableMeta->suid) ? TSDB_CODE_SUCCESS : TSDB_CODE_TDB_TABLE_IN_OTHER_STABLE; code = (pStableMeta->suid == pCtableMeta->suid) ? TSDB_CODE_SUCCESS : TSDB_CODE_TDB_TABLE_IN_OTHER_STABLE;
*ctbCacheHit = true; *ctbCacheHit = true;
} }
_no_ctb_cache:
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
if (*ctbCacheHit) { if (*ctbCacheHit) {
code = cloneTableMeta(pCtableMeta,&pStmt->pTableMeta); code = cloneTableMeta(pCtableMeta, &pStmt->pTableMeta);
} else { } else {
code = cloneTableMeta( pStableMeta,&pStmt->pTableMeta); code = cloneTableMeta(pStableMeta, &pStmt->pTableMeta);
} }
} }
taosMemoryFree(pStableMeta); taosMemoryFree(pStableMeta);