Patch for - Change FETCH/MOVE to use int8
Patch for - Change FETCH/MOVE to use int8
От:
Dhanaraj M <Dhanaraj.M@Sun.COM>
Дата:
This patch is for the following TODO item.
SQL command:
-/Change LIMIT/OFFSET and FETCH/MOVE to use int8
/Since the limit/offset patch is already applied,
this patch is meant for Fetch/Move query.
I have tested the patch and it works for int64 values.
Please verify this.
Thanks
Dhanaraj
/
/
*** ./src/backend/commands/portalcmds.c.orig Sat Aug 12 23:04:54 2006
--- ./src/backend/commands/portalcmds.c Sat Aug 12 23:04:53 2006
***************
*** 176,183 ****
char *completionTag)
{
Portal portal;
! long nprocessed;
/*
* Disallow empty-string cursor name (conflicts with protocol-level
* unnamed portal).
--- 176,183 ----
char *completionTag)
{
Portal portal;
! int64 nprocessed;
/*
* Disallow empty-string cursor name (conflicts with protocol-level
* unnamed portal).
***************
*** 209,215 ****
/* Return command status if wanted */
if (completionTag)
! snprintf(completionTag, COMPLETION_TAG_BUFSIZE, "%s %ld",
stmt->ismove ? "MOVE" : "FETCH",
nprocessed);
}
--- 209,215 ----
/* Return command status if wanted */
if (completionTag)
! snprintf(completionTag, COMPLETION_TAG_BUFSIZE, "%s %lld",
stmt->ismove ? "MOVE" : "FETCH",
nprocessed);
}
*** ./src/backend/parser/gram.y.orig Sat Aug 12 23:04:57 2006
--- ./src/backend/parser/gram.y Sun Aug 13 00:06:28 2006
***************
*** 116,122 ****
%union
{
! int ival;
char chr;
char *str;
const char *keyword;
--- 116,122 ----
%union
{
! int64 ival;
char chr;
char *str;
const char *keyword;
***************
*** 1180,1192 ****
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("INTERVAL(%d) precision must not be negative",
! $3)));
if ($3 > MAX_INTERVAL_PRECISION)
{
ereport(WARNING,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("INTERVAL(%d) precision reduced to maximum allowed, %d",
! $3, MAX_INTERVAL_PRECISION)));
$3 = MAX_INTERVAL_PRECISION;
}
--- 1180,1192 ----
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("INTERVAL(%d) precision must not be negative",
! (int)$3)));
if ($3 > MAX_INTERVAL_PRECISION)
{
ereport(WARNING,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("INTERVAL(%d) precision reduced to maximum allowed, %d",
! (int)$3, MAX_INTERVAL_PRECISION)));
$3 = MAX_INTERVAL_PRECISION;
}
***************
*** 2620,2626 ****
ICONST
{
char buf[64];
! snprintf(buf, sizeof(buf), "%d", $1);
$$ = makeString(pstrdup(buf));
}
| FCONST { $$ = makeString($1); }
--- 2620,2626 ----
ICONST
{
char buf[64];
! snprintf(buf, sizeof(buf), "%d", (int)$1);
$$ = makeString(pstrdup(buf));
}
| FCONST { $$ = makeString($1); }
***************
*** 6281,6293 ****
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("INTERVAL(%d) precision must not be negative",
! $3)));
if ($3 > MAX_INTERVAL_PRECISION)
{
ereport(WARNING,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("INTERVAL(%d) precision reduced to maximum allowed, %d",
! $3, MAX_INTERVAL_PRECISION)));
$3 = MAX_INTERVAL_PRECISION;
}
$$->typmod = INTERVAL_TYPMOD($3, $5);
--- 6281,6293 ----
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("INTERVAL(%d) precision must not be negative",
! (int)$3)));
if ($3 > MAX_INTERVAL_PRECISION)
{
ereport(WARNING,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("INTERVAL(%d) precision reduced to maximum allowed, %d",
! (int)$3, MAX_INTERVAL_PRECISION)));
$3 = MAX_INTERVAL_PRECISION;
}
$$->typmod = INTERVAL_TYPMOD($3, $5);
***************
*** 6408,6419 ****
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("NUMERIC precision %d must be between 1 and %d",
! $2, NUMERIC_MAX_PRECISION)));
if ($4 < 0 || $4 > $2)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("NUMERIC scale %d must be between 0 and precision %d",
! $4, $2)));
$$ = (($2 << 16) | $4) + VARHDRSZ;
}
--- 6408,6419 ----
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("NUMERIC precision %d must be between 1 and %d",
! (int)$2, NUMERIC_MAX_PRECISION)));
if ($4 < 0 || $4 > $2)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("NUMERIC scale %d must be between 0 and precision %d",
! (int)$4, (int)$2)));
$$ = (($2 << 16) | $4) + VARHDRSZ;
}
***************
*** 6423,6429 ****
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("NUMERIC precision %d must be between 1 and %d",
! $2, NUMERIC_MAX_PRECISION)));
$$ = ($2 << 16) + VARHDRSZ;
}
--- 6423,6429 ----
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("NUMERIC precision %d must be between 1 and %d",
! (int)$2, NUMERIC_MAX_PRECISION)));
$$ = ($2 << 16) + VARHDRSZ;
}
***************
*** 6441,6452 ****
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("DECIMAL precision %d must be between 1 and %d",
! $2, NUMERIC_MAX_PRECISION)));
if ($4 < 0 || $4 > $2)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("DECIMAL scale %d must be between 0 and precision %d",
! $4, $2)));
$$ = (($2 << 16) | $4) + VARHDRSZ;
}
--- 6441,6452 ----
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("DECIMAL precision %d must be between 1 and %d",
! (int)$2, NUMERIC_MAX_PRECISION)));
if ($4 < 0 || $4 > $2)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("DECIMAL scale %d must be between 0 and precision %d",
! (int)$4, (int)$2)));
$$ = (($2 << 16) | $4) + VARHDRSZ;
}
***************
*** 6456,6462 ****
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("DECIMAL precision %d must be between 1 and %d",
! $2, NUMERIC_MAX_PRECISION)));
$$ = ($2 << 16) + VARHDRSZ;
}
--- 6456,6462 ----
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("DECIMAL precision %d must be between 1 and %d",
! (int)$2, NUMERIC_MAX_PRECISION)));
$$ = ($2 << 16) + VARHDRSZ;
}
***************
*** 6662,6674 ****
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("TIMESTAMP(%d)%s precision must not be negative",
! $3, ($5 ? " WITH TIME ZONE": ""))));
if ($3 > MAX_TIMESTAMP_PRECISION)
{
ereport(WARNING,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("TIMESTAMP(%d)%s precision reduced to maximum allowed, %d",
! $3, ($5 ? " WITH TIME ZONE": ""),
MAX_TIMESTAMP_PRECISION)));
$3 = MAX_TIMESTAMP_PRECISION;
}
--- 6662,6674 ----
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("TIMESTAMP(%d)%s precision must not be negative",
! (int)$3, ($5 ? " WITH TIME ZONE": ""))));
if ($3 > MAX_TIMESTAMP_PRECISION)
{
ereport(WARNING,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("TIMESTAMP(%d)%s precision reduced to maximum allowed, %d",
! (int)$3, ($5 ? " WITH TIME ZONE": ""),
MAX_TIMESTAMP_PRECISION)));
$3 = MAX_TIMESTAMP_PRECISION;
}
***************
*** 6695,6707 ****
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("TIME(%d)%s precision must not be negative",
! $3, ($5 ? " WITH TIME ZONE": ""))));
if ($3 > MAX_TIME_PRECISION)
{
ereport(WARNING,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("TIME(%d)%s precision reduced to maximum allowed, %d",
! $3, ($5 ? " WITH TIME ZONE": ""),
MAX_TIME_PRECISION)));
$3 = MAX_TIME_PRECISION;
}
--- 6695,6707 ----
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("TIME(%d)%s precision must not be negative",
! (int)$3, ($5 ? " WITH TIME ZONE": ""))));
if ($3 > MAX_TIME_PRECISION)
{
ereport(WARNING,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("TIME(%d)%s precision reduced to maximum allowed, %d",
! (int)$3, ($5 ? " WITH TIME ZONE": ""),
MAX_TIME_PRECISION)));
$3 = MAX_TIME_PRECISION;
}
***************
*** 7435,7447 ****
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("CURRENT_TIME(%d) precision must not be negative",
! $3)));
if ($3 > MAX_TIME_PRECISION)
{
ereport(WARNING,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("CURRENT_TIME(%d) precision reduced to maximum allowed, %d",
! $3, MAX_TIME_PRECISION)));
$3 = MAX_TIME_PRECISION;
}
d->typmod = $3;
--- 7435,7447 ----
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("CURRENT_TIME(%d) precision must not be negative",
! (int)$3)));
if ($3 > MAX_TIME_PRECISION)
{
ereport(WARNING,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("CURRENT_TIME(%d) precision reduced to maximum allowed, %d",
! (int)$3, MAX_TIME_PRECISION)));
$3 = MAX_TIME_PRECISION;
}
d->typmod = $3;
***************
*** 7480,7492 ****
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("CURRENT_TIMESTAMP(%d) precision must not be negative",
! $3)));
if ($3 > MAX_TIMESTAMP_PRECISION)
{
ereport(WARNING,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("CURRENT_TIMESTAMP(%d) precision reduced to maximum allowed, %d",
! $3, MAX_TIMESTAMP_PRECISION)));
$3 = MAX_TIMESTAMP_PRECISION;
}
d->typmod = $3;
--- 7480,7492 ----
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("CURRENT_TIMESTAMP(%d) precision must not be negative",
! (int)$3)));
if ($3 > MAX_TIMESTAMP_PRECISION)
{
ereport(WARNING,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("CURRENT_TIMESTAMP(%d) precision reduced to maximum allowed, %d",
! (int)$3, MAX_TIMESTAMP_PRECISION)));
$3 = MAX_TIMESTAMP_PRECISION;
}
d->typmod = $3;
***************
*** 7527,7539 ****
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("LOCALTIME(%d) precision must not be negative",
! $3)));
if ($3 > MAX_TIME_PRECISION)
{
ereport(WARNING,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("LOCALTIME(%d) precision reduced to maximum allowed, %d",
! $3, MAX_TIME_PRECISION)));
$3 = MAX_TIME_PRECISION;
}
d->typmod = $3;
--- 7527,7539 ----
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("LOCALTIME(%d) precision must not be negative",
! (int)$3)));
if ($3 > MAX_TIME_PRECISION)
{
ereport(WARNING,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("LOCALTIME(%d) precision reduced to maximum allowed, %d",
! (int)$3, MAX_TIME_PRECISION)));
$3 = MAX_TIME_PRECISION;
}
d->typmod = $3;
***************
*** 7575,7587 ****
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("LOCALTIMESTAMP(%d) precision must not be negative",
! $3)));
if ($3 > MAX_TIMESTAMP_PRECISION)
{
ereport(WARNING,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("LOCALTIMESTAMP(%d) precision reduced to maximum allowed, %d",
! $3, MAX_TIMESTAMP_PRECISION)));
$3 = MAX_TIMESTAMP_PRECISION;
}
d->typmod = $3;
--- 7575,7587 ----
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("LOCALTIMESTAMP(%d) precision must not be negative",
! (int)$3)));
if ($3 > MAX_TIMESTAMP_PRECISION)
{
ereport(WARNING,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("LOCALTIMESTAMP(%d) precision reduced to maximum allowed, %d",
! (int)$3, MAX_TIMESTAMP_PRECISION)));
$3 = MAX_TIMESTAMP_PRECISION;
}
d->typmod = $3;
***************
*** 8360,8372 ****
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("INTERVAL(%d) precision must not be negative",
! $3)));
if ($3 > MAX_INTERVAL_PRECISION)
{
ereport(WARNING,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("INTERVAL(%d) precision reduced to maximum allowed, %d",
! $3, MAX_INTERVAL_PRECISION)));
$3 = MAX_INTERVAL_PRECISION;
}
n->typename->typmod = INTERVAL_TYPMOD($3, $6);
--- 8360,8372 ----
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("INTERVAL(%d) precision must not be negative",
! (int)$3)));
if ($3 > MAX_INTERVAL_PRECISION)
{
ereport(WARNING,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("INTERVAL(%d) precision reduced to maximum allowed, %d",
! (int)$3, MAX_INTERVAL_PRECISION)));
$3 = MAX_INTERVAL_PRECISION;
}
n->typename->typmod = INTERVAL_TYPMOD($3, $6);
*** ./src/backend/parser/scan.l.orig Sat Aug 12 23:04:58 2006
--- ./src/backend/parser/scan.l Sat Aug 12 23:04:57 2006
***************
*** 666,671 ****
--- 666,690 ----
#endif
)
{
+ /* For Fetch/Move stmt, convert the string into int64 value */
+ if((strcmp(yylval.keyword, "fetch")==0) || (strcmp(yylval.keyword, "move")==0))
+ {
+ int64 intVal;
+ errno = 0;
+
+ intVal = strtoll(yytext, &endptr, 10);
+ if (*endptr != '\0' || errno == ERANGE)
+ {
+ yylval.str = pstrdup(yytext);
+ return FCONST;
+ }
+ else
+ {
+ yylval.ival = intVal;
+ return ICONST;
+ }
+ }
+
/* integer too large, treat it as a float */
yylval.str = pstrdup(yytext);
return FCONST;
*** ./src/backend/tcop/postgres.c.orig Sat Aug 12 23:05:03 2006
--- ./src/backend/tcop/postgres.c Sat Aug 12 23:05:03 2006
***************
*** 1678,1684 ****
* Process an "Execute" message for a portal
*/
static void
! exec_execute_message(const char *portal_name, long max_rows)
{
CommandDest dest;
DestReceiver *receiver;
--- 1678,1684 ----
* Process an "Execute" message for a portal
*/
static void
! exec_execute_message(const char *portal_name, int64 max_rows)
{
CommandDest dest;
DestReceiver *receiver;
***************
*** 3263,3275 ****
case 'E': /* execute */
{
const char *portal_name;
! int max_rows;
/* Set statement_timestamp() */
SetCurrentStatementStartTimestamp();
portal_name = pq_getmsgstring(&input_message);
! max_rows = pq_getmsgint(&input_message, 4);
pq_getmsgend(&input_message);
exec_execute_message(portal_name, max_rows);
--- 3263,3275 ----
case 'E': /* execute */
{
const char *portal_name;
! int64 max_rows;
/* Set statement_timestamp() */
SetCurrentStatementStartTimestamp();
portal_name = pq_getmsgstring(&input_message);
! max_rows = pq_getmsgint64(&input_message);
pq_getmsgend(&input_message);
exec_execute_message(portal_name, max_rows);
*** ./src/backend/tcop/pquery.c.orig Sat Aug 12 23:05:03 2006
--- ./src/backend/tcop/pquery.c Sat Aug 12 23:05:03 2006
***************
*** 37,45 ****
ParamListInfo params,
DestReceiver *dest,
char *completionTag);
! static uint32 RunFromStore(Portal portal, ScanDirection direction, long count,
DestReceiver *dest);
! static long PortalRunSelect(Portal portal, bool forward, long count,
DestReceiver *dest);
static void PortalRunUtility(Portal portal, Query *query,
DestReceiver *dest, char *completionTag);
--- 37,45 ----
ParamListInfo params,
DestReceiver *dest,
char *completionTag);
! static uint64 RunFromStore(Portal portal, ScanDirection direction, int64 count,
DestReceiver *dest);
! static int64 PortalRunSelect(Portal portal, bool forward, int64 count,
DestReceiver *dest);
static void PortalRunUtility(Portal portal, Query *query,
DestReceiver *dest, char *completionTag);
***************
*** 46,54 ****
static void PortalRunMulti(Portal portal,
DestReceiver *dest, DestReceiver *altdest,
char *completionTag);
! static long DoPortalRunFetch(Portal portal,
FetchDirection fdirection,
! long count,
DestReceiver *dest);
static void DoPortalRewind(Portal portal);
--- 46,54 ----
static void PortalRunMulti(Portal portal,
DestReceiver *dest, DestReceiver *altdest,
char *completionTag);
! static int64 DoPortalRunFetch(Portal portal,
FetchDirection fdirection,
! int64 count,
DestReceiver *dest);
static void DoPortalRewind(Portal portal);
***************
*** 545,551 ****
* suspended due to exhaustion of the count parameter.
*/
bool
! PortalRun(Portal portal, long count,
DestReceiver *dest, DestReceiver *altdest,
char *completionTag)
{
--- 545,551 ----
* suspended due to exhaustion of the count parameter.
*/
bool
! PortalRun(Portal portal, int64 count,
DestReceiver *dest, DestReceiver *altdest,
char *completionTag)
{
***************
*** 745,759 ****
*
* Returns number of rows processed (suitable for use in result tag)
*/
! static long
PortalRunSelect(Portal portal,
bool forward,
! long count,
DestReceiver *dest)
{
QueryDesc *queryDesc;
ScanDirection direction;
! uint32 nprocessed;
/*
* NB: queryDesc will be NULL if we are fetching from a held cursor or a
--- 745,759 ----
*
* Returns number of rows processed (suitable for use in result tag)
*/
! static int64
PortalRunSelect(Portal portal,
bool forward,
! int64 count,
DestReceiver *dest)
{
QueryDesc *queryDesc;
ScanDirection direction;
! uint64 nprocessed;
/*
* NB: queryDesc will be NULL if we are fetching from a held cursor or a
***************
*** 767,773 ****
/*
* Force the queryDesc destination to the right thing. This supports
* MOVE, for example, which will pass in dest = DestNone. This is okay to
! * change as long as we do it on every fetch. (The Executor must not
* assume that dest never changes.)
*/
if (queryDesc)
--- 767,773 ----
/*
* Force the queryDesc destination to the right thing. This supports
* MOVE, for example, which will pass in dest = DestNone. This is okay to
! * change as int64 as we do it on every fetch. (The Executor must not
* assume that dest never changes.)
*/
if (queryDesc)
***************
*** 806,817 ****
if (!ScanDirectionIsNoMovement(direction))
{
! long oldPos;
if (nprocessed > 0)
portal->atStart = false; /* OK to go backward now */
if (count == 0 ||
! (unsigned long) nprocessed < (unsigned long) count)
portal->atEnd = true; /* we retrieved 'em all */
oldPos = portal->portalPos;
portal->portalPos += nprocessed;
--- 806,817 ----
if (!ScanDirectionIsNoMovement(direction))
{
! int64 oldPos;
if (nprocessed > 0)
portal->atStart = false; /* OK to go backward now */
if (count == 0 ||
! (uint64) nprocessed < (uint64) count)
portal->atEnd = true; /* we retrieved 'em all */
oldPos = portal->portalPos;
portal->portalPos += nprocessed;
***************
*** 854,860 ****
portal->portalPos++; /* adjust for endpoint case */
}
if (count == 0 ||
! (unsigned long) nprocessed < (unsigned long) count)
{
portal->atStart = true; /* we retrieved 'em all */
portal->portalPos = 0;
--- 854,860 ----
portal->portalPos++; /* adjust for endpoint case */
}
if (count == 0 ||
! (uint64) nprocessed < (uint64) count)
{
portal->atStart = true; /* we retrieved 'em all */
portal->portalPos = 0;
***************
*** 862,868 ****
}
else
{
! long oldPos;
oldPos = portal->portalPos;
portal->portalPos -= nprocessed;
--- 862,868 ----
}
else
{
! int64 oldPos;
oldPos = portal->portalPos;
portal->portalPos -= nprocessed;
***************
*** 888,898 ****
* are run in the caller's memory context (since we have no estate). Watch
* out for memory leaks.
*/
! static uint32
! RunFromStore(Portal portal, ScanDirection direction, long count,
DestReceiver *dest)
{
! long current_tuple_count = 0;
TupleTableSlot *slot;
slot = MakeSingleTupleTableSlot(portal->tupDesc);
--- 888,898 ----
* 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,
DestReceiver *dest)
{
! int64 current_tuple_count = 0;
TupleTableSlot *slot;
slot = MakeSingleTupleTableSlot(portal->tupDesc);
***************
*** 940,946 ****
ExecDropSingleTupleTableSlot(slot);
! return (uint32) current_tuple_count;
}
/*
--- 940,946 ----
ExecDropSingleTupleTableSlot(slot);
! return (uint64) current_tuple_count;
}
/*
***************
*** 1129,1141 ****
*
* Returns number of rows processed (suitable for use in result tag)
*/
! long
PortalRunFetch(Portal portal,
FetchDirection fdirection,
! long count,
DestReceiver *dest)
{
! long result;
Portal saveActivePortal;
Snapshot saveActiveSnapshot;
ResourceOwner saveResourceOwner;
--- 1129,1141 ----
*
* Returns number of rows processed (suitable for use in result tag)
*/
! int64
PortalRunFetch(Portal portal,
FetchDirection fdirection,
! int64 count,
DestReceiver *dest)
{
! int64 result;
Portal saveActivePortal;
Snapshot saveActiveSnapshot;
ResourceOwner saveResourceOwner;
***************
*** 1244,1253 ****
*
* Returns number of rows processed (suitable for use in result tag)
*/
! static long
DoPortalRunFetch(Portal portal,
FetchDirection fdirection,
! long count,
DestReceiver *dest)
{
bool forward;
--- 1244,1253 ----
*
* Returns number of rows processed (suitable for use in result tag)
*/
! static int64
DoPortalRunFetch(Portal portal,
FetchDirection fdirection,
! int64 count,
DestReceiver *dest)
{
bool forward;
***************
*** 1283,1289 ****
* we are. In any case, we arrange to fetch the target row
* going forwards.
*/
! if (portal->posOverflow || portal->portalPos == LONG_MAX ||
count - 1 <= portal->portalPos / 2)
{
DoPortalRewind(portal);
--- 1283,1289 ----
* we are. In any case, we arrange to fetch the target row
* going forwards.
*/
! if (portal->posOverflow || portal->portalPos == LLONG_MAX ||
count - 1 <= portal->portalPos / 2)
{
DoPortalRewind(portal);
***************
*** 1293,1299 ****
}
else
{
! long pos = portal->portalPos;
if (portal->atEnd)
pos++; /* need one extra fetch if off end */
--- 1293,1299 ----
}
else
{
! int64 pos = portal->portalPos;
if (portal->atEnd)
pos++; /* need one extra fetch if off end */
***************
*** 1405,1411 ****
*/
if (!forward && count == FETCH_ALL && dest->mydest == DestNone)
{
! long result = portal->portalPos;
if (result > 0 && !portal->atEnd)
result--;
--- 1405,1411 ----
*/
if (!forward && count == FETCH_ALL && dest->mydest == DestNone)
{
! int64 result = portal->portalPos;
if (result > 0 && !portal->atEnd)
result--;
*** ./src/include/nodes/parsenodes.h.orig Sat Aug 12 23:05:18 2006
--- ./src/include/nodes/parsenodes.h Sat Aug 12 23:05:18 2006
***************
*** 1419,1431 ****
FETCH_RELATIVE
} FetchDirection;
! #define FETCH_ALL LONG_MAX
typedef struct FetchStmt
{
NodeTag type;
FetchDirection direction; /* see above */
! long howMany; /* number of rows, or position argument */
char *portalname; /* name of portal (cursor) */
bool ismove; /* TRUE if MOVE */
} FetchStmt;
--- 1419,1431 ----
FETCH_RELATIVE
} FetchDirection;
! #define FETCH_ALL LLONG_MAX
typedef struct FetchStmt
{
NodeTag type;
FetchDirection direction; /* see above */
! int64 howMany; /* number of rows, or position argument */
char *portalname; /* name of portal (cursor) */
bool ismove; /* TRUE if MOVE */
} FetchStmt;
*** ./src/include/tcop/pquery.h.orig Sat Aug 12 23:05:19 2006
--- ./src/include/tcop/pquery.h Sat Aug 12 23:05:19 2006
***************
*** 30,42 ****
extern void PortalSetResultFormat(Portal portal, int nFormats,
int16 *formats);
! extern bool PortalRun(Portal portal, long count,
DestReceiver *dest, DestReceiver *altdest,
char *completionTag);
! extern long PortalRunFetch(Portal portal,
FetchDirection fdirection,
! long count,
DestReceiver *dest);
#endif /* PQUERY_H */
--- 30,42 ----
extern void PortalSetResultFormat(Portal portal, int nFormats,
int16 *formats);
! extern bool PortalRun(Portal portal, int64 count,
DestReceiver *dest, DestReceiver *altdest,
char *completionTag);
! extern int64 PortalRunFetch(Portal portal,
FetchDirection fdirection,
! int64 count,
DestReceiver *dest);
#endif /* PQUERY_H */
*** ./src/include/utils/portal.h.orig Sat Aug 12 23:05:19 2006
--- ./src/include/utils/portal.h Sat Aug 12 23:05:19 2006
***************
*** 163,169 ****
bool atStart;
bool atEnd;
bool posOverflow;
! long portalPos;
/* Presentation data, primarily used by the pg_cursors system view */
TimestampTz creation_time; /* time at which this portal was defined */
--- 163,169 ----
bool atStart;
bool atEnd;
bool posOverflow;
! int64 portalPos;
/* Presentation data, primarily used by the pg_cursors system view */
TimestampTz creation_time; /* time at which this portal was defined */
Re: Patch for - Change FETCH/MOVE to use int8
От:
Alvaro Herrera <alvherre@commandprompt.com>
Дата:
Dhanaraj M wrote:
I had a quick look:
> ***************
> *** 209,215 ****
>
> /* Return command status if wanted */
> if (completionTag)
> ! snprintf(completionTag, COMPLETION_TAG_BUFSIZE, "%s %ld",
> stmt->ismove ? "MOVE" : "FETCH",
> nprocessed);
> }
> --- 209,215 ----
>
> /* Return command status if wanted */
> if (completionTag)
> ! snprintf(completionTag, COMPLETION_TAG_BUFSIZE, "%s %lld",
> stmt->ismove ? "MOVE" : "FETCH",
> nprocessed);
> }
You shouldn't be using %lld as it breaks on some platforms.
Use INT64_FORMAT instead.
> --- ./src/backend/parser/gram.y Sun Aug 13 00:06:28 2006
> ***************
> *** 116,122 ****
>
> %union
> {
> ! int ival;
> char chr;
> char *str;
> const char *keyword;
> --- 116,122 ----
>
> %union
> {
> ! int64 ival;
> char chr;
> char *str;
> const char *keyword;
I don't think this is the right approach. Maybe it would be reasonable
to add another arm to the %union instead, not sure. The problem is the
amount of ugly casts you have to use below. The scanner code seems to
think that a constant larger than the biggest int4 should be treated as
float, so I'm not sure why this would work anyway.
> ***************
> *** 767,773 ****
> /*
> * Force the queryDesc destination to the right thing. This supports
> * MOVE, for example, which will pass in dest = DestNone. This is okay to
> ! * change as long as we do it on every fetch. (The Executor must not
> * assume that dest never changes.)
> */
> if (queryDesc)
> --- 767,773 ----
> /*
> * Force the queryDesc destination to the right thing. This supports
> * MOVE, for example, which will pass in dest = DestNone. This is okay to
> ! * change as int64 as we do it on every fetch. (The Executor must not
> * assume that dest never changes.)
> */
> if (queryDesc)
Too enthusiastic about the search'n replace I think.
I stopped reading at this point.
--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
Re: Patch for - Change FETCH/MOVE to use int8
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Alvaro Herrera writes: > I don't think this is the right approach. Maybe it would be reasonable > to add another arm to the %union instead, not sure. The problem is the > amount of ugly casts you have to use below. The scanner code seems to > think that a constant larger than the biggest int4 should be treated as > float, so I'm not sure why this would work anyway. I'm not sure that I see the point of this at all. ISTM the entire reason for using a cursor is that you're going to fetch the results in bite-size pieces. I don't see the current Postgres source code surviving into the era where >2G rows is considered bite-size ;-) I thought the int8-LIMIT patch was equally pointless, btw, but at least it was not very invasive. This one is not passing the minimum usefulness-to-ugliness ratio for me. regards, tom lane
Re: Patch for - Change FETCH/MOVE to use int8
От:
Bruce Momjian <bruce@momjian.us>
Дата:
Tom Lane wrote: > Alvaro Herrera writes: > > I don't think this is the right approach. Maybe it would be reasonable > > to add another arm to the %union instead, not sure. The problem is the > > amount of ugly casts you have to use below. The scanner code seems to > > think that a constant larger than the biggest int4 should be treated as > > float, so I'm not sure why this would work anyway. > > I'm not sure that I see the point of this at all. ISTM the entire > reason for using a cursor is that you're going to fetch the results > in bite-size pieces. I don't see the current Postgres source code > surviving into the era where >2G rows is considered bite-size ;-) Think MOVE to a specific section of the cursor > 2gig. I can see that happening. -- Bruce Momjian bruce@momjian.us EnterpriseDB http://www.enterprisedb.com + If your life is a hard drive, Christ can be your backup. +
Re: Patch for - Change FETCH/MOVE to use int8
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Bruce Momjian writes: > Tom Lane wrote: >> I'm not sure that I see the point of this at all. ISTM the entire >> reason for using a cursor is that you're going to fetch the results >> in bite-size pieces. I don't see the current Postgres source code >> surviving into the era where >2G rows is considered bite-size ;-) > Think MOVE to a specific section of the cursor > 2gig. I can see that > happening. Yeah, and by the time it happens you'll have gotten bored and found something else to do. With no support in the system for random access to a cursor result, this is just about as useless as the FETCH case. In any case I agree with Alvaro's comment: the way to support int8 in a FETCH/MOVE command is not to try to convert the entire rest of the grammar to int8 instead of int4 as its native datatype. regards, tom lane
Re: Patch for - Change FETCH/MOVE to use int8
От:
Dhanaraj M <Dhanaraj.M@Sun.COM>
Дата:
Hi Alvaro
Thanks for your valuable suggestions.
I made the changes as suggested earlier.
Please review again and comment on this.
I like to make changes if it is required.
*** ./src/backend/commands/portalcmds.c.orig Sat Aug 12 23:04:54 2006
--- ./src/backend/commands/portalcmds.c Fri Aug 18 22:52:05 2006
***************
*** 176,183 ****
char *completionTag)
{
Portal portal;
! long nprocessed;
/*
* Disallow empty-string cursor name (conflicts with protocol-level
* unnamed portal).
--- 176,183 ----
char *completionTag)
{
Portal portal;
! int64 nprocessed;
/*
* Disallow empty-string cursor name (conflicts with protocol-level
* unnamed portal).
***************
*** 209,215 ****
/* Return command status if wanted */
if (completionTag)
! snprintf(completionTag, COMPLETION_TAG_BUFSIZE, "%s %ld",
stmt->ismove ? "MOVE" : "FETCH",
nprocessed);
}
--- 209,215 ----
/* Return command status if wanted */
if (completionTag)
! snprintf(completionTag, COMPLETION_TAG_BUFSIZE, "%s " INT64_FORMAT,
stmt->ismove ? "MOVE" : "FETCH",
nprocessed);
}
*** ./src/backend/executor/spi.c.orig Sat Aug 12 23:04:55 2006
--- ./src/backend/executor/spi.c Fri Aug 18 02:14:20 2006
***************
*** 45,51 ****
static void _SPI_error_callback(void *arg);
! static void _SPI_cursor_operation(Portal portal, bool forward, long count,
DestReceiver *dest);
static _SPI_plan *_SPI_copy_plan(_SPI_plan *plan, int location);
--- 45,51 ----
static void _SPI_error_callback(void *arg);
! static void _SPI_cursor_operation(Portal portal, bool forward, int64 count,
DestReceiver *dest);
static _SPI_plan *_SPI_copy_plan(_SPI_plan *plan, int location);
***************
*** 980,986 ****
* Fetch rows in a cursor
*/
void
! SPI_cursor_fetch(Portal portal, bool forward, long count)
{
_SPI_cursor_operation(portal, forward, count,
CreateDestReceiver(DestSPI, NULL));
--- 980,986 ----
* Fetch rows in a cursor
*/
void
! SPI_cursor_fetch(Portal portal, bool forward, int64 count)
{
_SPI_cursor_operation(portal, forward, count,
CreateDestReceiver(DestSPI, NULL));
***************
*** 994,1000 ****
* Move in a cursor
*/
void
! SPI_cursor_move(Portal portal, bool forward, long count)
{
_SPI_cursor_operation(portal, forward, count, None_Receiver);
}
--- 994,1000 ----
* Move in a cursor
*/
void
! SPI_cursor_move(Portal portal, bool forward, int64 count)
{
_SPI_cursor_operation(portal, forward, count, None_Receiver);
}
***************
*** 1611,1620 ****
* Do a FETCH or MOVE in a cursor
*/
static void
! _SPI_cursor_operation(Portal portal, bool forward, long count,
DestReceiver *dest)
{
! long nfetched;
/* Check that the portal is valid */
if (!PortalIsValid(portal))
--- 1611,1620 ----
* Do a FETCH or MOVE in a cursor
*/
static void
! _SPI_cursor_operation(Portal portal, bool forward, int64 count,
DestReceiver *dest)
{
! int64 nfetched;
/* Check that the portal is valid */
if (!PortalIsValid(portal))
*** ./src/backend/parser/gram.y.orig Fri Aug 18 23:37:43 2006
--- ./src/backend/parser/gram.y Fri Aug 18 01:12:58 2006
***************
*** 117,122 ****
--- 117,123 ----
%union
{
int ival;
+ int64 i64val;
char chr;
char *str;
const char *keyword;
***************
*** 323,328 ****
--- 324,330 ----
%type opt_varying opt_timezone
%type Iconst SignedIconst
+ %type SignedI64const
%type Sconst comment_text
%type RoleId opt_granted_by opt_boolean ColId_or_Sconst
%type var_list var_list_or_default
***************
*** 446,451 ****
--- 448,454 ----
/* Special token types, not actually keywords - see the "lex" file */
%token IDENT FCONST SCONST BCONST XCONST Op
%token ICONST PARAM
+ %token I64CONST
/* precedence: lowest to highest */
%nonassoc SET /* see relation_expr_opt_alias */
***************
*** 3334,3339 ****
--- 3337,3363 ----
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);
***************
*** 3355,3360 ****
--- 3379,3391 ----
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);
***************
*** 3376,3381 ****
--- 3407,3419 ----
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);
***************
*** 8395,8400 ****
--- 8433,8441 ----
SignedIconst: ICONST { $$ = $1; }
| '-' ICONST { $$ = - $2; }
;
+ SignedI64const: I64CONST { $$ = $1; }
+ | '-' I64CONST { $$ = - $2; }
+ ;
/*
* Name classification hierarchy.
*** ./src/backend/parser/scan.l.orig Sat Aug 12 23:04:58 2006
--- ./src/backend/parser/scan.l Fri Aug 18 23:01:04 2006
***************
*** 666,671 ****
--- 666,688 ----
#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;
*** ./src/backend/tcop/postgres.c.orig Sat Aug 12 23:05:03 2006
--- ./src/backend/tcop/postgres.c Sat Aug 12 23:05:03 2006
***************
*** 1678,1684 ****
* Process an "Execute" message for a portal
*/
static void
! exec_execute_message(const char *portal_name, long max_rows)
{
CommandDest dest;
DestReceiver *receiver;
--- 1678,1684 ----
* Process an "Execute" message for a portal
*/
static void
! exec_execute_message(const char *portal_name, int64 max_rows)
{
CommandDest dest;
DestReceiver *receiver;
***************
*** 3263,3275 ****
case 'E': /* execute */
{
const char *portal_name;
! int max_rows;
/* Set statement_timestamp() */
SetCurrentStatementStartTimestamp();
portal_name = pq_getmsgstring(&input_message);
! max_rows = pq_getmsgint(&input_message, 4);
pq_getmsgend(&input_message);
exec_execute_message(portal_name, max_rows);
--- 3263,3275 ----
case 'E': /* execute */
{
const char *portal_name;
! int64 max_rows;
/* Set statement_timestamp() */
SetCurrentStatementStartTimestamp();
portal_name = pq_getmsgstring(&input_message);
! max_rows = pq_getmsgint64(&input_message);
pq_getmsgend(&input_message);
exec_execute_message(portal_name, max_rows);
*** ./src/backend/tcop/pquery.c.orig Sat Aug 12 23:05:03 2006
--- ./src/backend/tcop/pquery.c Fri Aug 18 01:18:47 2006
***************
*** 37,45 ****
ParamListInfo params,
DestReceiver *dest,
char *completionTag);
! static uint32 RunFromStore(Portal portal, ScanDirection direction, long count,
DestReceiver *dest);
! static long PortalRunSelect(Portal portal, bool forward, long count,
DestReceiver *dest);
static void PortalRunUtility(Portal portal, Query *query,
DestReceiver *dest, char *completionTag);
--- 37,45 ----
ParamListInfo params,
DestReceiver *dest,
char *completionTag);
! static uint64 RunFromStore(Portal portal, ScanDirection direction, int64 count,
DestReceiver *dest);
! static int64 PortalRunSelect(Portal portal, bool forward, int64 count,
DestReceiver *dest);
static void PortalRunUtility(Portal portal, Query *query,
DestReceiver *dest, char *completionTag);
***************
*** 46,54 ****
static void PortalRunMulti(Portal portal,
DestReceiver *dest, DestReceiver *altdest,
char *completionTag);
! static long DoPortalRunFetch(Portal portal,
FetchDirection fdirection,
! long count,
DestReceiver *dest);
static void DoPortalRewind(Portal portal);
--- 46,54 ----
static void PortalRunMulti(Portal portal,
DestReceiver *dest, DestReceiver *altdest,
char *completionTag);
! static int64 DoPortalRunFetch(Portal portal,
FetchDirection fdirection,
! int64 count,
DestReceiver *dest);
static void DoPortalRewind(Portal portal);
***************
*** 545,551 ****
* suspended due to exhaustion of the count parameter.
*/
bool
! PortalRun(Portal portal, long count,
DestReceiver *dest, DestReceiver *altdest,
char *completionTag)
{
--- 545,551 ----
* suspended due to exhaustion of the count parameter.
*/
bool
! PortalRun(Portal portal, int64 count,
DestReceiver *dest, DestReceiver *altdest,
char *completionTag)
{
***************
*** 745,759 ****
*
* Returns number of rows processed (suitable for use in result tag)
*/
! static long
PortalRunSelect(Portal portal,
bool forward,
! long count,
DestReceiver *dest)
{
QueryDesc *queryDesc;
ScanDirection direction;
! uint32 nprocessed;
/*
* NB: queryDesc will be NULL if we are fetching from a held cursor or a
--- 745,759 ----
*
* Returns number of rows processed (suitable for use in result tag)
*/
! static int64
PortalRunSelect(Portal portal,
bool forward,
! int64 count,
DestReceiver *dest)
{
QueryDesc *queryDesc;
ScanDirection direction;
! uint64 nprocessed;
/*
* NB: queryDesc will be NULL if we are fetching from a held cursor or a
***************
*** 806,817 ****
if (!ScanDirectionIsNoMovement(direction))
{
! long oldPos;
if (nprocessed > 0)
portal->atStart = false; /* OK to go backward now */
if (count == 0 ||
! (unsigned long) nprocessed < (unsigned long) count)
portal->atEnd = true; /* we retrieved 'em all */
oldPos = portal->portalPos;
portal->portalPos += nprocessed;
--- 806,817 ----
if (!ScanDirectionIsNoMovement(direction))
{
! int64 oldPos;
if (nprocessed > 0)
portal->atStart = false; /* OK to go backward now */
if (count == 0 ||
! (uint64) nprocessed < (uint64) count)
portal->atEnd = true; /* we retrieved 'em all */
oldPos = portal->portalPos;
portal->portalPos += nprocessed;
***************
*** 854,860 ****
portal->portalPos++; /* adjust for endpoint case */
}
if (count == 0 ||
! (unsigned long) nprocessed < (unsigned long) count)
{
portal->atStart = true; /* we retrieved 'em all */
portal->portalPos = 0;
--- 854,860 ----
portal->portalPos++; /* adjust for endpoint case */
}
if (count == 0 ||
! (uint64) nprocessed < (uint64) count)
{
portal->atStart = true; /* we retrieved 'em all */
portal->portalPos = 0;
***************
*** 862,868 ****
}
else
{
! long oldPos;
oldPos = portal->portalPos;
portal->portalPos -= nprocessed;
--- 862,868 ----
}
else
{
! int64 oldPos;
oldPos = portal->portalPos;
portal->portalPos -= nprocessed;
***************
*** 888,898 ****
* are run in the caller's memory context (since we have no estate). Watch
* out for memory leaks.
*/
! static uint32
! RunFromStore(Portal portal, ScanDirection direction, long count,
DestReceiver *dest)
{
! long current_tuple_count = 0;
TupleTableSlot *slot;
slot = MakeSingleTupleTableSlot(portal->tupDesc);
--- 888,898 ----
* 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,
DestReceiver *dest)
{
! int64 current_tuple_count = 0;
TupleTableSlot *slot;
slot = MakeSingleTupleTableSlot(portal->tupDesc);
***************
*** 940,946 ****
ExecDropSingleTupleTableSlot(slot);
! return (uint32) current_tuple_count;
}
/*
--- 940,946 ----
ExecDropSingleTupleTableSlot(slot);
! return (uint64) current_tuple_count;
}
/*
***************
*** 1129,1141 ****
*
* Returns number of rows processed (suitable for use in result tag)
*/
! long
PortalRunFetch(Portal portal,
FetchDirection fdirection,
! long count,
DestReceiver *dest)
{
! long result;
Portal saveActivePortal;
Snapshot saveActiveSnapshot;
ResourceOwner saveResourceOwner;
--- 1129,1141 ----
*
* Returns number of rows processed (suitable for use in result tag)
*/
! int64
PortalRunFetch(Portal portal,
FetchDirection fdirection,
! int64 count,
DestReceiver *dest)
{
! int64 result;
Portal saveActivePortal;
Snapshot saveActiveSnapshot;
ResourceOwner saveResourceOwner;
***************
*** 1244,1253 ****
*
* Returns number of rows processed (suitable for use in result tag)
*/
! static long
DoPortalRunFetch(Portal portal,
FetchDirection fdirection,
! long count,
DestReceiver *dest)
{
bool forward;
--- 1244,1253 ----
*
* Returns number of rows processed (suitable for use in result tag)
*/
! static int64
DoPortalRunFetch(Portal portal,
FetchDirection fdirection,
! int64 count,
DestReceiver *dest)
{
bool forward;
***************
*** 1283,1289 ****
* we are. In any case, we arrange to fetch the target row
* going forwards.
*/
! if (portal->posOverflow || portal->portalPos == LONG_MAX ||
count - 1 <= portal->portalPos / 2)
{
DoPortalRewind(portal);
--- 1283,1289 ----
* we are. In any case, we arrange to fetch the target row
* going forwards.
*/
! if (portal->posOverflow || portal->portalPos == LLONG_MAX ||
count - 1 <= portal->portalPos / 2)
{
DoPortalRewind(portal);
***************
*** 1293,1299 ****
}
else
{
! long pos = portal->portalPos;
if (portal->atEnd)
pos++; /* need one extra fetch if off end */
--- 1293,1299 ----
}
else
{
! int64 pos = portal->portalPos;
if (portal->atEnd)
pos++; /* need one extra fetch if off end */
***************
*** 1405,1411 ****
*/
if (!forward && count == FETCH_ALL && dest->mydest == DestNone)
{
! long result = portal->portalPos;
if (result > 0 && !portal->atEnd)
result--;
--- 1405,1411 ----
*/
if (!forward && count == FETCH_ALL && dest->mydest == DestNone)
{
! int64 result = portal->portalPos;
if (result > 0 && !portal->atEnd)
result--;
*** ./src/include/executor/spi.h.orig Sat Aug 12 23:05:17 2006
--- ./src/include/executor/spi.h Fri Aug 18 02:13:15 2006
***************
*** 123,130 ****
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, 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);
--- 123,130 ----
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_close(Portal portal);
extern void AtEOXact_SPI(bool isCommit);
*** ./src/include/nodes/parsenodes.h.orig Sat Aug 12 23:05:18 2006
--- ./src/include/nodes/parsenodes.h Sat Aug 12 23:05:18 2006
***************
*** 1419,1431 ****
FETCH_RELATIVE
} FetchDirection;
! #define FETCH_ALL LONG_MAX
typedef struct FetchStmt
{
NodeTag type;
FetchDirection direction; /* see above */
! long howMany; /* number of rows, or position argument */
char *portalname; /* name of portal (cursor) */
bool ismove; /* TRUE if MOVE */
} FetchStmt;
--- 1419,1431 ----
FETCH_RELATIVE
} FetchDirection;
! #define FETCH_ALL LLONG_MAX
typedef struct FetchStmt
{
NodeTag type;
FetchDirection direction; /* see above */
! int64 howMany; /* number of rows, or position argument */
char *portalname; /* name of portal (cursor) */
bool ismove; /* TRUE if MOVE */
} FetchStmt;
*** ./src/include/tcop/pquery.h.orig Sat Aug 12 23:05:19 2006
--- ./src/include/tcop/pquery.h Sat Aug 12 23:05:19 2006
***************
*** 30,42 ****
extern void PortalSetResultFormat(Portal portal, int nFormats,
int16 *formats);
! extern bool PortalRun(Portal portal, long count,
DestReceiver *dest, DestReceiver *altdest,
char *completionTag);
! extern long PortalRunFetch(Portal portal,
FetchDirection fdirection,
! long count,
DestReceiver *dest);
#endif /* PQUERY_H */
--- 30,42 ----
extern void PortalSetResultFormat(Portal portal, int nFormats,
int16 *formats);
! extern bool PortalRun(Portal portal, int64 count,
DestReceiver *dest, DestReceiver *altdest,
char *completionTag);
! extern int64 PortalRunFetch(Portal portal,
FetchDirection fdirection,
! int64 count,
DestReceiver *dest);
#endif /* PQUERY_H */
*** ./src/include/utils/portal.h.orig Sat Aug 12 23:05:19 2006
--- ./src/include/utils/portal.h Sat Aug 12 23:05:19 2006
***************
*** 163,169 ****
bool atStart;
bool atEnd;
bool posOverflow;
! long portalPos;
/* Presentation data, primarily used by the pg_cursors system view */
TimestampTz creation_time; /* time at which this portal was defined */
--- 163,169 ----
bool atStart;
bool atEnd;
bool posOverflow;
! int64 portalPos;
/* Presentation data, primarily used by the pg_cursors system view */
TimestampTz creation_time; /* time at which this portal was defined */
Re: Patch for - Change FETCH/MOVE to use int8
От:
Bruce Momjian <bruce@momjian.us>
Дата:
Patch applied. Thanks. I had to convert a lot of whitespace to tabs. It wasn't just the whitespace, but whitespace that was 8 spaces. I assume you are reading our code using an 8-space tab. Please see the developer's FAQ and try to use tabs in future patches. Thanks. --------------------------------------------------------------------------- Dhanaraj M wrote: > Hi Alvaro > > Thanks for your valuable suggestions. > I made the changes as suggested earlier. > Please review again and comment on this. > I like to make changes if it is required. > > ---------------------------(end of broadcast)--------------------------- > TIP 2: Don't 'kill -9' the postmaster -- Bruce Momjian bruce@momjian.us EnterpriseDB http://www.enterprisedb.com + If your life is a hard drive, Christ can be your backup. +
Re: Patch for - Change FETCH/MOVE to use int8
От:
Bruce Momjian <bruce@momjian.us>
Дата:
bruce wrote:
>
> Patch applied. Thanks.
>
> I had to convert a lot of whitespace to tabs. It wasn't just the
> whitespace, but whitespace that was 8 spaces. I assume you are reading
> our code using an 8-space tab. Please see the developer's FAQ and try
> to use tabs in future patches. Thanks.
I have reverted this patch. It was causing crashes in the ecpg
regression tests. I think the problem was in scan.l:
+ /* 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;
This is code that was in the 'integer' section. Why did you think you
could compare a non-assigned yylval at this stage? Anyway, this isn't
going into 8.2.
---------------------------------------------------------------------------
>
> Dhanaraj M wrote:
> > Hi Alvaro
> >
> > Thanks for your valuable suggestions.
> > I made the changes as suggested earlier.
> > Please review again and comment on this.
> > I like to make changes if it is required.
>
>
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 2: Don't 'kill -9' the postmaster
>
> --
> Bruce Momjian bruce@momjian.us
> EnterpriseDB http://www.enterprisedb.com
>
> + If your life is a hard drive, Christ can be your backup. +
--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +