aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeWindowAgg.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2018-02-23 15:11:40 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2018-02-23 15:11:40 -0500
commit9fe802c8185e9a53158b6797d0f6fd8bfbb01af1 (patch)
tree493273a7076eb287b6b00803346f93e47a3a7e55 /src/backend/executor/nodeWindowAgg.c
parent8af87f411c151537b6e3315c2a191110c3fec494 (diff)
downloadpostgresql-9fe802c8185e9a53158b6797d0f6fd8bfbb01af1.tar.gz
postgresql-9fe802c8185e9a53158b6797d0f6fd8bfbb01af1.zip
Fix brown-paper-bag bug in commit 0a459cec96d3856f476c2db298c6b52f592894e8.
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
Diffstat (limited to 'src/backend/executor/nodeWindowAgg.c')
-rw-r--r--src/backend/executor/nodeWindowAgg.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.c
index a56c3e89fd5..fe5369a0c7b 100644
--- a/src/backend/executor/nodeWindowAgg.c
+++ b/src/backend/executor/nodeWindowAgg.c
@@ -1559,6 +1559,7 @@ update_frameheadpos(WindowAggState *winstate)
* reach end of partition, we will leave frameheadpos = end+1 and
* framehead_slot empty.
*/
+ int sortCol = node->ordColIdx[0];
bool sub,
less;
@@ -1593,9 +1594,9 @@ update_frameheadpos(WindowAggState *winstate)
bool headisnull,
currisnull;
- headval = slot_getattr(winstate->framehead_slot, 1,
+ headval = slot_getattr(winstate->framehead_slot, sortCol,
&headisnull);
- currval = slot_getattr(winstate->ss.ss_ScanTupleSlot, 1,
+ currval = slot_getattr(winstate->ss.ss_ScanTupleSlot, sortCol,
&currisnull);
if (headisnull || currisnull)
{
@@ -1809,6 +1810,7 @@ update_frametailpos(WindowAggState *winstate)
* necessary. Note that if we reach end of partition, we will
* leave frametailpos = end+1 and frametail_slot empty.
*/
+ int sortCol = node->ordColIdx[0];
bool sub,
less;
@@ -1843,9 +1845,9 @@ update_frametailpos(WindowAggState *winstate)
bool tailisnull,
currisnull;
- tailval = slot_getattr(winstate->frametail_slot, 1,
+ tailval = slot_getattr(winstate->frametail_slot, sortCol,
&tailisnull);
- currval = slot_getattr(winstate->ss.ss_ScanTupleSlot, 1,
+ currval = slot_getattr(winstate->ss.ss_ScanTupleSlot, sortCol,
&currisnull);
if (tailisnull || currisnull)
{