提交 748ec3fc 编写于 作者: A Alex Duan

[TS-207]<fix>(query): fixed compare_a function compare with length

上级 190ed525
......@@ -387,31 +387,38 @@ int32_t columnValueAscendingComparator(char *f1, char *f2, int32_t type, int32_t
case TSDB_DATA_TYPE_BINARY: {
int32_t len1 = varDataLen(f1);
int32_t len2 = varDataLen(f2);
if (len1 != len2) {
return len1 > len2? 1:-1;
} else {
int32_t ret = strncmp(varDataVal(f1), varDataVal(f2), len1);
if (ret == 0) {
return 0;
}
return (ret < 0) ? -1 : 1;
}
// compare zero length
if (len1 == 0 && len2 == 0)
return 0;
if(len1 == 0)
return -1;
if(len2 == 0)
return 1;
// compare context
int32_t ret = strncmp(varDataVal(f1), varDataVal(f2), len1);
if (ret == 0) {
return 0;
}
return (ret < 0) ? -1 : 1;
};
case TSDB_DATA_TYPE_NCHAR: { // todo handle the var string compare
int32_t len1 = varDataLen(f1);
int32_t len2 = varDataLen(f2);
if (len1 != len2) {
return len1 > len2 ? 1 : -1;
} else {
int32_t ret = tasoUcs4Compare(varDataVal(f1), varDataVal(f2), len1);
if (ret == 0) {
return 0;
}
return (ret < 0) ? -1 : 1;
// compare zero length
if (len1 == 0 && len2 == 0)
return 0;
if(len1 == 0)
return -1;
if(len2 == 0)
return 1;
// compare context
int32_t ret = tasoUcs4Compare(varDataVal(f1), varDataVal(f2), len1);
if (ret == 0) {
return 0;
}
return (ret < 0) ? -1 : 1;
};
case TSDB_DATA_TYPE_UTINYINT: DEFAULT_COMP(GET_UINT8_VAL(f1), GET_UINT8_VAL(f2));
case TSDB_DATA_TYPE_USMALLINT: DEFAULT_COMP(GET_UINT16_VAL(f1), GET_UINT16_VAL(f2));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册