提交 71d59281 编写于 作者: S shenglian zhou

fix: select * from (select * from t order by ts desc) order by ts

上级 874725d1
......@@ -1079,11 +1079,23 @@ static bool sortPriKeyOptMayBeOptimized(SLogicNode* pNode) {
if (!sortPriKeyOptIsPriKeyOrderBy(pSort->pSortKeys) || 1 != LIST_LENGTH(pSort->node.pChildren)) {
return false;
}
SNode* pChild;
FOREACH(pChild, pSort->node.pChildren) {
SLogicNode* pSortDescendent = optFindPossibleNode((SLogicNode*)pChild, sortPriKeyOptMayBeOptimized);
if (pSortDescendent != NULL) {
return false;
}
}
return true;
}
static int32_t sortPriKeyOptGetSequencingNodesImpl(SLogicNode* pNode, bool groupSort, bool* pNotOptimize,
SNodeList** pSequencingNodes) {
if (NULL != pNode->pLimit || NULL != pNode->pSlimit) {
*pNotOptimize = false;
return TSDB_CODE_SUCCESS;
}
switch (nodeType(pNode)) {
case QUERY_NODE_LOGIC_PLAN_SCAN: {
SScanLogicNode* pScan = (SScanLogicNode*)pNode;
......
......@@ -875,6 +875,7 @@
,,y,script,./test.sh -f tsim/query/udf_with_const.sim
,,y,script,./test.sh -f tsim/query/join_interval.sim
,,y,script,./test.sh -f tsim/query/unionall_as_table.sim
,,y,script,./test.sh -f tsim/query/multi_order_by.sim
,,y,script,./test.sh -f tsim/query/sys_tbname.sim
,,y,script,./test.sh -f tsim/query/groupby.sim
,,y,script,./test.sh -f tsim/query/event.sim
......
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
sql create database test;
sql use test;
sql create table t(ts timestamp, f int);
sql insert into t values(now,0)(now+1s, 1)(now+2s, 2)(now+3s,3)(now+4s,4)(now+5s,5)(now+6s,6)(now+7s,7)(now+8s,8)(now+9s,9)
sql select * from (select * from t order by ts desc limit 3 offset 2) order by ts;
print $data01 $data11 $data21
if $data01 != 5 then
return -1
endi
if $data11 != 6 then
return -1
endi
if $data21 != 7 then
return -1
endi
sql select * from (select * from t order by ts limit 3 offset 2) order by ts desc;
print $data01 $data11 $data21
if $data01 != 4 then
return -1
endi
if $data11 != 3 then
return -1
endi
if $data21 != 2 then
return -1
endi
sql select * from (select * from t order by ts desc limit 3 offset 2) order by ts desc;
print $data01 $data11 $data21
if $data01 != 7 then
return -1
endi
if $data11 != 6 then
return -1
endi
if $data21 != 5 then
return -1
endi
sql select * from (select * from t order by ts limit 3 offset 2) order by ts;
print $data01 $data11 $data21
if $data01 != 2 then
return -1
endi
if $data11 != 3 then
return -1
endi
if $data21 != 4 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册