Index: src/backend/commands/portalcmds.c =================================================================== RCS file: /cvsroot/pgsql-server/src/backend/commands/portalcmds.c,v retrieving revision 1.6 diff -c -c -r1.6 portalcmds.c *** src/backend/commands/portalcmds.c 15 Dec 2002 16:17:42 -0000 1.6 --- src/backend/commands/portalcmds.c 27 Dec 2002 13:52:37 -0000 *************** *** 65,71 **** void PerformPortalFetch(char *name, bool forward, ! int count, CommandDest dest, char *completionTag) { --- 65,71 ---- void PerformPortalFetch(char *name, bool forward, ! long count, CommandDest dest, char *completionTag) { *************** *** 100,113 **** return; } ! /* If zero count, we are done */ if (count == 0) ! return; /* Internally, zero count processes all portal rows */ ! if (count == INT_MAX) count = 0; ! /* * switch into the portal context */ --- 100,147 ---- return; } ! /* If zero count, handle specially */ if (count == 0) ! { ! bool on_row = false; ! ! /* Are we sitting on a row? */ ! oldcontext = MemoryContextSwitchTo(PortalGetHeapMemory(portal)); ! queryDesc = PortalGetQueryDesc(portal); ! estate = queryDesc->estate; ! if (portal->atStart == false && portal->atEnd == false) ! on_row = true; ! MemoryContextSwitchTo(oldcontext); ! ! if (dest == None) ! { ! /* MOVE 0 returns 0/1 based on if FETCH 0 would return a row */ ! if (completionTag && on_row) ! strcpy(completionTag, "MOVE 1"); ! return; ! } ! else ! { ! /* If we are not on a row, FETCH 0 returns nothing */ ! if (!on_row) ! return; ! ! /* Since we are sitting on a row, return the row */ ! /* Back up so we can reread the row */ ! PerformPortalFetch(name, false /* backward */, 1, ! None, /* throw away output */ ! NULL /* do not modify the command tag */); ! ! /* Set up to fetch one row */ ! count = 1; ! forward = true; ! } ! } /* Internally, zero count processes all portal rows */ ! if (count == LONG_MAX) count = 0; ! /* * switch into the portal context */ Index: src/backend/parser/gram.y =================================================================== RCS file: /cvsroot/pgsql-server/src/backend/parser/gram.y,v retrieving revision 2.388 diff -c -c -r2.388 gram.y *** src/backend/parser/gram.y 12 Dec 2002 20:35:13 -0000 2.388 --- src/backend/parser/gram.y 27 Dec 2002 13:52:55 -0000 *************** *** 2731,2738 **** fetch_how_many: Iconst { $$ = $1; } | '-' Iconst { $$ = - $2; } ! | ALL { $$ = INT_MAX; } ! | LAST { $$ = INT_MAX; } | NEXT { $$ = 1; } | PRIOR { $$ = -1; } ; --- 2731,2738 ---- fetch_how_many: Iconst { $$ = $1; } | '-' Iconst { $$ = - $2; } ! | ALL { $$ = LONG_MAX; } ! | LAST { $$ = LONG_MAX; } | NEXT { $$ = 1; } | PRIOR { $$ = -1; } ; Index: src/backend/tcop/utility.c =================================================================== RCS file: /cvsroot/pgsql-server/src/backend/tcop/utility.c,v retrieving revision 1.185 diff -c -c -r1.185 utility.c *** src/backend/tcop/utility.c 6 Dec 2002 05:00:31 -0000 1.185 --- src/backend/tcop/utility.c 27 Dec 2002 13:53:01 -0000 *************** *** 257,263 **** FetchStmt *stmt = (FetchStmt *) parsetree; char *portalName = stmt->portalname; bool forward; ! int count; forward = (bool) (stmt->direction == FORWARD); --- 257,263 ---- FetchStmt *stmt = (FetchStmt *) parsetree; char *portalName = stmt->portalname; bool forward; ! long count; forward = (bool) (stmt->direction == FORWARD); Index: src/include/commands/portalcmds.h =================================================================== RCS file: /cvsroot/pgsql-server/src/include/commands/portalcmds.h,v retrieving revision 1.3 diff -c -c -r1.3 portalcmds.h *** src/include/commands/portalcmds.h 13 Nov 2002 00:44:09 -0000 1.3 --- src/include/commands/portalcmds.h 27 Dec 2002 13:53:05 -0000 *************** *** 25,31 **** * BadArg if forward invalid. * "ERROR" if portal not found. */ ! extern void PerformPortalFetch(char *name, bool forward, int count, CommandDest dest, char *completionTag); /* --- 25,31 ---- * BadArg if forward invalid. * "ERROR" if portal not found. */ ! extern void PerformPortalFetch(char *name, bool forward, long count, CommandDest dest, char *completionTag); /* Index: src/include/nodes/parsenodes.h =================================================================== RCS file: /cvsroot/pgsql-server/src/include/nodes/parsenodes.h,v retrieving revision 1.223 diff -c -c -r1.223 parsenodes.h *** src/include/nodes/parsenodes.h 12 Dec 2002 20:35:16 -0000 1.223 --- src/include/nodes/parsenodes.h 27 Dec 2002 13:53:11 -0000 *************** *** 1198,1204 **** { NodeTag type; int direction; /* FORWARD or BACKWARD */ ! int howMany; /* amount to fetch */ char *portalname; /* name of portal (cursor) */ bool ismove; /* TRUE if MOVE */ } FetchStmt; --- 1198,1204 ---- { NodeTag type; int direction; /* FORWARD or BACKWARD */ ! long howMany; /* amount to fetch */ char *portalname; /* name of portal (cursor) */ bool ismove; /* TRUE if MOVE */ } FetchStmt;