diff --git a/include/libs/qcom/query.h b/include/libs/qcom/query.h index 389fe25780f5bbdde734ba1248dd5e04c4a14d3f..bb57946082202e60b60a2f9625cbebabdc684add 100644 --- a/include/libs/qcom/query.h +++ b/include/libs/qcom/query.h @@ -198,6 +198,8 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t #define NEED_CLIENT_HANDLE_ERROR(_code) \ (NEED_CLIENT_RM_TBLMETA_ERROR(_code) || NEED_CLIENT_REFRESH_VG_ERROR(_code) || \ NEED_CLIENT_REFRESH_TBLMETA_ERROR(_code)) +#define NEED_CLIENT_RM_TBLMETA_REQ(_type) ((_type) == TDMT_VND_CREATE_TABLE || (_type) == TDMT_VND_CREATE_STB \ + || (_type) == TDMT_VND_DROP_TABLE || (_type) == TDMT_VND_DROP_STB) #define NEED_SCHEDULER_RETRY_ERROR(_code) \ ((_code) == TSDB_CODE_RPC_REDIRECT || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL) diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 386283b5b58d04b68a00f89100d64b1312e82b46..8a03043a996ef8759c7094d31dc25e01e6838dab 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -345,6 +345,10 @@ int32_t validateSversion(SRequestObj* pRequest, void* res) { for (int32_t i = 0; i < pRsp->nBlocks; ++i) { SSubmitBlkRsp* blk = pRsp->pBlocks + i; + if (NULL == blk->tblFName || 0 == blk->tblFName[0]) { + continue; + } + STbSVersion tbSver = {.tbFName = blk->tblFName, .sver = blk->sver}; taosArrayPush(pArray, &tbSver); } @@ -499,6 +503,23 @@ int32_t refreshMeta(STscObj* pTscObj, SRequestObj* pRequest) { return code; } +int32_t removeMeta(STscObj* pTscObj, SArray* tbList) { + SCatalog* pCatalog = NULL; + int32_t tbNum = taosArrayGetSize(tbList); + int32_t code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCatalog); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + + for (int32_t i = 0; i < tbNum; ++i) { + SName* pTbName = taosArrayGet(tbList, i); + catalogRemoveTableMeta(pCatalog, pTbName); + } + + return TSDB_CODE_SUCCESS; +} + + SRequestObj* execQuery(STscObj* pTscObj, const char* sql, int sqlLen) { SRequestObj* pRequest = NULL; int32_t retryNum = 0; @@ -518,6 +539,10 @@ SRequestObj* execQuery(STscObj* pTscObj, const char* sql, int sqlLen) { } } while (retryNum++ < REQUEST_MAX_TRY_TIMES); + if (NEED_CLIENT_RM_TBLMETA_REQ(pRequest->type)) { + removeMeta(pTscObj, pRequest->tableList); + } + return pRequest; } diff --git a/source/client/src/clientStmt.c b/source/client/src/clientStmt.c index 764571e71e5f3ddf89f58183a1d7b26a73cfc79d..a9b4e234e8ca1d09560a5d39a37483b18a8431d6 100644 --- a/source/client/src/clientStmt.c +++ b/source/client/src/clientStmt.c @@ -47,8 +47,14 @@ int32_t stmtSwitchStatus(STscStmt* pStmt, STMT_STATUS newStatus) { } break; case STMT_EXECUTE: - if (STMT_STATUS_NE(ADD_BATCH) && STMT_STATUS_NE(FETCH_FIELDS)) { - code = TSDB_CODE_TSC_STMT_API_ERROR; + if (STMT_TYPE_QUERY == pStmt->sql.type) { + if (STMT_STATUS_NE(ADD_BATCH) && STMT_STATUS_NE(FETCH_FIELDS) && STMT_STATUS_NE(BIND) && STMT_STATUS_NE(BIND_COL)) { + code = TSDB_CODE_TSC_STMT_API_ERROR; + } + } else { + if (STMT_STATUS_NE(ADD_BATCH) && STMT_STATUS_NE(FETCH_FIELDS)) { + code = TSDB_CODE_TSC_STMT_API_ERROR; + } } break; default: diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index d5301e3624fd632d31e48e6eae0944d5ceebd8be..85d9b14c60759ed25ddfb1f376184d61b4bc87c1 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -2800,6 +2800,7 @@ int32_t catalogRemoveTableMeta(SCatalog* pCtg, const SName* pTableName) { CTG_ERR_JRET(ctgPushRmTblMsgInQueue(pCtg, dbFName, dbId, pTableName->tname, true)); } + ctgDebug("table meta %s.%s removed", dbFName, pTableName->tname); _return: @@ -2974,6 +2975,10 @@ int32_t catalogChkTbMetaVersion(SCatalog* pCtg, void *pTrans, const SEpSet* pMgm int32_t tbNum = taosArrayGetSize(pTables); for (int32_t i = 0; i < tbNum; ++i) { STbSVersion* pTb = (STbSVersion*)taosArrayGet(pTables, i); + if (NULL == pTb->tbFName || 0 == pTb->tbFName[0]) { + continue; + } + tNameFromString(&name, pTb->tbFName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); if (CTG_IS_SYS_DBNAME(name.dbname)) { diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index f6d53dd15ac5f4c1e3b9f1d1e07f5dc34ab2ff40..bc16bd89e66e581e334e515e6f61a637b8d9c37a 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -2726,6 +2726,7 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm SName tableName; tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tableName), pReq->name); + collectUseTable(&tableName, pCxt->pTables); return buildRollupAst(pCxt, pStmt, pReq); } diff --git a/source/libs/qworker/src/qworker.c b/source/libs/qworker/src/qworker.c index cb7ff08fa3b8c869a101ad202c274490a49091bd..5b358fb0080bef9f9df4a34a26a4816662154f59 100644 --- a/source/libs/qworker/src/qworker.c +++ b/source/libs/qworker/src/qworker.c @@ -725,7 +725,11 @@ void qwSaveTbVersionInfo(qTaskInfo_t pTaskInfo, SQWTaskCtx *ctx) { qGetQueriedTableSchemaVersion(pTaskInfo, dbFName, tbName, &ctx->tbInfo.sversion, &ctx->tbInfo.tversion); - sprintf(ctx->tbInfo.tbFName, "%s.%s", dbFName, tbName); + if (dbFName[0] && tbName[0]) { + sprintf(ctx->tbInfo.tbFName, "%s.%s", dbFName, tbName); + } else { + ctx->tbInfo.tbFName[0] = 0; + } } int32_t qwHandlePrePhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *input, SQWPhaseOutput *output) { diff --git a/tests/script/api/batchprepare.c b/tests/script/api/batchprepare.c index ba1cd00fcb102bf6e0fbcb29c7655a6cc0d7357a..2ded58a979ad16e06f03ab8d4f828f1c10731df3 100644 --- a/tests/script/api/batchprepare.c +++ b/tests/script/api/batchprepare.c @@ -1825,10 +1825,12 @@ int queryColumnTest(TAOS_STMT *stmt, TAOS *taos) { if (bpBindParam(stmt, data.pBind + n * gCurCase->bindColNum)) { exit(1); } - - if (taos_stmt_add_batch(stmt)) { - printf("!!!taos_stmt_add_batch error:%s\n", taos_stmt_errstr(stmt)); - exit(1); + + if (rand() % 2 == 0) { + if (taos_stmt_add_batch(stmt)) { + printf("!!!taos_stmt_add_batch error:%s\n", taos_stmt_errstr(stmt)); + exit(1); + } } if (taos_stmt_execute(stmt) != 0) { @@ -1871,10 +1873,12 @@ int queryMiscTest(TAOS_STMT *stmt, TAOS *taos) { if (bpBindParam(stmt, data.pBind + n * gCurCase->bindColNum)) { exit(1); } - - if (taos_stmt_add_batch(stmt)) { - printf("!!!taos_stmt_add_batch error:%s\n", taos_stmt_errstr(stmt)); - exit(1); + + if (rand() % 2 == 0) { + if (taos_stmt_add_batch(stmt)) { + printf("!!!taos_stmt_add_batch error:%s\n", taos_stmt_errstr(stmt)); + exit(1); + } } if (taos_stmt_execute(stmt) != 0) { diff --git a/tests/system-test/0-others/udfTest.py b/tests/system-test/0-others/udfTest.py index af3245df3d937cc2a4c4723c52a34fdd3ebeb561..679b41509891d1efe92507a81f7add51b9f76253 100644 --- a/tests/system-test/0-others/udfTest.py +++ b/tests/system-test/0-others/udfTest.py @@ -14,7 +14,7 @@ class TDTestCase: def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), logSql) def getBuildPath(self): selfPath = os.path.dirname(os.path.realpath(__file__))