diff --git a/source/libs/catalog/src/ctgAsync.c b/source/libs/catalog/src/ctgAsync.c index ba9d41705e..46f4f86484 100644 --- a/source/libs/catalog/src/ctgAsync.c +++ b/source/libs/catalog/src/ctgAsync.c @@ -606,12 +606,12 @@ static int32_t ctgInitGetTbNamesTask(SCtgJob* pJob, int32_t taskId, void* param) qError("qid:0x%" PRIx64 " taosArrayInit %d SMetaRes %d failed", pJob->queryId, pJob->tbNameNum, (int32_t)sizeof(SMetaRes)); ctgFreeTask(&task, true); - CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + CTG_ERR_RET(terrno); } if (NULL == taosArrayPush(pJob->pTasks, &task)) { ctgFreeTask(&task, true); - CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + CTG_ERR_RET(terrno); } return TSDB_CODE_SUCCESS; @@ -1942,16 +1942,14 @@ static int32_t ctgHandleGetTbNamesRsp(SCtgTaskReq* tReq, int32_t reqType, const case TDMT_MND_USE_DB: { SUseDbOutput* pOut = (SUseDbOutput*)pMsgCtx->out; CTG_ERR_RET(ctgMakeVgArray(pOut->dbVgroup)); - int32_t vgSize = taosArrayGetSize(pOut->dbVgroup->vgArray); + SArray* pVgArray = NULL; + TSWAP(pVgArray, pOut->dbVgroup->vgArray); + int32_t vgSize = taosArrayGetSize(pVgArray); if (0 == vgSize) { + taosArrayDestroy(pVgArray); ctgTaskError("no vgroup got, dbName:%s", pName->dbname); CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR); } - SArray* pVgArray = taosArrayDup(pOut->dbVgroup->vgArray, NULL); - if (NULL == pVgArray) { - ctgTaskError("fail to dup vgArray:%s", pName->dbname); - CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); - } for (int32_t i = 0; i < vgSize; ++i) { SVgroupInfo* vgInfo = TARRAY_GET_ELEM(pVgArray, i); if (NULL == vgInfo) { @@ -1961,12 +1959,12 @@ static int32_t ctgHandleGetTbNamesRsp(SCtgTaskReq* tReq, int32_t reqType, const } ctgTaskDebug("will refresh tbmeta, not supposed to be stb, tbName:%s, flag:%d, vgId:%d", tNameGetTableName(pName), flag, vgInfo->vgId); - // *vgId = 100; //vgInfo->vgId; + // *vgId = vgInfo->vgId; if (i > 0) atomic_add_fetch_32(&ctx->fetchNum, 1); code = ctgGetTbMetaFromVnode(pCtg, pConn, pName, vgInfo, NULL, tReq); if (code) { taosArrayDestroy(pVgArray); - CTG_ERR_RET(code); + CTG_ERR_JRET(code); } } taosArrayDestroy(pVgArray); @@ -4006,7 +4004,7 @@ static int32_t ctgLaunchGetTbNamesTask(SCtgTask* pTask) { pTask->msgCtxs = taosArrayInit_s(sizeof(SCtgMsgCtx), pCtx->fetchNum); if (NULL == pTask->msgCtxs) { ctgError("taosArrayInit_s %d SCtgMsgCtx %d failed", pCtx->fetchNum, (int32_t)sizeof(SCtgMsgCtx)); - CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + CTG_ERR_RET(terrno); } for (int32_t i = 0; i < pCtx->fetchNum; ++i) { diff --git a/tests/system-test/1-insert/drop.py b/tests/system-test/1-insert/drop.py index ed892e83d1..7e41aad4a8 100644 --- a/tests/system-test/1-insert/drop.py +++ b/tests/system-test/1-insert/drop.py @@ -50,9 +50,9 @@ class TDTestCase: 'col13': 'nchar(20)' } self.db_names = [ f'dbtest_0', f'dbtest_1'] - self.stb_names = [ f'`aa\u00bf\u200bstb0`'] - self.ctb_names = [ f'ctb0', 'ctb1', f'`aa\u00bf\u200bctb0`', f'`aa\u00bf\u200bctb1`'] - self.ntb_names = [ f'ntb0', f'`aa\u00bf\u200bntb0`', f'ntb1', f'`aa\u00bf\u200bntb1`'] + self.stb_names = [ f'aa\u00bf\u200bstb0'] + self.ctb_names = [ f'ctb0', 'ctb1', f'aa\u00bf\u200bctb0', f'aa\u00bf\u200bctb1'] + self.ntb_names = [ f'ntb0', f'aa\u00bf\u200bntb0', f'ntb1', f'aa\u00bf\u200bntb1'] self.vgroups_opt = f'vgroups 4' def insert_data(self,column_dict,tbname,row_num): insert_sql = self.setsql.set_insertsql(column_dict,tbname,self.binary_str,self.nchar_str) @@ -126,13 +126,13 @@ class TDTestCase: tdSql.execute(f'create database if not exists {db_name} {self.vgroups_opt}') tdSql.execute(f'use {db_name}') for stb_name in self.stb_names: - tdSql.execute(f'create table {stb_name} (ts timestamp,c0 int) tags(t0 int)') + tdSql.execute(f'create table `{stb_name}` (ts timestamp,c0 int) tags(t0 int)') for ctb_name in self.ctb_names: - tdSql.execute(f'create table {ctb_name} using {stb_name} tags(0)') - tdSql.execute(f'insert into {ctb_name} values (now,1)') + tdSql.execute(f'create table `{ctb_name}` using `{stb_name}` tags(0)') + tdSql.execute(f'insert into `{ctb_name}` values (now,1)') for ntb_name in self.ntb_names: - tdSql.execute(f'create table {ntb_name} (ts timestamp,c0 int)') - tdSql.execute(f'insert into {ntb_name} values (now,1)') + tdSql.execute(f'create table `{ntb_name}` (ts timestamp,c0 int)') + tdSql.execute(f'insert into `{ntb_name}` values (now,1)') def drop_table_check_end(self): for db_name in self.db_names: tdSql.execute(f'drop database {db_name}') @@ -174,7 +174,7 @@ class TDTestCase: tdSql.checkRows(8) tdSql.error(f'drop stable with information_schema.`ins_tables`;') tdSql.error(f'drop stable with performance_schema.`perf_connections`;') - self.drop_table_check_end() + self.drop_table_check_end() def drop_table_with_check(self): self.drop_table_check_init() tdSql.query(f'select * from information_schema.ins_tables where db_name like "dbtest_%"') @@ -199,6 +199,43 @@ class TDTestCase: tdSql.error(f'drop table with information_schema.`ins_tables`;') tdSql.error(f'drop table with performance_schema.`perf_connections`;') self.drop_table_check_end() + def drop_table_with_check_tsma(self): + tdSql.execute(f'create database if not exists {self.dbname} {self.vgroups_opt}') + tdSql.execute(f'use {self.dbname}') + tdSql.execute(f'create table {self.dbname}.stb (ts timestamp,c0 int) tags(t0 int)') + tdSql.execute(f'create tsma stb_tsma on {self.dbname}.stb function(avg(c0),count(c0)) interval(1d)') + tdSql.execute(f'create table {self.dbname}.ctb using {self.dbname}.stb tags(0)') + tdSql.execute(f'insert into {self.dbname}.ctb values (now,1)') + tdSql.execute(f'create table {self.dbname}.ntb (ts timestamp,c0 int)') + tdSql.execute(f'create tsma ntb_tsma on {self.dbname}.ntb function(avg(c0),count(c0)) interval(1d)') + tdSql.execute(f'insert into {self.dbname}.ntb values (now,1)') + tdSql.query(f'select * from information_schema.ins_tsmas where db_name = "{self.dbname}"') + tdSql.checkRows(2) + tdSql.query(f'select * from information_schema.ins_tables where db_name = "{self.dbname}" and type="CHILD_TABLE"') + tdSql.checkRows(1) + tdSql.execute(f'drop table with {tdSql.queryResult[0][1]}.`{tdSql.queryResult[0][5]}`') + tdSql.query(f'select * from information_schema.ins_tables where db_name = "{self.dbname}" and type="CHILD_TABLE"') + tdSql.checkRows(0) + tdSql.query(f'select * from information_schema.ins_stables where db_name = "{self.dbname}"') + tdSql.checkRows(1) + tdSql.error(f'drop table with {tdSql.queryResult[0][1]}.`{tdSql.queryResult[0][10]}`') + tdSql.query(f'select * from information_schema.ins_stables where db_name = "{self.dbname}"') + tdSql.error(f'drop stable with {tdSql.queryResult[0][1]}.`{tdSql.queryResult[0][10]}`') + tdSql.query(f'select * from information_schema.ins_stables where db_name = "{self.dbname}"') + tdSql.checkRows(1) + tdSql.query(f'select * from information_schema.ins_tables where db_name = "{self.dbname}" and type="NORMAL_TABLE"') + tdSql.checkRows(1) + tdSql.execute(f'drop table with {tdSql.queryResult[0][1]}.`{tdSql.queryResult[0][5]}`') + tdSql.query(f'select * from information_schema.ins_tables where db_name = "{self.dbname}" and type="NORMAL_TABLE"') + tdSql.checkRows(0) + tdSql.query(f'select * from information_schema.ins_tsmas where db_name = "{self.dbname}"') + tsmas = tdSql.queryResult + tdSql.checkEqual(len(tsmas),2) + for tsma in tsmas: + tdSql.execute(f'drop tsma {tsma[1]}.{tsma[0]}') + tdSql.query(f'show tsmas') + tdSql.checkRows(0) + tdSql.execute(f'drop database {self.dbname}') def drop_topic_check(self): tdSql.execute(f'create database {self.dbname} replica {self.replicaVar} wal_retention_period 3600') tdSql.execute(f'use {self.dbname}') @@ -246,6 +283,7 @@ class TDTestCase: self.drop_stb_ctb_check() self.drop_stable_with_check() self.drop_table_with_check() + self.drop_table_with_check_tsma() self.drop_topic_check() if platform.system().lower() == 'windows': self.drop_stream_check()