Skip to content

Commit 9fe802c

Browse files
committed
Fix brown-paper-bag bug in commit 0a459ce.
RANGE_OFFSET comparisons need to examine the first ORDER BY column, which isn't necessarily the first column in the incoming tuples. No idea how this slipped through initial testing. Per bug #15082 from Zhou Digoal. Discussion: https://postgr.es/m/151939899974.1461.9411971793110285476@wrigleys.postgresql.org
1 parent 8af87f4 commit 9fe802c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/backend/executor/nodeWindowAgg.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,6 +1559,7 @@ update_frameheadpos(WindowAggState *winstate)
15591559
* reach end of partition, we will leave frameheadpos = end+1 and
15601560
* framehead_slot empty.
15611561
*/
1562+
int sortCol = node->ordColIdx[0];
15621563
bool sub,
15631564
less;
15641565

@@ -1593,9 +1594,9 @@ update_frameheadpos(WindowAggState *winstate)
15931594
bool headisnull,
15941595
currisnull;
15951596

1596-
headval = slot_getattr(winstate->framehead_slot, 1,
1597+
headval = slot_getattr(winstate->framehead_slot, sortCol,
15971598
&headisnull);
1598-
currval = slot_getattr(winstate->ss.ss_ScanTupleSlot, 1,
1599+
currval = slot_getattr(winstate->ss.ss_ScanTupleSlot, sortCol,
15991600
&currisnull);
16001601
if (headisnull || currisnull)
16011602
{
@@ -1809,6 +1810,7 @@ update_frametailpos(WindowAggState *winstate)
18091810
* necessary. Note that if we reach end of partition, we will
18101811
* leave frametailpos = end+1 and frametail_slot empty.
18111812
*/
1813+
int sortCol = node->ordColIdx[0];
18121814
bool sub,
18131815
less;
18141816

@@ -1843,9 +1845,9 @@ update_frametailpos(WindowAggState *winstate)
18431845
bool tailisnull,
18441846
currisnull;
18451847

1846-
tailval = slot_getattr(winstate->frametail_slot, 1,
1848+
tailval = slot_getattr(winstate->frametail_slot, sortCol,
18471849
&tailisnull);
1848-
currval = slot_getattr(winstate->ss.ss_ScanTupleSlot, 1,
1850+
currval = slot_getattr(winstate->ss.ss_ScanTupleSlot, sortCol,
18491851
&currisnull);
18501852
if (tailisnull || currisnull)
18511853
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy