From c2afd95c4e7dc273ae506eb8fc015c41a277c485 Mon Sep 17 00:00:00 2001 From: wangjiaming0909 <604227650@qq.com> Date: Wed, 3 Apr 2024 10:07:02 +0800 Subject: [PATCH] fix taosd crash query ins_tags with empty nchar tag --- source/libs/executor/src/sysscanoperator.c | 5 ++++- tests/system-test/0-others/information_schema.py | 13 ++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/source/libs/executor/src/sysscanoperator.c b/source/libs/executor/src/sysscanoperator.c index 628aacf3c3..903e2f85aa 100644 --- a/source/libs/executor/src/sysscanoperator.c +++ b/source/libs/executor/src/sysscanoperator.c @@ -983,7 +983,10 @@ static int32_t sysTableUserTagsFillOneTableTags(const SSysTableScanInfo* pInfo, : (3 + DBL_MANT_DIG - DBL_MIN_EXP + VARSTR_HEADER_SIZE); tagVarChar = taosMemoryCalloc(1, bufSize + 1); int32_t len = -1; - convertTagDataToStr(varDataVal(tagVarChar), tagType, tagData, tagLen, &len); + if (tagLen > 0) + convertTagDataToStr(varDataVal(tagVarChar), tagType, tagData, tagLen, &len); + else + len = 0; varDataSetLen(tagVarChar, len); } } diff --git a/tests/system-test/0-others/information_schema.py b/tests/system-test/0-others/information_schema.py index 63718417b4..c3d65482fc 100644 --- a/tests/system-test/0-others/information_schema.py +++ b/tests/system-test/0-others/information_schema.py @@ -50,10 +50,11 @@ class TDTestCase: self.tbnum = 20 self.rowNum = 10 self.tag_dict = { - 't0':'int' + 't0':'int', + 't1':f'nchar({self.nchar_length})' } self.tag_values = [ - f'1' + f'1', '""' ] self.binary_str = 'taosdata' self.nchar_str = '涛思数据' @@ -72,7 +73,7 @@ class TDTestCase: tdSql.execute(f'use {self.dbname}') tdSql.execute(self.setsql.set_create_stable_sql(self.stbname,self.column_dict,self.tag_dict)) for i in range(self.tbnum): - tdSql.execute(f"create table {self.stbname}_{i} using {self.stbname} tags({self.tag_values[0]})") + tdSql.execute(f"create table {self.stbname}_{i} using {self.stbname} tags({self.tag_values[0]}, {self.tag_values[1]})") self.insert_data(self.column_dict,f'{self.stbname}_{i}',self.rowNum) def count_check(self): tdSql.query('select count(*) from information_schema.ins_tables') @@ -313,6 +314,11 @@ class TDTestCase: tdSql.error('alter cluster "activeCode" ""') tdSql.execute('alter cluster "activeCode" "revoked"') + def test_query_ins_tags(self): + sql = f'select tag_name, tag_value from information_schema.ins_tags where table_name = "{self.stbname}_0"' + tdSql.query(sql) + tdSql.checkRows(2) + def run(self): self.prepare_data() self.count_check() @@ -322,6 +328,7 @@ class TDTestCase: self.ins_stable_check2() self.ins_dnodes_check() self.ins_grants_check() + self.test_query_ins_tags() def stop(self):