fetch/move in scan.l.
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/portalcmds.c,v 1.52 2006/09/02 18:17:17 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/portalcmds.c,v 1.53 2006/09/03 03:19:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
char *completionTag)
{
Portal portal;
- int64 nprocessed;
+ long nprocessed;
/*
* Disallow empty-string cursor name (conflicts with protocol-level
/* Return command status if wanted */
if (completionTag)
- snprintf(completionTag, COMPLETION_TAG_BUFSIZE, "%s " INT64_FORMAT,
+ snprintf(completionTag, COMPLETION_TAG_BUFSIZE, "%s %ld",
stmt->ismove ? "MOVE" : "FETCH",
nprocessed);
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.160 2006/09/02 18:17:17 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.161 2006/09/03 03:19:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static void _SPI_error_callback(void *arg);
-static void _SPI_cursor_operation(Portal portal, bool forward, int64 count,
+static void _SPI_cursor_operation(Portal portal, bool forward, long count,
DestReceiver *dest);
static _SPI_plan *_SPI_copy_plan(_SPI_plan *plan, int location);
* Fetch rows in a cursor
*/
void
-SPI_cursor_fetch(Portal portal, bool forward, int64 count)
+SPI_cursor_fetch(Portal portal, bool forward, long count)
{
_SPI_cursor_operation(portal, forward, count,
CreateDestReceiver(DestSPI, NULL));
* Move in a cursor
*/
void
-SPI_cursor_move(Portal portal, bool forward, int64 count)
+SPI_cursor_move(Portal portal, bool forward, long count)
{
_SPI_cursor_operation(portal, forward, count, None_Receiver);
}
* Do a FETCH or MOVE in a cursor
*/
static void
-_SPI_cursor_operation(Portal portal, bool forward, int64 count,
+_SPI_cursor_operation(Portal portal, bool forward, long count,
DestReceiver *dest)
{
- int64 nfetched;
+ long nfetched;
/* Check that the portal is valid */
if (!PortalIsValid(portal))
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.563 2006/09/03 00:46:41 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.564 2006/09/03 03:19:44 momjian Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
%union
{
int ival;
- int64 i64val;
char chr;
char *str;
const char *keyword;
%type <boolean> opt_varying opt_timezone
%type <ival> Iconst SignedIconst
-%type <i64val> SignedI64const
%type <str> Sconst comment_text
%type <str> RoleId opt_granted_by opt_boolean ColId_or_Sconst
%type <list> var_list var_list_or_default
/* Special token types, not actually keywords - see the "lex" file */
%token <str> IDENT FCONST SCONST BCONST XCONST Op
%token <ival> ICONST PARAM
-%token <i64val> I64CONST
/* precedence: lowest to highest */
%nonassoc SET /* see relation_expr_opt_alias */
n->howMany = $1;
$$ = (Node *)n;
}
- | ABSOLUTE_P SignedI64const
- {
- FetchStmt *n = makeNode(FetchStmt);
- n->direction = FETCH_ABSOLUTE;
- n->howMany = $2;
- $$ = (Node *)n;
- }
- | RELATIVE_P SignedI64const
- {
- FetchStmt *n = makeNode(FetchStmt);
- n->direction = FETCH_RELATIVE;
- n->howMany = $2;
- $$ = (Node *)n;
- }
- | SignedI64const
- {
- FetchStmt *n = makeNode(FetchStmt);
- n->direction = FETCH_FORWARD;
- n->howMany = $1;
- $$ = (Node *)n;
- }
| ALL
{
FetchStmt *n = makeNode(FetchStmt);
n->howMany = $2;
$$ = (Node *)n;
}
- | FORWARD SignedI64const
- {
- FetchStmt *n = makeNode(FetchStmt);
- n->direction = FETCH_FORWARD;
- n->howMany = $2;
- $$ = (Node *)n;
- }
| FORWARD ALL
{
FetchStmt *n = makeNode(FetchStmt);
n->howMany = $2;
$$ = (Node *)n;
}
- | BACKWARD SignedI64const
- {
- FetchStmt *n = makeNode(FetchStmt);
- n->direction = FETCH_BACKWARD;
- n->howMany = $2;
- $$ = (Node *)n;
- }
| BACKWARD ALL
{
FetchStmt *n = makeNode(FetchStmt);
SignedIconst: ICONST { $$ = $1; }
| '-' ICONST { $$ = - $2; }
;
-SignedI64const: I64CONST { $$ = $1; }
- | '-' I64CONST { $$ = - $2; }
- ;
/*
* Name classification hierarchy.
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.136 2006/09/02 18:17:17 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.137 2006/09/03 03:19:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#endif
)
{
- /* For Fetch/Move stmt, convert the string into int64 value */
- if((strcmp(yylval.keyword, "fetch")==0) || (strcmp(yylval.keyword, "move")==0))
- {
- int64 int64Val;
- errno = 0;
-
- int64Val = strtoll(yytext, &endptr, 10);
- if (*endptr != '\0' || errno == ERANGE)
- {
- yylval.str = pstrdup(yytext);
- return FCONST;
- }
- yylval.i64val = int64Val;
- return I64CONST;
- }
-
/* integer too large, treat it as a float */
yylval.str = pstrdup(yytext);
return FCONST;
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.504 2006/09/02 18:17:17 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.505 2006/09/03 03:19:44 momjian Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
* Process an "Execute" message for a portal
*/
static void
-exec_execute_message(const char *portal_name, int64 max_rows)
+exec_execute_message(const char *portal_name, long max_rows)
{
CommandDest dest;
DestReceiver *receiver;
case 'E': /* execute */
{
const char *portal_name;
- int64 max_rows;
+ int max_rows;
/* Set statement_timestamp() */
SetCurrentStatementStartTimestamp();
portal_name = pq_getmsgstring(&input_message);
- max_rows = pq_getmsgint64(&input_message);
+ max_rows = pq_getmsgint(&input_message, 4);
pq_getmsgend(&input_message);
exec_execute_message(portal_name, max_rows);
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/tcop/pquery.c,v 1.109 2006/09/03 01:15:40 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/tcop/pquery.c,v 1.110 2006/09/03 03:19:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
DestReceiver *dest,
char *completionTag);
static void FillPortalStore(Portal portal);
-static uint64 RunFromStore(Portal portal, ScanDirection direction, int64 count,
+static uint32 RunFromStore(Portal portal, ScanDirection direction, long count,
DestReceiver *dest);
-static int64 PortalRunSelect(Portal portal, bool forward, int64 count,
+static long PortalRunSelect(Portal portal, bool forward, long count,
DestReceiver *dest);
static void PortalRunUtility(Portal portal, Query *query,
DestReceiver *dest, char *completionTag);
static void PortalRunMulti(Portal portal,
DestReceiver *dest, DestReceiver *altdest,
char *completionTag);
-static int64 DoPortalRunFetch(Portal portal,
+static long DoPortalRunFetch(Portal portal,
FetchDirection fdirection,
- int64 count,
+ long count,
DestReceiver *dest);
static void DoPortalRewind(Portal portal);
* suspended due to exhaustion of the count parameter.
*/
bool
-PortalRun(Portal portal, int64 count,
+PortalRun(Portal portal, long count,
DestReceiver *dest, DestReceiver *altdest,
char *completionTag)
{
*
* Returns number of rows processed (suitable for use in result tag)
*/
-static int64
+static long
PortalRunSelect(Portal portal,
bool forward,
- int64 count,
+ long count,
DestReceiver *dest)
{
QueryDesc *queryDesc;
ScanDirection direction;
- uint64 nprocessed;
+ uint32 nprocessed;
/*
* NB: queryDesc will be NULL if we are fetching from a held cursor or a
if (!ScanDirectionIsNoMovement(direction))
{
- int64 oldPos;
+ long oldPos;
if (nprocessed > 0)
portal->atStart = false; /* OK to go backward now */
if (count == 0 ||
- (uint64) nprocessed < (uint64) count)
+ (unsigned long) nprocessed < (unsigned long) count)
portal->atEnd = true; /* we retrieved 'em all */
oldPos = portal->portalPos;
portal->portalPos += nprocessed;
portal->portalPos++; /* adjust for endpoint case */
}
if (count == 0 ||
- (uint64) nprocessed < (uint64) count)
+ (unsigned long) nprocessed < (unsigned long) count)
{
portal->atStart = true; /* we retrieved 'em all */
portal->portalPos = 0;
}
else
{
- int64 oldPos;
+ long oldPos;
oldPos = portal->portalPos;
portal->portalPos -= nprocessed;
* are run in the caller's memory context (since we have no estate). Watch
* out for memory leaks.
*/
-static uint64
-RunFromStore(Portal portal, ScanDirection direction, int64 count,
+static uint32
+RunFromStore(Portal portal, ScanDirection direction, long count,
DestReceiver *dest)
{
- int64 current_tuple_count = 0;
+ long current_tuple_count = 0;
TupleTableSlot *slot;
slot = MakeSingleTupleTableSlot(portal->tupDesc);
ExecDropSingleTupleTableSlot(slot);
- return (uint64) current_tuple_count;
+ return (uint32) current_tuple_count;
}
/*
*
* Returns number of rows processed (suitable for use in result tag)
*/
-int64
+long
PortalRunFetch(Portal portal,
FetchDirection fdirection,
- int64 count,
+ long count,
DestReceiver *dest)
{
- int64 result;
+ long result;
Portal saveActivePortal;
Snapshot saveActiveSnapshot;
ResourceOwner saveResourceOwner;
*
* Returns number of rows processed (suitable for use in result tag)
*/
-static int64
+static long
DoPortalRunFetch(Portal portal,
FetchDirection fdirection,
- int64 count,
+ long count,
DestReceiver *dest)
{
bool forward;
* we are. In any case, we arrange to fetch the target row
* going forwards.
*/
- if (portal->posOverflow || portal->portalPos == FETCH_ALL ||
+ if (portal->posOverflow || portal->portalPos == LONG_MAX ||
count - 1 <= portal->portalPos / 2)
{
DoPortalRewind(portal);
}
else
{
- int64 pos = portal->portalPos;
+ long pos = portal->portalPos;
if (portal->atEnd)
pos++; /* need one extra fetch if off end */
*/
if (!forward && count == FETCH_ALL && dest->mydest == DestNone)
{
- int64 result = portal->portalPos;
+ long result = portal->portalPos;
if (result > 0 && !portal->atEnd)
result--;
*
* spi.h
*
- * $PostgreSQL: pgsql/src/include/executor/spi.h,v 1.56 2006/09/02 18:17:17 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/executor/spi.h,v 1.57 2006/09/03 03:19:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern Portal SPI_cursor_open(const char *name, void *plan,
Datum *Values, const char *Nulls, bool read_only);
extern Portal SPI_cursor_find(const char *name);
-extern void SPI_cursor_fetch(Portal portal, bool forward, int64 count);
-extern void SPI_cursor_move(Portal portal, bool forward, int64 count);
+extern void SPI_cursor_fetch(Portal portal, bool forward, long count);
+extern void SPI_cursor_move(Portal portal, bool forward, long count);
extern void SPI_cursor_close(Portal portal);
extern void AtEOXact_SPI(bool isCommit);
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.328 2006/09/03 01:15:40 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.329 2006/09/03 03:19:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PARSENODES_H
#define PARSENODES_H
-#include "limits.h"
-
#include "nodes/primnodes.h"
#include "nodes/value.h"
FETCH_RELATIVE
} FetchDirection;
-#ifdef HAVE_INT64
-#define FETCH_ALL LLONG_MAX
-#else
#define FETCH_ALL LONG_MAX
-#endif
-
typedef struct FetchStmt
{
NodeTag type;
FetchDirection direction; /* see above */
- int64 howMany; /* number of rows, or position argument */
+ long howMany; /* number of rows, or position argument */
char *portalname; /* name of portal (cursor) */
bool ismove; /* TRUE if MOVE */
} FetchStmt;
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/tcop/pquery.h,v 1.38 2006/09/02 18:17:17 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/tcop/pquery.h,v 1.39 2006/09/03 03:19:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void PortalSetResultFormat(Portal portal, int nFormats,
int16 *formats);
-extern bool PortalRun(Portal portal, int64 count,
+extern bool PortalRun(Portal portal, long count,
DestReceiver *dest, DestReceiver *altdest,
char *completionTag);
-extern int64 PortalRunFetch(Portal portal,
+extern long PortalRunFetch(Portal portal,
FetchDirection fdirection,
- int64 count,
+ long count,
DestReceiver *dest);
#endif /* PQUERY_H */
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/utils/portal.h,v 1.68 2006/09/02 18:17:18 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/utils/portal.h,v 1.69 2006/09/03 03:19:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
bool atStart;
bool atEnd;
bool posOverflow;
- int64 portalPos;
+ long portalPos;
/* Presentation data, primarily used by the pg_cursors system view */
TimestampTz creation_time; /* time at which this portal was defined */