feat:[TD-23117] fix overflow in stack & add test case

This commit is contained in:
wangmm0220 2023-05-12 19:43:16 +08:00
parent e17a105eff
commit c95e314896
2 changed files with 18 additions and 8 deletions

View File

@ -908,13 +908,14 @@ static int32_t mndRetrieveTopic(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
colDataSetVal(pColInfo, numOfRows, (const char *)sql, false);
char schemaJson[TSDB_SHOW_SCHEMA_JSON_LEN + VARSTR_HEADER_SIZE] = {0};
char *schemaJson = taosMemoryMalloc(TSDB_SHOW_SCHEMA_JSON_LEN + VARSTR_HEADER_SIZE);
if(pTopic->subType == TOPIC_SUB_TYPE__COLUMN){
schemaToJson(pTopic->schema.pSchema, pTopic->schema.nCols, schemaJson);
}else if(pTopic->subType == TOPIC_SUB_TYPE__TABLE){
SStbObj *pStb = mndAcquireStb(pMnode, pTopic->stbName);
if (pStb == NULL) {
terrno = TSDB_CODE_MND_STB_NOT_EXIST;
taosMemoryFree(schemaJson);
return -1;
}
schemaToJson(pStb->pColumns, pStb->numOfColumns, schemaJson);
@ -926,6 +927,7 @@ static int32_t mndRetrieveTopic(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
colDataSetVal(pColInfo, numOfRows, (const char *)schemaJson, false);
taosMemoryFree(schemaJson);
char mete[4 + VARSTR_HEADER_SIZE] = {0};
if(pTopic->withMeta){

View File

@ -35,16 +35,24 @@ class TDTestCase:
tdLog.info("create topic")
tdSql.execute("create topic topic_1 as database db1")
tdSql.execute("create topic topic_2 as stable db1.st")
tdSql.execute("create topic topic_2 with meta as stable db1.st")
tdSql.execute("create topic topic_3 as select * from db1.nt")
tdSql.execute("create topic topic_4 as select ts,c3,c5 from db1.st")
tdSql.execute("create topic topic_4 as select ts,c3,c5,t2 from db1.st")
tdSql.query("select * from information_schema.ins_topics")
tdSql.query("select * from information_schema.ins_topics order by topic_name")
tdSql.checkRows(4)
# tdSql.checkData(0, 1, 51)
# tdSql.checkData(0, 4, 940)
# tdSql.checkData(1, 1, 23)
# tdSql.checkData(1, 4, None)
tdSql.checkData(0, 4, "NULL")
tdSql.checkData(0, 5, "no")
tdSql.checkData(0, 6, "db")
tdSql.checkData(1, 4, "[{\"name\":\"ts\",\"type\":\"TIMESTAMP\",\"length\":8},{\"name\":\"c1\",\"type\":\"INT\",\"length\":4},{\"name\":\"c2\",\"type\":\"BOOL\",\"length\":1},{\"name\":\"c3\",\"type\":\"TINYINT\",\"length\":1},{\"name\":\"c4\",\"type\":\"DOUBLE\",\"length\":8},{\"name\":\"c5\",\"type\":\"NCHAR\",\"length\":8}]")
tdSql.checkData(1, 5, "yes")
tdSql.checkData(1, 6, "stable")
tdSql.checkData(2, 4, "[{\"name\":\"ts\",\"type\":\"TIMESTAMP\",\"length\":8},{\"name\":\"c1\",\"type\":\"SMALLINT\",\"length\":2},{\"name\":\"c2\",\"type\":\"FLOAT\",\"length\":4},{\"name\":\"c3\",\"type\":\"VARCHAR\",\"length\":64},{\"name\":\"c4\",\"type\":\"BIGINT\",\"length\":8}]")
tdSql.checkData(2, 5, "no")
tdSql.checkData(2, 6, "column")
tdSql.checkData(3, 4, "[{\"name\":\"ts\",\"type\":\"TIMESTAMP\",\"length\":8},{\"name\":\"c3\",\"type\":\"TINYINT\",\"length\":1},{\"name\":\"c5\",\"type\":\"NCHAR\",\"length\":8},{\"name\":\"t2\",\"type\":\"FLOAT\",\"length\":4}]")
tdSql.checkData(3, 5, "no")
tdSql.checkData(3, 6, "column")
tdLog.printNoPrefix("======== test case end ...... ")