File tree 8 files changed +36
-21
lines changed 8 files changed +36
-21
lines changed Original file line number Diff line number Diff line change 1
1
<!--
2
- $Header: /cvsroot/pgsql/doc/src/sgml/ref/move.sgml,v 1.13 2002/04/21 19:02:39 thomas Exp $
2
+ $Header: /cvsroot/pgsql/doc/src/sgml/ref/move.sgml,v 1.14 2002/11/13 00:44:08 momjian Exp $
3
3
PostgreSQL documentation
4
4
-->
5
5
@@ -21,7 +21,8 @@ PostgreSQL documentation
21
21
<date>1999-07-20</date>
22
22
</refsynopsisdivinfo>
23
23
<synopsis>
24
- MOVE [ <replaceable class="PARAMETER">direction</replaceable> ] [ <replaceable class="PARAMETER">count</replaceable> ]
24
+ MOVE [ <replaceable class="PARAMETER">direction</replaceable> ]
25
+ {<replaceable class="PARAMETER">count</replaceable> | LAST }
25
26
{ IN | FROM } <replaceable class="PARAMETER">cursor</replaceable>
26
27
</synopsis>
27
28
</refsynopsisdiv>
@@ -37,8 +38,9 @@ MOVE [ <replaceable class="PARAMETER">direction</replaceable> ] [ <replaceable c
37
38
<command>MOVE</command> allows a user to move cursor position a specified
38
39
number of rows.
39
40
<command>MOVE</command> works like the <command>FETCH</command> command,
40
- but only positions the cursor and does
41
- not return rows.
41
+ but only positions the cursor and does not return rows.
42
+ <replaceable class="PARAMETER">LAST</replaceable> moves to the end
43
+ of the cursor.
42
44
</para>
43
45
<para>
44
46
Refer to
Original file line number Diff line number Diff line change 8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $Header: /cvsroot/pgsql/src/backend/commands/portalcmds.c,v 1.3 2002/09/04 20:31:15 momjian Exp $
11
+ * $Header: /cvsroot/pgsql/src/backend/commands/portalcmds.c,v 1.4 2002/11/13 00:44:08 momjian Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
15
15
16
16
#include "postgres.h"
17
17
18
+ #include <limits.h>
19
+
18
20
#include "commands/portalcmds.h"
19
21
#include "executor/executor.h"
20
22
@@ -55,7 +57,7 @@ PortalCleanup(Portal portal)
55
57
*
56
58
* name: name of portal
57
59
* forward: forward or backward fetch?
58
- * count: # of tuples to fetch (0 implies all)
60
+ * count: # of tuples to fetch
59
61
* dest: where to send results
60
62
* completionTag: points to a buffer of size COMPLETION_TAG_BUFSIZE
61
63
* in which to store a command completion status string.
@@ -100,6 +102,14 @@ PerformPortalFetch(char *name,
100
102
return ;
101
103
}
102
104
105
+ /* If zero count, we are done */
106
+ if (count == 0 )
107
+ return ;
108
+
109
+ /* Internally, zero count processes all portal rows */
110
+ if (count == INT_MAX )
111
+ count = 0 ;
112
+
103
113
/*
104
114
* switch into the portal context
105
115
*/
Original file line number Diff line number Diff line change 27
27
*
28
28
*
29
29
* IDENTIFICATION
30
- * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.185 2002/11/13 00:39:46 momjian Exp $
30
+ * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.186 2002/11/13 00:44:08 momjian Exp $
31
31
*
32
32
*-------------------------------------------------------------------------
33
33
*/
@@ -1116,7 +1116,8 @@ lnext: ;
1116
1116
1117
1117
/*
1118
1118
* check our tuple count.. if we've processed the proper number
1119
- * then quit, else loop again and process more tuples..
1119
+ * then quit, else loop again and process more tuples. Zero
1120
+ * number_tuples means no limit.
1120
1121
*/
1121
1122
current_tuple_count ++ ;
1122
1123
if (numberTuples == current_tuple_count )
Original file line number Diff line number Diff line change 11
11
*
12
12
*
13
13
* IDENTIFICATION
14
- * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.376 2002/11/11 22:19:23 tgl Exp $
14
+ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.377 2002/11/13 00:44:08 momjian Exp $
15
15
*
16
16
* HISTORY
17
17
* AUTHOR DATE MAJOR EVENT
49
49
#include " postgres.h"
50
50
51
51
#include < ctype.h>
52
+ #include < limits.h>
52
53
53
54
#include " access/htup.h"
54
55
#include " catalog/index.h"
@@ -358,7 +359,7 @@ static void doNegateFloat(Value *v);
358
359
359
360
KEY
360
361
361
- LANCOMPILER LANGUAGE LEADING LEFT LEVEL LIKE LIMIT
362
+ LANCOMPILER LANGUAGE LAST LEADING LEFT LEVEL LIKE LIMIT
362
363
LISTEN LOAD LOCAL LOCALTIME LOCALTIMESTAMP LOCATION
363
364
LOCK_P
364
365
@@ -2661,7 +2662,7 @@ FetchStmt: FETCH direction fetch_how_many from_in name
2661
2662
if ($3 < 0 )
2662
2663
{
2663
2664
$3 = -$3 ;
2664
- $2 = (($2 == FORWARD)? BACKWARD: FORWARD);
2665
+ $2 = (($2 == FORWARD) ? BACKWARD: FORWARD);
2665
2666
}
2666
2667
n->direction = $2 ;
2667
2668
n->howMany = $3 ;
@@ -2729,8 +2730,8 @@ direction: FORWARD { $$ = FORWARD; }
2729
2730
fetch_how_many:
2730
2731
Iconst { $$ = $1 ; }
2731
2732
| ' -' Iconst { $$ = - $2 ; }
2732
- /* 0 means fetch all tuples */
2733
- | ALL { $$ = 0 ; }
2733
+ | ALL { $$ = INT_MAX; }
2734
+ | LAST { $$ = INT_MAX ; }
2734
2735
| NEXT { $$ = 1 ; }
2735
2736
| PRIOR { $$ = -1 ; }
2736
2737
;
@@ -7060,6 +7061,7 @@ unreserved_keyword:
7060
7061
| KEY
7061
7062
| LANGUAGE
7062
7063
| LANCOMPILER
7064
+ | LAST
7063
7065
| LEVEL
7064
7066
| LISTEN
7065
7067
| LOAD
Original file line number Diff line number Diff line change 8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.129 2002/11/11 22:19:23 tgl Exp $
11
+ * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.130 2002/11/13 00:44:09 momjian Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -172,6 +172,7 @@ static const ScanKeyword ScanKeywords[] = {
172
172
{"key" , KEY },
173
173
{"lancompiler" , LANCOMPILER },
174
174
{"language" , LANGUAGE },
175
+ {"last" , LAST },
175
176
{"leading" , LEADING },
176
177
{"left" , LEFT },
177
178
{"level" , LEVEL },
Original file line number Diff line number Diff line change 10
10
*
11
11
*
12
12
* IDENTIFICATION
13
- * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.180 2002/10/21 20:31:52 momjian Exp $
13
+ * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.181 2002/11/13 00:44:09 momjian Exp $
14
14
*
15
15
*-------------------------------------------------------------------------
16
16
*/
@@ -262,9 +262,8 @@ ProcessUtility(Node *parsetree,
262
262
forward = (bool ) (stmt -> direction == FORWARD );
263
263
264
264
/*
265
- * parser ensures that count is >= 0 and 'fetch ALL' -> 0
265
+ * parser ensures that count is >= 0
266
266
*/
267
-
268
267
count = stmt -> howMany ;
269
268
PerformPortalFetch (portalName , forward , count ,
270
269
(stmt -> ismove ) ? None : dest ,
Original file line number Diff line number Diff line change 7
7
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
8
8
* Portions Copyright (c) 1994, Regents of the University of California
9
9
*
10
- * $Id: portalcmds.h,v 1.2 2002/09/04 20:31:42 momjian Exp $
10
+ * $Id: portalcmds.h,v 1.3 2002/11/13 00:44:09 momjian Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
18
18
19
19
/*
20
20
* PerformPortalFetch
21
- * Performs the POSTQUEL function FETCH. Fetches count (or all if 0)
21
+ * Performs the POSTQUEL function FETCH. Fetches count
22
22
* tuples in portal with name in the forward direction iff goForward.
23
23
*
24
24
* Exceptions:
Original file line number Diff line number Diff line change 7
7
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
8
8
* Portions Copyright (c) 1994, Regents of the University of California
9
9
*
10
- * $Id: parsenodes.h,v 1.212 2002/11/11 22:19:24 tgl Exp $
10
+ * $Id: parsenodes.h,v 1.213 2002/11/13 00:44:09 momjian Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -1277,7 +1277,7 @@ typedef struct FetchStmt
1277
1277
{
1278
1278
NodeTag type ;
1279
1279
int direction ; /* FORWARD or BACKWARD */
1280
- int howMany ; /* amount to fetch ("ALL" --> 0) */
1280
+ int howMany ; /* amount to fetch */
1281
1281
char * portalname ; /* name of portal (cursor) */
1282
1282
bool ismove ; /* TRUE if MOVE */
1283
1283
} FetchStmt ;
You can’t perform that action at this time.
0 commit comments