fix: select ins_columns from stb/ctb

This commit is contained in:
kailixu 2023-03-17 14:19:00 +08:00
parent 7ed966e3f1
commit a85e30efe6
2 changed files with 31 additions and 38 deletions

View File

@ -57,6 +57,7 @@ typedef struct SSysTableScanInfo {
const char* pUser; const char* pUser;
bool sysInfo; bool sysInfo;
bool showRewrite; bool showRewrite;
bool resume;
SNode* pCondition; // db_name filter condition, to discard data that are not in current database SNode* pCondition; // db_name filter condition, to discard data that are not in current database
SMTbCursor* pCur; // cursor for iterate the local table meta store. SMTbCursor* pCur; // cursor for iterate the local table meta store.
SSysTableIndex* pIdx; // idx for local table meta SSysTableIndex* pIdx; // idx for local table meta
@ -520,12 +521,15 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) {
taosHashSetFreeFp(pInfo->pSchema, tDeleteSSchemaWrapperForHash); taosHashSetFreeFp(pInfo->pSchema, tDeleteSSchemaWrapperForHash);
} }
while ((ret = metaTbCursorNext(pInfo->pCur, TSDB_TABLE_MAX)) == 0) { int32_t resume = pInfo->resume;
pInfo->resume = false;
while (resume || ((ret = metaTbCursorNext(pInfo->pCur, TSDB_TABLE_MAX)) == 0)) {
char typeName[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0}; char typeName[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
char tableName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; char tableName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
SSchemaWrapper* schemaRow = NULL; SSchemaWrapper* schemaRow = NULL;
if (resume) resume = false;
if (pInfo->pCur->mr.me.type == TSDB_SUPER_TABLE) { if (pInfo->pCur->mr.me.type == TSDB_SUPER_TABLE) {
qDebug("sysTableScanUserCols cursor get super table"); qDebug("sysTableScanUserCols cursor get super table");
void* schema = taosHashGet(pInfo->pSchema, &pInfo->pCur->mr.me.uid, sizeof(int64_t)); void* schema = taosHashGet(pInfo->pSchema, &pInfo->pCur->mr.me.uid, sizeof(int64_t));
@ -572,7 +576,7 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) {
if ((numOfRows + schemaRow->nCols) > pOperator->resultInfo.capacity) { if ((numOfRows + schemaRow->nCols) > pOperator->resultInfo.capacity) {
relocateAndFilterSysTagsScanResult(pInfo, numOfRows, dataBlock, pOperator->exprSupp.pFilterInfo); relocateAndFilterSysTagsScanResult(pInfo, numOfRows, dataBlock, pOperator->exprSupp.pFilterInfo);
numOfRows = 0; numOfRows = 0;
metaTbCursorPrev(pInfo->pCur); pInfo->resume = true;
if (pInfo->pRes->info.rows > 0) { if (pInfo->pRes->info.rows > 0) {
break; break;

View File

@ -101,47 +101,36 @@ class TDTestCase:
tdSql.checkEqual(i[1],len(self.perf_list)) tdSql.checkEqual(i[1],len(self.perf_list))
elif i[0].lower() == self.dbname: elif i[0].lower() == self.dbname:
tdSql.checkEqual(i[1],self.tbnum+1) tdSql.checkEqual(i[1],self.tbnum+1)
# def ins_columns_check(self): def ins_columns_check(self):
# tdSql.execute('drop database if exists db2') tdSql.execute('drop database if exists db2')
# tdSql.execute('create database if not exists db2 vgroups 2 replica 1') tdSql.execute('create database if not exists db2 vgroups 1 replica 1')
# tdSql.execute('create table db2.stb2 (ts timestamp,c0 int,c1 int, c2 double, c3 float, c4 binary(1000), c5 nchar(100),c7 bigint, c8 bool, c9 smallint) tags(t0 int)') for i in range (5):
# for i in range(2000): self.stb4096 = 'create table db2.stb%d (ts timestamp' % (i)
# tdSql.execute("create table db2.ctb%d using db2.stb2 tags(%d)" %(i,i)) for j in range (4094 - i):
# tdSql.query(f'select * from information_schema.ins_columns where db_name="db2" and table_type="CHILD_TABLE"') # for j in range (499):
# tdSql.checkEqual(20000,len(tdSql.queryResult)) self.stb4096 += ', c%d int' % (j)
# print("number of ins_columns of child table in db2 is %s" % len(tdSql.queryResult)) self.stb4096 += ') tags (t1 int)'
# def ins_columns_check(self): tdSql.execute(self.stb4096)
# tdSql.execute('drop database if exists db2') for k in range(10):
# tdSql.execute('create database if not exists db2 vgroups 1 replica 1') tdSql.execute("create table db2.ctb_%d_%dc using db2.stb%d tags(%d)" %(i,k,i,k))
# for i in range (5): tdSql.query(f'select * from information_schema.ins_columns where db_name="db2" and table_type=="SUPER_TABLE"')
# self.stb4096 = 'create table db2.stb%d (ts timestamp' % (i) tdSql.checkEqual(20465,len(tdSql.queryResult))
# for j in range (4094 - i): tdSql.query(f'select * from information_schema.ins_columns where db_name="db2" and table_type=="CHILD_TABLE"')
# # for j in range (499): tdSql.checkEqual(204650,len(tdSql.queryResult))
# self.stb4096 += ', c%d int' % (j)
# self.stb4096 += ') tags (t1 int)'
# tdSql.execute(self.stb4096)
# # print ("stb sql is %s" % (self.stb4096))
# for k in range(10):
# tdSql.execute("create table db2.ctb_%d_%dc using db2.stb%d tags(%d)" %(i,k,i,k))
# tdSql.query(f'select * from information_schema.ins_columns where db_name="db2" and table_type=="SUPER_TABLE"')
# tdSql.checkEqual(20465,len(tdSql.queryResult))
# tdSql.query(f'select * from information_schema.ins_columns where db_name="db2" and table_type=="CHILD_TABLE"')
# tdSql.checkEqual(20465,len(tdSql.queryResult))
# for j in range (5): for i in range (5):
# self.ntb4096 = 'create table db2.ntb%d (ts timestamp' % (j) self.ntb4096 = 'create table db2.ntb%d (ts timestamp' % (i)
# for i in range (4095 - j): for j in range (4095 - i):
# self.ntb4096 += ', c%d binary(10)' % (i) self.ntb4096 += ', c%d binary(10)' % (j)
# self.ntb4096 += ')' self.ntb4096 += ')'
# tdSql.execute(self.ntb4096) tdSql.execute(self.ntb4096)
# # print ("ntb sql is %s" % (self.ntb4096)) tdSql.query(f'select * from information_schema.ins_columns where db_name="db2" and table_type=="NORMAL_TABLE"')
# tdSql.query(f'select * from information_schema.ins_columns where db_name="db2" and table_type=="NORMAL_TABLE"') tdSql.checkEqual(204700,len(tdSql.queryResult))
# tdSql.checkEqual(20000,len(tdSql.queryResult))
def run(self): def run(self):
self.prepare_data() self.prepare_data()
self.count_check() self.count_check()
# self.ins_columns_check() self.ins_columns_check()
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success("%s successfully executed" % __file__) tdLog.success("%s successfully executed" % __file__)