|
27 | 27 | * Portions Copyright (c) 1994, Regents of the University of California |
28 | 28 | * |
29 | 29 | * IDENTIFICATION |
30 | | - * $PostgreSQL: pgsql/src/backend/executor/nodeWindowAgg.c,v 1.3 2009/01/01 17:23:42 momjian Exp $ |
| 30 | + * $PostgreSQL: pgsql/src/backend/executor/nodeWindowAgg.c,v 1.4 2009/03/27 18:30:21 tgl Exp $ |
31 | 31 | * |
32 | 32 | *------------------------------------------------------------------------- |
33 | 33 | */ |
@@ -480,7 +480,8 @@ eval_windowaggregates(WindowAggState *winstate) |
480 | 480 | spool_tuples(winstate,winstate->aggregatedupto); |
481 | 481 | tuplestore_select_read_pointer(winstate->buffer, |
482 | 482 | winstate->agg_ptr); |
483 | | -if (!tuplestore_gettupleslot(winstate->buffer, true,agg_row_slot)) |
| 483 | +if (!tuplestore_gettupleslot(winstate->buffer, true, true, |
| 484 | +agg_row_slot)) |
484 | 485 | break;/* must be end of partition */ |
485 | 486 | } |
486 | 487 |
|
@@ -1001,12 +1002,14 @@ ExecWindowAgg(WindowAggState *winstate) |
1001 | 1002 | /* |
1002 | 1003 | * Read the current row from the tuplestore, and save in ScanTupleSlot. |
1003 | 1004 | * (We can't rely on the outerplan's output slot because we may have to |
1004 | | - * read beyond the current row.) |
| 1005 | + * read beyond the current row. Also, we have to actually copy the row |
| 1006 | + * out of the tuplestore, since window function evaluation might cause |
| 1007 | + * the tuplestore to dump its state to disk.) |
1005 | 1008 | * |
1006 | 1009 | * Current row must be in the tuplestore, since we spooled it above. |
1007 | 1010 | */ |
1008 | 1011 | tuplestore_select_read_pointer(winstate->buffer,winstate->current_ptr); |
1009 | | -if (!tuplestore_gettupleslot(winstate->buffer, true, |
| 1012 | +if (!tuplestore_gettupleslot(winstate->buffer, true, true, |
1010 | 1013 | winstate->ss.ss_ScanTupleSlot)) |
1011 | 1014 | elog(ERROR,"unexpected end of tuplestore"); |
1012 | 1015 |
|
@@ -1589,14 +1592,14 @@ window_gettupleslot(WindowObject winobj, int64 pos, TupleTableSlot *slot) |
1589 | 1592 |
|
1590 | 1593 | while (winobj->seekpos>pos) |
1591 | 1594 | { |
1592 | | -if (!tuplestore_gettupleslot(winstate->buffer, false,slot)) |
| 1595 | +if (!tuplestore_gettupleslot(winstate->buffer, false,true,slot)) |
1593 | 1596 | elog(ERROR,"unexpected end of tuplestore"); |
1594 | 1597 | winobj->seekpos--; |
1595 | 1598 | } |
1596 | 1599 |
|
1597 | 1600 | while (winobj->seekpos<pos) |
1598 | 1601 | { |
1599 | | -if (!tuplestore_gettupleslot(winstate->buffer, true,slot)) |
| 1602 | +if (!tuplestore_gettupleslot(winstate->buffer, true,true,slot)) |
1600 | 1603 | elog(ERROR,"unexpected end of tuplestore"); |
1601 | 1604 | winobj->seekpos++; |
1602 | 1605 | } |
|