提交 f1741261 编写于 作者: A Alex Duan

[TS-207]<fix>(query): if tbname go old and case add

上级 748ec3fc
......@@ -819,7 +819,7 @@ SSDataBlock* doMultiwayMergeSort(void* param, bool* newgroup) {
pOneDataSrc->rowIdx, pIndex->colIndex);
char *data = pInfo->prevRow[i];
int32_t ret = columnValueAscendingComparator(data, newRow, pColInfo->info.type, pColInfo->info.bytes);
int32_t ret = columnValueAscendingComparator(data, newRow, pColInfo->info.type, pColInfo->info.bytes, true);
if (ret == 0) {
continue;
} else {
......@@ -881,7 +881,7 @@ static bool isSameGroup(SArray* orderColumnList, SSDataBlock* pBlock, char** dat
assert(pIndex->colId == pColInfo->info.colId);
char *data = dataCols[i];
int32_t ret = columnValueAscendingComparator(data, pColInfo->pData, pColInfo->info.type, pColInfo->info.bytes);
int32_t ret = columnValueAscendingComparator(data, pColInfo->pData, pColInfo->info.type, pColInfo->info.bytes, true);
if (ret == 0) {
continue;
} else {
......@@ -1067,7 +1067,7 @@ static int32_t doSlimitImpl(SOperatorInfo* pOperator, SSLimitOperatorInfo* pInfo
SColumnInfo *pColInfo = &pColInfoData->info;
char *d = rowIndex * pColInfo->bytes + (char *)pColInfoData->pData;
int32_t ret = columnValueAscendingComparator(pInfo->prevRow[i], d, pColInfo->type, pColInfo->bytes);
int32_t ret = columnValueAscendingComparator(pInfo->prevRow[i], d, pColInfo->type, pColInfo->bytes, true);
if (ret != 0) { // it is a new group
samegroup = false;
break;
......
......@@ -254,7 +254,7 @@ int32_t compare_d(tOrderDescriptor *, int32_t numOfRow1, int32_t s1, char *data1
struct SSDataBlock;
int32_t compare_aRv(struct SSDataBlock* pBlock, SArray* colIndex, int32_t numOfCols, int32_t rowIndex, char** buffer, int32_t order);
int32_t columnValueAscendingComparator(char *f1, char *f2, int32_t type, int32_t bytes);
int32_t columnValueAscendingComparator(char *f1, char *f2, int32_t type, int32_t bytes, bool lenFirst);
#ifdef __cplusplus
}
......
......@@ -366,7 +366,7 @@ static int32_t tsCompareFunc(TSKEY k1, TSKEY k2, int32_t order) {
}
}
int32_t columnValueAscendingComparator(char *f1, char *f2, int32_t type, int32_t bytes) {
int32_t columnValueAscendingComparator(char *f1, char *f2, int32_t type, int32_t bytes, bool lenFirst) {
if (type == TSDB_DATA_TYPE_JSON){
bool canReturn = true;
int32_t result = jsonCompareUnit(f1, f2, &canReturn);
......@@ -388,6 +388,13 @@ int32_t columnValueAscendingComparator(char *f1, char *f2, int32_t type, int32_t
int32_t len1 = varDataLen(f1);
int32_t len2 = varDataLen(f2);
// length first compare
if(lenFirst) {
if(len1 > len2)
return 1;
else if( len1 < len2)
return -1;
}
// compare zero length
if (len1 == 0 && len2 == 0)
return 0;
......@@ -406,6 +413,13 @@ int32_t columnValueAscendingComparator(char *f1, char *f2, int32_t type, int32_t
int32_t len1 = varDataLen(f1);
int32_t len2 = varDataLen(f2);
// length first compare
if(lenFirst) {
if(len1 > len2)
return 1;
else if( len1 < len2)
return -1;
}
// compare zero length
if (len1 == 0 && len2 == 0)
return 0;
......@@ -449,7 +463,7 @@ int32_t compare_a(tOrderDescriptor *pDescriptor, int32_t numOfRows1, int32_t s1,
}
} else {
SSchemaEx *pSchema = &pDescriptor->pColumnModel->pFields[colIdx];
int32_t ret = columnValueAscendingComparator(f1, f2, pSchema->field.type, pSchema->field.bytes);
int32_t ret = columnValueAscendingComparator(f1, f2, pSchema->field.type, pSchema->field.bytes, strcmp(pSchema->field.name, TSQL_TBNAME_L) == 0);
if (ret == 0) {
continue;
} else {
......@@ -478,7 +492,7 @@ int32_t compare_aRv(SSDataBlock* pBlock, SArray* colIndex, int32_t numOfCols, in
return ret;
}
} else {
int32_t ret = columnValueAscendingComparator(data, buffer[i], pColInfo->info.type, pColInfo->info.bytes);
int32_t ret = columnValueAscendingComparator(data, buffer[i], pColInfo->info.type, pColInfo->info.bytes, false);
if (ret == 0) {
continue;
} else {
......@@ -510,7 +524,7 @@ int32_t compare_d(tOrderDescriptor *pDescriptor, int32_t numOfRows1, int32_t s1,
}
} else {
SSchemaEx *pSchema = &pDescriptor->pColumnModel->pFields[colIdx];
int32_t ret = columnValueAscendingComparator(f1, f2, pSchema->field.type, pSchema->field.bytes);
int32_t ret = columnValueAscendingComparator(f1, f2, pSchema->field.type, pSchema->field.bytes, strcmp(pSchema->field.name, TSQL_TBNAME_L) == 0);
if (ret == 0) {
continue;
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册