Merge pull request #11412 from taosdata/feature/3.0_liaohj

fix(query): load the null data in nchar/binary columns.
This commit is contained in:
Haojun Liao 2022-04-12 14:26:01 +08:00 committed by GitHub
commit ec0637df8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 57 deletions

View File

@ -737,7 +737,7 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int
int32_t type = pResultInfo->fields[i].type; int32_t type = pResultInfo->fields[i].type;
int32_t bytes = pResultInfo->fields[i].bytes; int32_t bytes = pResultInfo->fields[i].bytes;
if (type == TSDB_DATA_TYPE_NCHAR) { if (type == TSDB_DATA_TYPE_NCHAR && colLength[i] > 0) {
char* p = taosMemoryRealloc(pResultInfo->convertBuf[i], colLength[i]); char* p = taosMemoryRealloc(pResultInfo->convertBuf[i], colLength[i]);
if (p == NULL) { if (p == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;

View File

@ -1414,7 +1414,7 @@ static int32_t doCopyRowsFromFileBlock(STsdbReadHandle* pTsdbReadHandle, int32_t
} }
if (sVal.valType == TD_VTYPE_NULL) { if (sVal.valType == TD_VTYPE_NULL) {
colDataAppend(pColInfo, k, NULL, true); colDataAppendNULL(pColInfo, k);
} else { } else {
colDataAppend(pColInfo, k, sVal.val, false); colDataAppend(pColInfo, k, sVal.val, false);
} }
@ -1427,7 +1427,11 @@ static int32_t doCopyRowsFromFileBlock(STsdbReadHandle* pTsdbReadHandle, int32_t
TASSERT(0); TASSERT(0);
} }
colDataAppend(pColInfo, k, sVal.val, false); if (sVal.valType == TD_VTYPE_NULL) {
colDataAppendNULL(pColInfo, k);
} else {
colDataAppend(pColInfo, k, sVal.val, false);
}
} }
} }

View File

@ -6682,38 +6682,6 @@ bool validateExprColumnInfo(SQueriedTableInfo* pTableInfo, SExprBasicInfo* pExpr
return j != INT32_MIN; return j != INT32_MIN;
} }
static int32_t deserializeColFilterInfo(SColumnFilterInfo* pColFilters, int16_t numOfFilters, char** pMsg) {
for (int32_t f = 0; f < numOfFilters; ++f) {
SColumnFilterInfo* pFilterMsg = (SColumnFilterInfo*)(*pMsg);
SColumnFilterInfo* pColFilter = &pColFilters[f];
pColFilter->filterstr = htons(pFilterMsg->filterstr);
(*pMsg) += sizeof(SColumnFilterInfo);
if (pColFilter->filterstr) {
pColFilter->len = htobe64(pFilterMsg->len);
pColFilter->pz =
(int64_t)taosMemoryCalloc(1, (size_t)(pColFilter->len + 1 * TSDB_NCHAR_SIZE)); // note: null-terminator
if (pColFilter->pz == 0) {
return TSDB_CODE_QRY_OUT_OF_MEMORY;
}
memcpy((void*)pColFilter->pz, (*pMsg), (size_t)pColFilter->len);
(*pMsg) += (pColFilter->len + 1);
} else {
pColFilter->lowerBndi = htobe64(pFilterMsg->lowerBndi);
pColFilter->upperBndi = htobe64(pFilterMsg->upperBndi);
}
pColFilter->lowerRelOptr = htons(pFilterMsg->lowerRelOptr);
pColFilter->upperRelOptr = htons(pFilterMsg->upperRelOptr);
}
return TSDB_CODE_SUCCESS;
}
static SResSchema createResSchema(int32_t type, int32_t bytes, int32_t slotId, int32_t scale, int32_t precision, static SResSchema createResSchema(int32_t type, int32_t bytes, int32_t slotId, int32_t scale, int32_t precision,
const char* name) { const char* name) {
SResSchema s = {0}; SResSchema s = {0};

View File

@ -63,20 +63,21 @@ print =============== step2
$i = 1 $i = 1
$tb = $tbPrefix . $i $tb = $tbPrefix . $i
print ===> select diff(tbcol) from $tb print ===> select _rowts, diff(tbcol) from $tb
sql select diff(tbcol) from $tb sql select _rowts, diff(tbcol) from $tb
print ===> rows: $rows print ===> rows: $rows
print ===> $data00 $data01 $data02 $data03 $data04 $data05 print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15 print ===> $data10 $data11 $data12 $data13 $data14 $data15
if $data11 != 1 then if $data11 != 1 then
print expect 1, actual: $data11
return -1 return -1
endi endi
print =============== step3 print =============== step3
$cc = 4 * 60000 $cc = 4 * 60000
$ms = 1601481600000 + $cc $ms = 1601481600000 + $cc
print ===> select diff(tbcol) from $tb where ts > $ms print ===> select _rowts, diff(tbcol) from $tb where ts > $ms
sql select diff(tbcol) from $tb where ts > $ms sql select _rowts, diff(tbcol) from $tb where ts > $ms
print ===> rows: $rows print ===> rows: $rows
print ===> $data00 $data01 $data02 $data03 $data04 $data05 print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15 print ===> $data10 $data11 $data12 $data13 $data14 $data15
@ -86,8 +87,8 @@ endi
$cc = 4 * 60000 $cc = 4 * 60000
$ms = 1601481600000 + $cc $ms = 1601481600000 + $cc
print ===> select diff(tbcol) from $tb where ts <= $ms print ===> select _rowts, diff(tbcol) from $tb where ts <= $ms
sql select diff(tbcol) from $tb where ts <= $ms sql select _rowts, diff(tbcol) from $tb where ts <= $ms
print ===> rows: $rows print ===> rows: $rows
print ===> $data00 $data01 $data02 $data03 $data04 $data05 print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15 print ===> $data10 $data11 $data12 $data13 $data14 $data15
@ -96,8 +97,8 @@ if $data11 != 1 then
endi endi
print =============== step4 print =============== step4
print ===> select diff(tbcol) as b from $tb print ===> select _rowts, diff(tbcol) as b from $tb
sql select diff(tbcol) as b from $tb sql select _rowts, diff(tbcol) as b from $tb
print ===> rows: $rows print ===> rows: $rows
print ===> $data00 $data01 $data02 $data03 $data04 $data05 print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15 print ===> $data10 $data11 $data12 $data13 $data14 $data15
@ -105,24 +106,24 @@ if $data11 != 1 then
return -1 return -1
endi endi
print =============== step5 #print =============== step5
print ===> select diff(tbcol) as b from $tb interval(1m) #print ===> select diff(tbcol) as b from $tb interval(1m)
sql select diff(tbcol) as b from $tb interval(1m) -x step5 #sql select diff(tbcol) as b from $tb interval(1m) -x step5
return -1 # return -1
step5: #step5:
#
print =============== step6 #print =============== step6
$cc = 4 * 60000 #$cc = 4 * 60000
$ms = 1601481600000 + $cc #$ms = 1601481600000 + $cc
print ===> select diff(tbcol) as b from $tb where ts <= $ms interval(1m) #print ===> select diff(tbcol) as b from $tb where ts <= $ms interval(1m)
sql select diff(tbcol) as b from $tb where ts <= $ms interval(1m) -x step6 #sql select diff(tbcol) as b from $tb where ts <= $ms interval(1m) -x step6
return -1 # return -1
step6: step6:
print =============== clear print =============== clear
sql drop database $db sql drop database $db
sql show databases sql show databases
if $rows != 0 then if $rows != 1 then
return -1 return -1
endi endi