Skip to content

Commit 6c785d5

Browse files
committed
Change FETCH/MOVE to use int8.
Dhanaraj M
1 parent 87eb130 commit 6c785d5

File tree

10 files changed

+109
-52
lines changed

10 files changed

+109
-52
lines changed

src/backend/commands/portalcmds.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*
1515
*
1616
* IDENTIFICATION
17-
* $PostgreSQL: pgsql/src/backend/commands/portalcmds.c,v 1.51 2006/08/29 02:11:29 momjian Exp $
17+
* $PostgreSQL: pgsql/src/backend/commands/portalcmds.c,v 1.52 2006/09/02 18:17:17 momjian Exp $
1818
*
1919
*-------------------------------------------------------------------------
2020
*/
@@ -177,7 +177,7 @@ PerformPortalFetch(FetchStmt *stmt,
177177
char *completionTag)
178178
{
179179
Portal portal;
180-
long nprocessed;
180+
int64 nprocessed;
181181

182182
/*
183183
* Disallow empty-string cursor name (conflicts with protocol-level
@@ -210,7 +210,7 @@ PerformPortalFetch(FetchStmt *stmt,
210210

211211
/* Return command status if wanted */
212212
if (completionTag)
213-
snprintf(completionTag, COMPLETION_TAG_BUFSIZE, "%s %ld",
213+
snprintf(completionTag, COMPLETION_TAG_BUFSIZE, "%s " INT64_FORMAT,
214214
stmt->ismove ? "MOVE" : "FETCH",
215215
nprocessed);
216216
}

src/backend/executor/spi.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.159 2006/08/29 02:11:29 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.160 2006/09/02 18:17:17 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -45,7 +45,7 @@ static int _SPI_pquery(QueryDesc *queryDesc, long tcount);
4545

4646
static void _SPI_error_callback(void *arg);
4747

48-
static void _SPI_cursor_operation(Portal portal, bool forward, long count,
48+
static void _SPI_cursor_operation(Portal portal, bool forward, int64 count,
4949
DestReceiver *dest);
5050

5151
static _SPI_plan *_SPI_copy_plan(_SPI_plan *plan, int location);
@@ -980,7 +980,7 @@ SPI_cursor_find(const char *name)
980980
* Fetch rows in a cursor
981981
*/
982982
void
983-
SPI_cursor_fetch(Portal portal, bool forward, long count)
983+
SPI_cursor_fetch(Portal portal, bool forward, int64 count)
984984
{
985985
_SPI_cursor_operation(portal, forward, count,
986986
CreateDestReceiver(DestSPI, NULL));
@@ -994,7 +994,7 @@ SPI_cursor_fetch(Portal portal, bool forward, long count)
994994
* Move in a cursor
995995
*/
996996
void
997-
SPI_cursor_move(Portal portal, bool forward, long count)
997+
SPI_cursor_move(Portal portal, bool forward, int64 count)
998998
{
999999
_SPI_cursor_operation(portal, forward, count, None_Receiver);
10001000
}
@@ -1639,10 +1639,10 @@ _SPI_error_callback(void *arg)
16391639
* Do a FETCH or MOVE in a cursor
16401640
*/
16411641
static void
1642-
_SPI_cursor_operation(Portal portal, bool forward, long count,
1642+
_SPI_cursor_operation(Portal portal, bool forward, int64 count,
16431643
DestReceiver *dest)
16441644
{
1645-
long nfetched;
1645+
int64 nfetched;
16461646

16471647
/* Check that the portal is valid */
16481648
if (!PortalIsValid(portal))

src/backend/parser/gram.y

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.559 2006/08/30 23:34:21 tgl Exp $
14+
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.560 2006/09/02 18:17:17 momjian Exp $
1515
*
1616
* HISTORY
1717
* AUTHOR DATE MAJOR EVENT
@@ -116,6 +116,7 @@ static void doNegateFloat(Value *v);
116116
%union
117117
{
118118
int ival;
119+
int64 i64val;
119120
char chr;
120121
char *str;
121122
const char *keyword;
@@ -322,6 +323,7 @@ static void doNegateFloat(Value *v);
322323
%type <boolean> opt_varying opt_timezone
323324

324325
%type <ival> Iconst SignedIconst
326+
%type <i64val> SignedI64const
325327
%type <str> Sconst comment_text
326328
%type <str> RoleId opt_granted_by opt_boolean ColId_or_Sconst
327329
%type <list> var_list var_list_or_default
@@ -446,6 +448,7 @@ static void doNegateFloat(Value *v);
446448
/* Special token types, not actually keywords - see the "lex" file */
447449
%token <str> IDENT FCONST SCONST BCONST XCONST Op
448450
%token <ival> ICONST PARAM
451+
%token <i64val> I64CONST
449452

450453
/* precedence: lowest to highest */
451454
%nonassoc SET /* see relation_expr_opt_alias */
@@ -3354,6 +3357,27 @@ fetch_direction:
33543357
n->howMany = $1;
33553358
$$ = (Node *)n;
33563359
}
3360+
| ABSOLUTE_P SignedI64const
3361+
{
3362+
FetchStmt *n = makeNode(FetchStmt);
3363+
n->direction = FETCH_ABSOLUTE;
3364+
n->howMany = $2;
3365+
$$ = (Node *)n;
3366+
}
3367+
| RELATIVE_P SignedI64const
3368+
{
3369+
FetchStmt *n = makeNode(FetchStmt);
3370+
n->direction = FETCH_RELATIVE;
3371+
n->howMany = $2;
3372+
$$ = (Node *)n;
3373+
}
3374+
| SignedI64const
3375+
{
3376+
FetchStmt *n = makeNode(FetchStmt);
3377+
n->direction = FETCH_FORWARD;
3378+
n->howMany = $1;
3379+
$$ = (Node *)n;
3380+
}
33573381
| ALL
33583382
{
33593383
FetchStmt *n = makeNode(FetchStmt);
@@ -3375,6 +3399,13 @@ fetch_direction:
33753399
n->howMany = $2;
33763400
$$ = (Node *)n;
33773401
}
3402+
| FORWARD SignedI64const
3403+
{
3404+
FetchStmt *n = makeNode(FetchStmt);
3405+
n->direction = FETCH_FORWARD;
3406+
n->howMany = $2;
3407+
$$ = (Node *)n;
3408+
}
33783409
| FORWARD ALL
33793410
{
33803411
FetchStmt *n = makeNode(FetchStmt);
@@ -3396,6 +3427,13 @@ fetch_direction:
33963427
n->howMany = $2;
33973428
$$ = (Node *)n;
33983429
}
3430+
| BACKWARD SignedI64const
3431+
{
3432+
FetchStmt *n = makeNode(FetchStmt);
3433+
n->direction = FETCH_BACKWARD;
3434+
n->howMany = $2;
3435+
$$ = (Node *)n;
3436+
}
33993437
| BACKWARD ALL
34003438
{
34013439
FetchStmt *n = makeNode(FetchStmt);
@@ -8441,6 +8479,9 @@ RoleId: ColId { $$ = $1; };
84418479
SignedIconst: ICONST { $$ = $1; }
84428480
| '-' ICONST { $$ = - $2; }
84438481
;
8482+
SignedI64const: I64CONST { $$ = $1; }
8483+
| '-' I64CONST { $$ = - $2; }
8484+
;
84448485

84458486
/*
84468487
* Name classification hierarchy.

src/backend/parser/scan.l

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* Portions Copyright (c) 1994, Regents of the University of California
2525
*
2626
* IDENTIFICATION
27-
* $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.135 2006/05/21 20:10:42 tgl Exp $
27+
* $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.136 2006/09/02 18:17:17 momjian Exp $
2828
*
2929
*-------------------------------------------------------------------------
3030
*/
@@ -666,6 +666,22 @@ other .
666666
#endif
667667
)
668668
{
669+
/* For Fetch/Move stmt, convert the string into int64 value */
670+
if((strcmp(yylval.keyword, "fetch")==0) || (strcmp(yylval.keyword, "move")==0))
671+
{
672+
int64 int64Val;
673+
errno = 0;
674+
675+
int64Val = strtoll(yytext, &endptr, 10);
676+
if (*endptr != '\0' || errno == ERANGE)
677+
{
678+
yylval.str = pstrdup(yytext);
679+
return FCONST;
680+
}
681+
yylval.i64val = int64Val;
682+
return I64CONST;
683+
}
684+
669685
/* integer too large, treat it as a float */
670686
yylval.str = pstrdup(yytext);
671687
return FCONST;

src/backend/tcop/postgres.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.503 2006/08/30 18:22:02 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.504 2006/09/02 18:17:17 momjian Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -1687,7 +1687,7 @@ exec_bind_message(StringInfo input_message)
16871687
* Process an "Execute" message for a portal
16881688
*/
16891689
static void
1690-
exec_execute_message(const char *portal_name, long max_rows)
1690+
exec_execute_message(const char *portal_name, int64 max_rows)
16911691
{
16921692
CommandDest dest;
16931693
DestReceiver *receiver;
@@ -3308,13 +3308,13 @@ PostgresMain(int argc, char *argv[], const char *username)
33083308
case 'E': /* execute */
33093309
{
33103310
const char *portal_name;
3311-
int max_rows;
3311+
int64 max_rows;
33123312

33133313
/* Set statement_timestamp() */
33143314
SetCurrentStatementStartTimestamp();
33153315

33163316
portal_name = pq_getmsgstring(&input_message);
3317-
max_rows = pq_getmsgint(&input_message, 4);
3317+
max_rows = pq_getmsgint64(&input_message);
33183318
pq_getmsgend(&input_message);
33193319

33203320
exec_execute_message(portal_name, max_rows);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy