提交 41e89bdc 编写于 作者: A Alex Duan

[TS-207]<fix>(query): strncmp with short length

上级 789c0474
......@@ -396,9 +396,14 @@ int32_t columnValueAscendingComparator(char *f1, char *f2, int32_t type, int32_t
return -1;
}
// compare context
int32_t ret = strncmp(varDataVal(f1), varDataVal(f2), len1>len2 ? len1:len2);
int32_t ret = strncmp(varDataVal(f1), varDataVal(f2), len1>len2 ? len2:len1);
if (ret == 0) {
return 0;
if (len1 > len2)
return 1;
else if(len1 < len2)
return -1;
else
return 0;
}
return (ret < 0) ? -1 : 1;
};
......@@ -414,9 +419,14 @@ int32_t columnValueAscendingComparator(char *f1, char *f2, int32_t type, int32_t
return -1;
}
// compare context
int32_t ret = tasoUcs4Compare(varDataVal(f1), varDataVal(f2), len1>len2 ? len1:len2);
int32_t ret = tasoUcs4Compare(varDataVal(f1), varDataVal(f2), len1>len2 ? len2:len1);
if (ret == 0) {
return 0;
if (len1 > len2)
return 1;
else if(len1 < len2)
return -1;
else
return 0;
}
return (ret < 0) ? -1 : 1;
};
......
......@@ -379,8 +379,8 @@ class TDTestCase:
tdSql.error("select count(*) from jsons1 group by jtag->'tag1' order by jtag")
tdSql.query("select count(*) from jsons1 group by jtag->'tag1' order by jtag->'tag1' desc")
tdSql.checkRows(8)
tdSql.checkData(0, 0, 2)
tdSql.checkData(0, 1, '"femail"')
tdSql.checkData(1, 0, 2)
tdSql.checkData(1, 1, '"femail"')
tdSql.checkData(2, 0, 1)
tdSql.checkData(2, 1, 11)
tdSql.checkData(5, 0, 1)
......@@ -398,8 +398,8 @@ class TDTestCase:
tdSql.checkData(2, 1, "false")
tdSql.checkData(5, 0, 1)
tdSql.checkData(5, 1, 11)
tdSql.checkData(7, 0, 2)
tdSql.checkData(7, 1, '"femail"')
tdSql.checkData(6, 0, 2)
tdSql.checkData(6, 1, '"femail"')
# test stddev with group by json tag
tdSql.query("select stddev(dataint) from jsons1 group by jtag->'tag1'")
......@@ -407,8 +407,8 @@ class TDTestCase:
tdSql.checkData(0, 1, None)
tdSql.checkData(1, 0, 0)
tdSql.checkData(1, 1, "null")
tdSql.checkData(7, 0, 11)
tdSql.checkData(7, 1, '"femail"')
tdSql.checkData(6, 0, 11)
tdSql.checkData(6, 1, '"femail"')
res = tdSql.getColNameList("select stddev(dataint) from jsons1 group by jsons1.jtag->'tag1'")
cname_list = []
......@@ -422,8 +422,8 @@ class TDTestCase:
tdSql.checkData(0, 1, 4)
tdSql.checkData(1, 1, 24)
tdSql.checkData(1, 2, None)
tdSql.checkData(10, 1, 1)
tdSql.checkData(10, 2, '"femail"')
tdSql.checkData(9, 1, 1)
tdSql.checkData(9, 2, '"femail"')
# test having
tdSql.query("select stddev(dataint) from jsons1 group by jtag->'tag1' having stddev(dataint) > 0")
......@@ -437,7 +437,7 @@ class TDTestCase:
tdSql.query("select jtag->'tag1' from (select jtag->'tag1', dataint from jsons1)")
tdSql.checkRows(11)
tdSql.checkData(0, 0, '"femail"')
tdSql.checkData(1, 0, '"femail"')
tdSql.checkData(2, 0, 5)
res = tdSql.getColNameList("select jtag->'tag1' from (select jtag->'tag1', dataint from jsons1)")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册