Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4e5a947

Browse files
committed
Make MOVE/FETCH 0 actually move/fetch 0. Add MOVE LAST to move to end
of cursor.
1 parent9b12ab6 commit4e5a947

File tree

8 files changed

+36
-21
lines changed

8 files changed

+36
-21
lines changed

‎doc/src/sgml/ref/move.sgml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
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 $
33
PostgreSQL documentation
44
-->
55

@@ -21,7 +21,8 @@ PostgreSQL documentation
2121
<date>1999-07-20</date>
2222
</refsynopsisdivinfo>
2323
<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 }
2526
{ IN | FROM } <replaceable class="PARAMETER">cursor</replaceable>
2627
</synopsis>
2728
</refsynopsisdiv>
@@ -37,8 +38,9 @@ MOVE [ <replaceable class="PARAMETER">direction</replaceable> ] [ <replaceable c
3738
<command>MOVE</command> allows a user to move cursor position a specified
3839
number of rows.
3940
<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.
4244
</para>
4345
<para>
4446
Refer to

‎src/backend/commands/portalcmds.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
*
99
*
1010
* 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 $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
1515

1616
#include"postgres.h"
1717

18+
#include<limits.h>
19+
1820
#include"commands/portalcmds.h"
1921
#include"executor/executor.h"
2022

@@ -55,7 +57,7 @@ PortalCleanup(Portal portal)
5557
*
5658
*name: name of portal
5759
*forward: forward or backward fetch?
58-
*count: # of tuples to fetch (0 implies all)
60+
*count: # of tuples to fetch
5961
*dest: where to send results
6062
*completionTag: points to a buffer of size COMPLETION_TAG_BUFSIZE
6163
*in which to store a command completion status string.
@@ -100,6 +102,14 @@ PerformPortalFetch(char *name,
100102
return;
101103
}
102104

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+
103113
/*
104114
* switch into the portal context
105115
*/

‎src/backend/executor/execMain.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*
2828
*
2929
* 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 $
3131
*
3232
*-------------------------------------------------------------------------
3333
*/
@@ -1116,7 +1116,8 @@ lnext:;
11161116

11171117
/*
11181118
* 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.
11201121
*/
11211122
current_tuple_count++;
11221123
if (numberTuples==current_tuple_count)

‎src/backend/parser/gram.y

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* 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 $
1515
*
1616
* HISTORY
1717
* AUTHORDATEMAJOR EVENT
@@ -49,6 +49,7 @@
4949
#include"postgres.h"
5050

5151
#include<ctype.h>
52+
#include<limits.h>
5253

5354
#include"access/htup.h"
5455
#include"catalog/index.h"
@@ -358,7 +359,7 @@ static void doNegateFloat(Value *v);
358359

359360
KEY
360361

361-
LANCOMPILER LANGUAGE LEADING LEFT LEVEL LIKE LIMIT
362+
LANCOMPILER LANGUAGELASTLEADING LEFT LEVEL LIKE LIMIT
362363
LISTEN LOAD LOCAL LOCALTIME LOCALTIMESTAMP LOCATION
363364
LOCK_P
364365

@@ -2661,7 +2662,7 @@ FetchStmt:FETCH direction fetch_how_many from_in name
26612662
if ($3 <0)
26622663
{
26632664
$3 = -$3;
2664-
$2 = (($2 == FORWARD)? BACKWARD: FORWARD);
2665+
$2 = (($2 == FORWARD)? BACKWARD: FORWARD);
26652666
}
26662667
n->direction =$2;
26672668
n->howMany =$3;
@@ -2729,8 +2730,8 @@ direction:FORWARD{ $$ = FORWARD; }
27292730
fetch_how_many:
27302731
Iconst{$$ =$1; }
27312732
|'-' Iconst{$$ = -$2; }
2732-
/* 0 means fetch all tuples*/
2733-
|ALL{$$ =0; }
2733+
| ALL{$$ = INT_MAX; }
2734+
|LAST{$$ =INT_MAX; }
27342735
| NEXT{$$ =1; }
27352736
| PRIOR{$$ = -1; }
27362737
;
@@ -7060,6 +7061,7 @@ unreserved_keyword:
70607061
| KEY
70617062
| LANGUAGE
70627063
| LANCOMPILER
7064+
| LAST
70637065
| LEVEL
70647066
| LISTEN
70657067
| LOAD

‎src/backend/parser/keywords.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* 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 $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -172,6 +172,7 @@ static const ScanKeyword ScanKeywords[] = {
172172
{"key",KEY},
173173
{"lancompiler",LANCOMPILER},
174174
{"language",LANGUAGE},
175+
{"last",LAST},
175176
{"leading",LEADING},
176177
{"left",LEFT},
177178
{"level",LEVEL},

‎src/backend/tcop/utility.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* 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 $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -262,9 +262,8 @@ ProcessUtility(Node *parsetree,
262262
forward= (bool) (stmt->direction==FORWARD);
263263

264264
/*
265-
* parser ensures that count is >= 0 and 'fetch ALL' -> 0
265+
* parser ensures that count is >= 0
266266
*/
267-
268267
count=stmt->howMany;
269268
PerformPortalFetch(portalName,forward,count,
270269
(stmt->ismove) ?None :dest,

‎src/include/commands/portalcmds.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
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 $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -18,7 +18,7 @@
1818

1919
/*
2020
* PerformPortalFetch
21-
*Performs the POSTQUEL function FETCH. Fetches count (or all if 0)
21+
*Performs the POSTQUEL function FETCH. Fetches count
2222
* tuples in portal with name in the forward direction iff goForward.
2323
*
2424
* Exceptions:

‎src/include/nodes/parsenodes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
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 $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1277,7 +1277,7 @@ typedef struct FetchStmt
12771277
{
12781278
NodeTagtype;
12791279
intdirection;/* FORWARD or BACKWARD */
1280-
inthowMany;/* amount to fetch("ALL" --> 0)*/
1280+
inthowMany;/* amount to fetch */
12811281
char*portalname;/* name of portal (cursor) */
12821282
boolismove;/* TRUE if MOVE */
12831283
}FetchStmt;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp