未验证 提交 b4472552 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #3886 from taosdata/feature/os

Feature/os
...@@ -2445,8 +2445,8 @@ static bool percentile_function_setup(SQLFunctionCtx *pCtx) { ...@@ -2445,8 +2445,8 @@ static bool percentile_function_setup(SQLFunctionCtx *pCtx) {
// in the first round, get the min-max value of all involved data // in the first round, get the min-max value of all involved data
SResultInfo *pResInfo = GET_RES_INFO(pCtx); SResultInfo *pResInfo = GET_RES_INFO(pCtx);
SPercentileInfo *pInfo = pResInfo->interResultBuf; SPercentileInfo *pInfo = pResInfo->interResultBuf;
pInfo->minval = DBL_MAX; SET_DOUBLE_VAL(&pInfo->minval, DBL_MAX);
pInfo->maxval = -DBL_MAX; SET_DOUBLE_VAL(&pInfo->maxval, -DBL_MAX);
pInfo->numOfElems = 0; pInfo->numOfElems = 0;
return true; return true;
...@@ -2461,12 +2461,12 @@ static void percentile_function(SQLFunctionCtx *pCtx) { ...@@ -2461,12 +2461,12 @@ static void percentile_function(SQLFunctionCtx *pCtx) {
// the first stage, only acquire the min/max value // the first stage, only acquire the min/max value
if (pInfo->stage == 0) { if (pInfo->stage == 0) {
if (pCtx->preAggVals.isSet) { if (pCtx->preAggVals.isSet) {
if (pInfo->minval > pCtx->preAggVals.statis.min) { if (GET_DOUBLE_VAL(&pInfo->minval) > pCtx->preAggVals.statis.min) {
pInfo->minval = (double)pCtx->preAggVals.statis.min; SET_DOUBLE_VAL(&pInfo->minval, (double)pCtx->preAggVals.statis.min);
} }
if (pInfo->maxval < pCtx->preAggVals.statis.max) { if (GET_DOUBLE_VAL(&pInfo->maxval) < pCtx->preAggVals.statis.max) {
pInfo->maxval = (double)pCtx->preAggVals.statis.max; SET_DOUBLE_VAL(&pInfo->maxval, (double)pCtx->preAggVals.statis.max);
} }
pInfo->numOfElems += (pCtx->size - pCtx->preAggVals.statis.numOfNull); pInfo->numOfElems += (pCtx->size - pCtx->preAggVals.statis.numOfNull);
...@@ -2500,12 +2500,12 @@ static void percentile_function(SQLFunctionCtx *pCtx) { ...@@ -2500,12 +2500,12 @@ static void percentile_function(SQLFunctionCtx *pCtx) {
break; break;
} }
if (v < pInfo->minval) { if (v < GET_DOUBLE_VAL(&pInfo->minval)) {
pInfo->minval = v; SET_DOUBLE_VAL(&pInfo->minval, v);
} }
if (v > pInfo->maxval) { if (v > GET_DOUBLE_VAL(&pInfo->maxval)) {
pInfo->maxval = v; SET_DOUBLE_VAL(&pInfo->maxval, v);
} }
pInfo->numOfElems += 1; pInfo->numOfElems += 1;
...@@ -2564,12 +2564,12 @@ static void percentile_function_f(SQLFunctionCtx *pCtx, int32_t index) { ...@@ -2564,12 +2564,12 @@ static void percentile_function_f(SQLFunctionCtx *pCtx, int32_t index) {
break; break;
} }
if (v < pInfo->minval) { if (v < GET_DOUBLE_VAL(&pInfo->minval)) {
pInfo->minval = v; SET_DOUBLE_VAL(&pInfo->minval, v);
} }
if (v > pInfo->maxval) { if (v > GET_DOUBLE_VAL(&pInfo->maxval)) {
pInfo->maxval = v; SET_DOUBLE_VAL(&pInfo->maxval, v);
} }
pInfo->numOfElems += 1; pInfo->numOfElems += 1;
...@@ -2609,7 +2609,7 @@ static void percentile_next_step(SQLFunctionCtx *pCtx) { ...@@ -2609,7 +2609,7 @@ static void percentile_next_step(SQLFunctionCtx *pCtx) {
} }
pInfo->stage += 1; pInfo->stage += 1;
pInfo->pMemBucket = tMemBucketCreate(pCtx->inputBytes, pCtx->inputType, pInfo->minval, pInfo->maxval); pInfo->pMemBucket = tMemBucketCreate(pCtx->inputBytes, pCtx->inputType, GET_DOUBLE_VAL(&pInfo->minval), GET_DOUBLE_VAL(&pInfo->maxval));
} else { } else {
pResInfo->complete = true; pResInfo->complete = true;
} }
......
...@@ -194,9 +194,9 @@ static FORCE_INLINE bool isNull(const char *val, int32_t type) { ...@@ -194,9 +194,9 @@ static FORCE_INLINE bool isNull(const char *val, int32_t type) {
case TSDB_DATA_TYPE_DOUBLE: case TSDB_DATA_TYPE_DOUBLE:
return *(uint64_t *)val == TSDB_DATA_DOUBLE_NULL; return *(uint64_t *)val == TSDB_DATA_DOUBLE_NULL;
case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_NCHAR:
return *(uint32_t*) varDataVal(val) == TSDB_DATA_NCHAR_NULL; return varDataLen(val) == sizeof(int32_t) && *(uint32_t*) varDataVal(val) == TSDB_DATA_NCHAR_NULL;
case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_BINARY:
return *(uint8_t *) varDataVal(val) == TSDB_DATA_BINARY_NULL; return varDataLen(val) == sizeof(int8_t) && *(uint8_t *) varDataVal(val) == TSDB_DATA_BINARY_NULL;
default: default:
return false; return false;
}; };
......
...@@ -2284,7 +2284,7 @@ void filterPrepare(void* expr, void* param) { ...@@ -2284,7 +2284,7 @@ void filterPrepare(void* expr, void* param) {
if (pInfo->optr == TSDB_RELATION_IN) { if (pInfo->optr == TSDB_RELATION_IN) {
pInfo->q = (char*) pCond->arr; pInfo->q = (char*) pCond->arr;
} else { } else {
pInfo->q = calloc(1, pSchema->bytes); pInfo->q = calloc(1, pSchema->bytes + TSDB_NCHAR_SIZE); // to make sure tonchar does not cause invalid write, since the '\0' needs at least sizeof(wchar_t) space.
tVariantDump(pCond, pInfo->q, pSchema->type, true); tVariantDump(pCond, pInfo->q, pSchema->type, true);
} }
} }
......
...@@ -30,9 +30,11 @@ print =============== step 1 ...@@ -30,9 +30,11 @@ print =============== step 1
$x = $N $x = $N
$y = $N / 2 $y = $N / 2
while $x > $y while $x > $y
$ms = $x . m $z = $x * 60000
$ms = 1601481600000 - $z
$xt = - . $x $xt = - . $x
sql insert into $tb values (now - $ms , -$x ) sql insert into $tb values ($ms , -$x )
$x = $x - 1 $x = $x - 1
endw endw
...@@ -45,8 +47,10 @@ endi ...@@ -45,8 +47,10 @@ endi
$x = $N / 2 $x = $N / 2
$y = $N $y = $N
while $x < $y while $x < $y
$ms = $x . m $z = $x * 60000
sql insert into $tb values (now + $ms , $x ) $ms = 1601481600000 + $z
sql insert into $tb values ($ms , $x )
$x = $x + 1 $x = $x + 1
endw endw
sql select * from $tb sql select * from $tb
...@@ -60,14 +64,14 @@ print =============== step 2 ...@@ -60,14 +64,14 @@ print =============== step 2
$N1 = $N + 1 $N1 = $N + 1
$result1 = $N / 2 $result1 = $N / 2
$result2 = $N $result2 = $N
$step = $N1 . m $step = $N1 * 60000
$start1 = now- . $step $start1 = 1601481600000 - $step
$start2 = now $start2 = 1601481600000
$start3 = now+ . $step $start3 = 1601481600000 + $step
$end1 = now- . $step $end1 = 1601481600000 - $step
$end2 = now $end2 = 1601481600000
$end3 = now+ . $step $end3 = 1601481600000 + $step
sql select * from $tb where ts < $start1 and ts > $end1 sql select * from $tb where ts < $start1 and ts > $end1
if $rows != 0 then if $rows != 0 then
......
...@@ -33,7 +33,8 @@ while $i < $tbNum ...@@ -33,7 +33,8 @@ while $i < $tbNum
$x = 0 $x = 0
while $x < $rowNum while $x < $rowNum
$ms = $x . m $y = $x * 60000
$ms = 1600099200000 + $y
$c = $x / 100 $c = $x / 100
$c = $c * 100 $c = $c * 100
$c = $x - $c $c = $x - $c
...@@ -41,7 +42,7 @@ while $i < $tbNum ...@@ -41,7 +42,7 @@ while $i < $tbNum
$binary = $binary . ' $binary = $binary . '
$nchar = 'nchar . $c $nchar = 'nchar . $c
$nchar = $nchar . ' $nchar = $nchar . '
sql insert into $tb values (now + $ms , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) sql insert into $tb values ($ms , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar )
$x = $x + 1 $x = $x + 1
endw endw
...@@ -299,7 +300,8 @@ while $i < 1 ...@@ -299,7 +300,8 @@ while $i < 1
$x = 0 $x = 0
while $x < 10000 while $x < 10000
$ms = $x . m $y = $x * 60000
$ms = 1601481600000 + $y
$c = $x / 100 $c = $x / 100
$c = $c * 100 $c = $c * 100
$c = $x - $c $c = $x - $c
...@@ -307,7 +309,7 @@ while $i < 1 ...@@ -307,7 +309,7 @@ while $i < 1
$binary = $binary . ' $binary = $binary . '
$nchar = 'nchar . $c $nchar = 'nchar . $c
$nchar = $nchar . ' $nchar = $nchar . '
sql insert into $tb values (now + $ms , null , null , null , null , null , null , null , null , null ) sql insert into $tb values ($ms , null , null , null , null , null , null , null , null , null )
$x = $x + 1 $x = $x + 1
endw endw
......
...@@ -289,3 +289,5 @@ endi ...@@ -289,3 +289,5 @@ endi
if $data09 != 20 then if $data09 != 20 then
return -1 return -1
endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
...@@ -29,6 +29,9 @@ system sh/exec.sh -n dnode3 -s start ...@@ -29,6 +29,9 @@ system sh/exec.sh -n dnode3 -s start
sleep 3000 sleep 3000
$maxNum = 102
$maxNum = 12
$x = 0 $x = 0
show2: show2:
$x = $x + 1 $x = $x + 1
...@@ -58,7 +61,7 @@ endi ...@@ -58,7 +61,7 @@ endi
print ============================== step3 print ============================== step3
$count = 2 $count = 2
while $count < 102 while $count < $maxNum
$db = d . $count $db = d . $count
$tb = $db . .t $tb = $db . .t
$tb2 = $db . .t2 $tb2 = $db . .t2
...@@ -73,7 +76,7 @@ endw ...@@ -73,7 +76,7 @@ endw
print ============================== step4 print ============================== step4
$count = 2 $count = 2
while $count < 102 while $count < $maxNum
$db = d . $count $db = d . $count
$tb = $db . .t $tb = $db . .t
sql select * from $tb sql select * from $tb
...@@ -131,7 +134,7 @@ show8: ...@@ -131,7 +134,7 @@ show8:
endi endi
$count = 2 $count = 2
while $count < 102 while $count < $maxNum
$db = d . $count $db = d . $count
$tb = $db . .t $tb = $db . .t
sql select * from $tb sql select * from $tb
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册