未验证 提交 8ecdbc79 编写于 作者: D dapan1121 提交者: GitHub

Merge pull request #21448 from wangjiaming0909/fix/m/TD-24313

fix: core dump when select with interval caused by order
...@@ -258,7 +258,7 @@ static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t ...@@ -258,7 +258,7 @@ static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t
STimeWindow w = {0}; STimeWindow w = {0};
int64_t startKey = (order == TSDB_ORDER_ASC) ? win.skey : win.ekey; int64_t startKey = (order == TSDB_ORDER_ASC) ? win.skey : win.ekey;
getInitialStartTimeWindow(pInterval, startKey, &w, order); getInitialStartTimeWindow(pInterval, startKey, &w, order == TSDB_ORDER_ASC);
pInfo->pFillInfo = taosCreateFillInfo(w.skey, numOfCols, numOfNotFillCols, capacity, pInterval, fillType, pColInfo, pInfo->pFillInfo = taosCreateFillInfo(w.skey, numOfCols, numOfNotFillCols, capacity, pInterval, fillType, pColInfo,
pInfo->primaryTsCol, order, id); pInfo->primaryTsCol, order, id);
......
...@@ -561,7 +561,7 @@ int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t ma ...@@ -561,7 +561,7 @@ int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t ma
ASSERT(numOfRes >= numOfRows); ASSERT(numOfRes >= numOfRows);
} else { // reach the end of data } else { // reach the end of data
if ((ekey1 < pFillInfo->currentKey && FILL_IS_ASC_FILL(pFillInfo)) || if ((ekey1 < pFillInfo->currentKey && FILL_IS_ASC_FILL(pFillInfo)) ||
(ekey1 >= pFillInfo->currentKey && !FILL_IS_ASC_FILL(pFillInfo))) { (ekey1 > pFillInfo->currentKey && !FILL_IS_ASC_FILL(pFillInfo))) {
return 0; return 0;
} }
numOfRes = taosTimeCountInterval(ekey1, pFillInfo->currentKey, pFillInfo->interval.sliding, numOfRes = taosTimeCountInterval(ekey1, pFillInfo->currentKey, pFillInfo->interval.sliding,
......
...@@ -170,6 +170,42 @@ endi ...@@ -170,6 +170,42 @@ endi
# return -1 # return -1
#endi #endi
print ================ step10
print -------- create database and table
sql create database if not exists test
sql use test
sql create stable st (ts timestamp, c2 int) tags(tg int)
print -------- insert 300 rows data
$i = 0
while $i < 300
$t = 1577807983000
$cc = $i * 1000
$t = $t + $cc
sql select $i % 3
if $data00 != 0.000000000 then
goto continue_while
endi
sql select $i % 4
if $data00 == 0.000000000 then
goto continue_while
endi
sql insert into t1 using st tags(1) values ( $t , $i )
continue_while:
$i = $i + 1
endw
$ms1 = 1577808120000
$ms2 = 1577808000000
sql select * from (select _wstart, last(ts) as ts, avg(c2) as av from t1 where ts <= $ms1 and ts >= $ms2 interval(10s) sliding(1s) fill(NULL)) order by ts asc
print ----> select asc rows: $rows
$asc_rows = $rows
sql select * from (select _wstart, last(ts) as ts, avg(c2) as av from t1 where ts <= $ms1 and ts >= $ms2 interval(10s) sliding(1s) fill(NULL)) order by ts desc
print ----> select desc rows: $rows
$desc_rows = $rows
if $desc_rows != $asc_rows then
return -1
endi
print =============== clear print =============== clear
#sql drop database $db #sql drop database $db
#sql select * from information_schema.ins_databases #sql select * from information_schema.ins_databases
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册