diff options
| author | David Rowley | 2023-03-17 02:49:53 +0000 |
|---|---|---|
| committer | David Rowley | 2023-03-17 02:49:53 +0000 |
| commit | eb7d043c9bbadb75a87385113c578f1b30e9d195 (patch) | |
| tree | 079ecb710a843852853d6a59834f1410af35c0ca /src/test/regress/sql/window.sql | |
| parent | b9f8d1cbad7cdc4d0d29c5cdbb14e179a7111439 (diff) | |
Fix incorrect logic for determining safe WindowAgg run conditions
The logic added in 9d9c02ccd to determine when a qual can be used as a
WindowClause run condition failed to correctly check for subqueries in the
qual. This was being done correctly for normal subquery qual pushdowns,
it's just that 9d9c02ccd failed to follow the lead on that.
This also fixes various other cases where transforming the qual into a
WindowClause run condition in the subquery should have been disallowed.
Bug: #17826
Reported-by: Anban Company
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 15, where 9d9c02ccd was introduced.
Diffstat (limited to 'src/test/regress/sql/window.sql')
| -rw-r--r-- | src/test/regress/sql/window.sql | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/test/regress/sql/window.sql b/src/test/regress/sql/window.sql index 1009b438def..3ab6ac715d0 100644 --- a/src/test/regress/sql/window.sql +++ b/src/test/regress/sql/window.sql @@ -1259,15 +1259,24 @@ SELECT * FROM FROM empsalary) emp WHERE 3 <= c; --- Ensure we don't pushdown when there are multiple window clauses to evaluate +-- Ensure we don't use a run condition when there's a volatile function in the +-- WindowFunc EXPLAIN (COSTS OFF) SELECT * FROM (SELECT empno, salary, - count(*) OVER (ORDER BY empno DESC) c, - dense_rank() OVER (ORDER BY salary DESC) dr + count(random()) OVER (ORDER BY empno DESC) c FROM empsalary) emp -WHERE dr = 1; +WHERE c = 1; + +-- Ensure we don't use a run condition when the WindowFunc contains subplans +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + salary, + count((SELECT 1)) OVER (ORDER BY empno DESC) c + FROM empsalary) emp +WHERE c = 1; -- Test Sort node collapsing EXPLAIN (COSTS OFF) |
