From 69e88f9f5cbbee2756443c2e3cea1437bafb79d7 Mon Sep 17 00:00:00 2001 From: xiao-77 Date: Tue, 4 Mar 2025 15:10:47 +0800 Subject: [PATCH] Fix(stmt): skip stmt while use ctg cache. --- source/libs/catalog/src/ctgRemote.c | 3 ++- source/libs/parser/src/parInsertSql.c | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/source/libs/catalog/src/ctgRemote.c b/source/libs/catalog/src/ctgRemote.c index dca4e2d2fa..abd97e4ed9 100644 --- a/source/libs/catalog/src/ctgRemote.c +++ b/source/libs/catalog/src/ctgRemote.c @@ -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, STableMetaOutput* out, SCtgTaskReq* tReq) { SCtgTask* pTask = tReq ? tReq->pTask : NULL; + uint8_t autoCreateCtb = tReq ? tReq->autoCreateCtb : 0; char dbFName[TSDB_DB_FNAME_LEN]; (void)tNameGetFullDbName(pTableName, dbFName); 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, .option = reqType == TDMT_VND_TABLE_NAME ? REQ_OPT_TBUID : REQ_OPT_TBNAME, - .autoCreateCtb = tReq->autoCreateCtb, + .autoCreateCtb = autoCreateCtb, .dbFName = dbFName, .tbName = (char*)tNameGetTableName(pTableName)}; char* msg = NULL; diff --git a/source/libs/parser/src/parInsertSql.c b/source/libs/parser/src/parInsertSql.c index 290011a708..e322dd1dc7 100644 --- a/source/libs/parser/src/parInsertSql.c +++ b/source/libs/parser/src/parInsertSql.c @@ -1328,6 +1328,9 @@ static int32_t getUsingTableSchema(SInsertParseContext* pCxt, SVnodeModifyOpStmt bool bUsingTable = true; code = getTableMeta(pCxt, &pStmt->usingTableName, &pStableMeta, &pCxt->missCache, bUsingTable); } + if (pCxt->isStmtBind) { + goto _no_ctb_cache; + } if (TSDB_CODE_SUCCESS == code && !pCxt->missCache) { 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; *ctbCacheHit = true; } +_no_ctb_cache: if (TSDB_CODE_SUCCESS == code) { if (*ctbCacheHit) { - code = cloneTableMeta(pCtableMeta,&pStmt->pTableMeta); + code = cloneTableMeta(pCtableMeta, &pStmt->pTableMeta); } else { - code = cloneTableMeta( pStableMeta,&pStmt->pTableMeta); + code = cloneTableMeta(pStableMeta, &pStmt->pTableMeta); } } taosMemoryFree(pStableMeta);