提交 234b9c86 编写于 作者: H Haojun Liao

[td-225] fix bugs when tag is NULL

上级 33d83cc5
......@@ -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,10 +4295,10 @@ 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
......
......@@ -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;
......@@ -1951,6 +1950,19 @@ int32_t tableGroupComparFn(const void *p1, const void *p2, const void *param) {
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))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册