Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit53823a0

Browse files
committed
Fix failure to set correct operator in window run condition
This was a simple omission in9d9c02c where the code didn't correctlyset the operator to use in the run condition OpExpr when the windowfunction was both monotonically increasing and decreasing.Bug discovered by Julien Roze, although he did not report it.Reported-by: Phil FlorentDiscussion:https://postgr.es/m/PA4P191MB160009A09B9D0624359278CFBA9F9@PA4P191MB1600.EURP191.PROD.OUTLOOK.COMBackpatch-through: 15, where9d9c02c was added
1 parentcf112c1 commit53823a0

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

‎src/backend/optimizer/path/allpaths.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2306,6 +2306,7 @@ find_window_run_conditions(Query *subquery, RangeTblEntry *rte, Index rti,
23062306
{
23072307
*keep_original= false;
23082308
runopexpr=opexpr;
2309+
runoperator=opexpr->opno;
23092310
break;
23102311
}
23112312

‎src/test/regress/expected/window.out

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3646,6 +3646,23 @@ WHERE c <= 3;
36463646
3 | sales | 4800 | 3
36473647
(8 rows)
36483648

3649+
-- Ensure we get the correct run condition when the window function is both
3650+
-- monotonically increasing and decreasing.
3651+
EXPLAIN (COSTS OFF)
3652+
SELECT * FROM
3653+
(SELECT empno,
3654+
depname,
3655+
salary,
3656+
count(empno) OVER () c
3657+
FROM empsalary) emp
3658+
WHERE c = 1;
3659+
QUERY PLAN
3660+
--------------------------------------------------------
3661+
WindowAgg
3662+
Run Condition: (count(empsalary.empno) OVER (?) = 1)
3663+
-> Seq Scan on empsalary
3664+
(3 rows)
3665+
36493666
-- Some more complex cases with multiple window clauses
36503667
EXPLAIN (COSTS OFF)
36513668
SELECT * FROM

‎src/test/regress/sql/window.sql

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,17 @@ SELECT * FROM
11501150
FROM empsalary) emp
11511151
WHERE c<=3;
11521152

1153+
-- Ensure we get the correct run condition when the window function is both
1154+
-- monotonically increasing and decreasing.
1155+
EXPLAIN (COSTS OFF)
1156+
SELECT*FROM
1157+
(SELECT empno,
1158+
depname,
1159+
salary,
1160+
count(empno) OVER () c
1161+
FROM empsalary) emp
1162+
WHERE c=1;
1163+
11531164
-- Some more complex cases with multiple window clauses
11541165
EXPLAIN (COSTS OFF)
11551166
SELECT*FROM

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp