Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3bb248a

Browse files
committed
Guard against stopping when numberTuples=0 and counter wraps around.
1 parent b56af49 commit 3bb248a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/backend/executor/execMain.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*
2727
*
2828
* IDENTIFICATION
29-
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.195 2002/12/18 00:14:47 tgl Exp $
29+
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.196 2003/01/08 23:32:29 tgl Exp $
3030
*
3131
*-------------------------------------------------------------------------
3232
*/
@@ -166,7 +166,7 @@ ExecutorStart(QueryDesc *queryDesc)
166166
* except to start up/shut down the destination. Otherwise,
167167
* we retrieve up to 'count' tuples in the specified direction.
168168
*
169-
* Note: count = 0 is interpreted as no portal limit, e.g. run to
169+
* Note: count = 0 is interpreted as no portal limit, i.e., run to
170170
* completion.
171171
*
172172
* ----------------------------------------------------------------
@@ -846,6 +846,7 @@ ExecEndPlan(PlanState *planstate, EState *estate)
846846
*
847847
* processes the query plan to retrieve 'numberTuples' tuples in the
848848
* direction specified.
849+
*
849850
* Retrieves all tuples if numberTuples is 0
850851
*
851852
* result is either a slot containing the last tuple in the case
@@ -1091,10 +1092,10 @@ lnext: ;
10911092
/*
10921093
* check our tuple count.. if we've processed the proper number
10931094
* then quit, else loop again and process more tuples. Zero
1094-
* number_tuples means no limit.
1095+
* numberTuples means no limit.
10951096
*/
10961097
current_tuple_count++;
1097-
if (numberTuples == current_tuple_count)
1098+
if (numberTuples && numberTuples == current_tuple_count)
10981099
break;
10991100
}
11001101

0 commit comments

Comments
 (0)