1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-17 06:41:09 +03:00

Change FETCH/MOVE to use int8.

Dhanaraj M
This commit is contained in:
Bruce Momjian
2006-09-02 18:17:18 +00:00
parent 87eb130ad8
commit 6c785d599d
10 changed files with 109 additions and 52 deletions

View File

@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.559 2006/08/30 23:34:21 tgl Exp $
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.560 2006/09/02 18:17:17 momjian Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@ -116,6 +116,7 @@ static void doNegateFloat(Value *v);
%union
{
int ival;
int64 i64val;
char chr;
char *str;
const char *keyword;
@ -322,6 +323,7 @@ static void doNegateFloat(Value *v);
%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
@ -446,6 +448,7 @@ static void doNegateFloat(Value *v);
/* 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 */
@ -3354,6 +3357,27 @@ fetch_direction:
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);
@ -3375,6 +3399,13 @@ fetch_direction:
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);
@ -3396,6 +3427,13 @@ fetch_direction:
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);
@ -8441,6 +8479,9 @@ RoleId: ColId { $$ = $1; };
SignedIconst: ICONST { $$ = $1; }
| '-' ICONST { $$ = - $2; }
;
SignedI64const: I64CONST { $$ = $1; }
| '-' I64CONST { $$ = - $2; }
;
/*
* Name classification hierarchy.

View File

@ -24,7 +24,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.135 2006/05/21 20:10:42 tgl Exp $
* $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.136 2006/09/02 18:17:17 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -666,6 +666,22 @@ other .
#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;