Commit 9fe802c8 authored by Tom Lane's avatar Tom Lane

Fix brown-paper-bag bug in commit 0a459cec.

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
parent 8af87f41
...@@ -1559,6 +1559,7 @@ update_frameheadpos(WindowAggState *winstate) ...@@ -1559,6 +1559,7 @@ update_frameheadpos(WindowAggState *winstate)
* reach end of partition, we will leave frameheadpos = end+1 and * reach end of partition, we will leave frameheadpos = end+1 and
* framehead_slot empty. * framehead_slot empty.
*/ */
int sortCol = node->ordColIdx[0];
bool sub, bool sub,
less; less;
...@@ -1593,9 +1594,9 @@ update_frameheadpos(WindowAggState *winstate) ...@@ -1593,9 +1594,9 @@ update_frameheadpos(WindowAggState *winstate)
bool headisnull, bool headisnull,
currisnull; currisnull;
headval = slot_getattr(winstate->framehead_slot, 1, headval = slot_getattr(winstate->framehead_slot, sortCol,
&headisnull); &headisnull);
currval = slot_getattr(winstate->ss.ss_ScanTupleSlot, 1, currval = slot_getattr(winstate->ss.ss_ScanTupleSlot, sortCol,
&currisnull); &currisnull);
if (headisnull || currisnull) if (headisnull || currisnull)
{ {
...@@ -1809,6 +1810,7 @@ update_frametailpos(WindowAggState *winstate) ...@@ -1809,6 +1810,7 @@ update_frametailpos(WindowAggState *winstate)
* necessary. Note that if we reach end of partition, we will * necessary. Note that if we reach end of partition, we will
* leave frametailpos = end+1 and frametail_slot empty. * leave frametailpos = end+1 and frametail_slot empty.
*/ */
int sortCol = node->ordColIdx[0];
bool sub, bool sub,
less; less;
...@@ -1843,9 +1845,9 @@ update_frametailpos(WindowAggState *winstate) ...@@ -1843,9 +1845,9 @@ update_frametailpos(WindowAggState *winstate)
bool tailisnull, bool tailisnull,
currisnull; currisnull;
tailval = slot_getattr(winstate->frametail_slot, 1, tailval = slot_getattr(winstate->frametail_slot, sortCol,
&tailisnull); &tailisnull);
currval = slot_getattr(winstate->ss.ss_ScanTupleSlot, 1, currval = slot_getattr(winstate->ss.ss_ScanTupleSlot, sortCol,
&currisnull); &currisnull);
if (tailisnull || currisnull) if (tailisnull || currisnull)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment