[td-225] fix bugs when tag is NULL
This commit is contained in:
parent
33d83cc539
commit
234b9c8611
|
@ -2206,8 +2206,18 @@ static void doSetTagValueInParam(void *tsdb, STableId* pTableId, int32_t tagColI
|
|||
}
|
||||
|
||||
if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) {
|
||||
if (isNull(varDataVal(val), type)) {
|
||||
tag->nType = TSDB_DATA_TYPE_NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
tVariantCreateFromBinary(tag, varDataVal(val), varDataLen(val), type);
|
||||
} else {
|
||||
if (isNull(val, type)) {
|
||||
tag->nType = TSDB_DATA_TYPE_NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
tVariantCreateFromBinary(tag, val, bytes, type);
|
||||
}
|
||||
}
|
||||
|
@ -4285,12 +4295,12 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
|
|||
assert(taosArrayGetSize(s) >= 1);
|
||||
|
||||
setTagVal(pRuntimeEnv, (STableId*) taosArrayGet(s, 0), pQInfo->tsdb);
|
||||
|
||||
if (isFirstLastRowQuery(pQuery)) {
|
||||
assert(taosArrayGetSize(s) == 1);
|
||||
}
|
||||
|
||||
taosArrayDestroy(s);
|
||||
|
||||
|
||||
// here we simply set the first table as current table
|
||||
pQuery->current = ((SGroupItem*) taosArrayGet(group, 0))->info;
|
||||
scanOneTableDataBlocks(pRuntimeEnv, pQuery->current->lastKey);
|
||||
|
|
|
@ -1930,8 +1930,7 @@ int32_t tableGroupComparFn(const void *p1, const void *p2, const void *param) {
|
|||
SColIndex* pColIndex = &pTableGroupSupp->pCols[i];
|
||||
int32_t colIndex = pColIndex->colIndex;
|
||||
|
||||
assert((colIndex >= 0 && colIndex < schemaNCols(pTableGroupSupp->pTagSchema)) ||
|
||||
(colIndex == TSDB_TBNAME_COLUMN_INDEX));
|
||||
assert(colIndex >= TSDB_TBNAME_COLUMN_INDEX);
|
||||
|
||||
char * f1 = NULL;
|
||||
char * f2 = NULL;
|
||||
|
@ -1950,7 +1949,20 @@ int32_t tableGroupComparFn(const void *p1, const void *p2, const void *param) {
|
|||
f1 = tdGetKVRowValOfCol(pTable1->tagVal, pCol->colId);
|
||||
f2 = tdGetKVRowValOfCol(pTable2->tagVal, pCol->colId);
|
||||
}
|
||||
|
||||
|
||||
// this tags value may be NULL
|
||||
if (f1 == NULL && f2 == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (f1 == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (f2 == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int32_t ret = doCompare(f1, f2, type, bytes);
|
||||
if (ret == 0) {
|
||||
continue;
|
||||
|
|
|
@ -9,7 +9,7 @@ sql connect
|
|||
$dbPrefix = db
|
||||
$tbPrefix = tb
|
||||
$stbPrefix = stb
|
||||
$tbNum = 1000
|
||||
$tbNum = 100
|
||||
$rowNum = 100
|
||||
$totalNum = $tbNum * $rowNum
|
||||
$ts0 = 1537146000000
|
||||
|
@ -26,7 +26,7 @@ $stb = $stbPrefix . $i
|
|||
sql drop database $db -x step1
|
||||
step1:
|
||||
sql create database $db
|
||||
print ====== create tables
|
||||
print ====== create $tbNum tables
|
||||
sql use $db
|
||||
sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 binary(9), t2 binary(8))
|
||||
|
||||
|
|
Loading…
Reference in New Issue