修复了关于rownum的4个bug。

1.最大值只有255,正常应该是无限大。
2.group by跟where rownum < n同时存在时,禁止将rownum优化成limit
3.groupy by后面没有rownum,而having后面有rownum时,会正常运行,正常应该报错。
4.union前后的子句如果有where rownum < n,并且还有含有order by的子查询时,禁止将order by优化删除掉。
This commit is contained in:
zhouxiongjia
2020-10-21 17:45:44 +08:00
parent 916c0cfbe0
commit dc80b79cc0
6 changed files with 89 additions and 3 deletions

View File

@ -1941,6 +1941,10 @@ static void reduce_orderby_recurse(Query* query, Node* jtnode, bool reduce)
/* Reduce orderby clause in subquery for join or from clause of more than one rte */
reduce_orderby_final(rte, reduce);
} else if (IsA(jtnode, FromExpr)) {
/* If there is ROWNUM, can not reduce orderby clause in subquery */
if (contain_rownum_walker(jtnode, NULL)) {
return;
}
FromExpr* f = (FromExpr*)jtnode;
ListCell* l = NULL;
bool flag = false;