Treat timeline IDs as unsigned in replication parser

Timeline IDs are unsigned ints everywhere, except the replication parser
treated them as signed ints.
This commit is contained in:
Peter Eisentraut 2013-08-14 23:18:49 -04:00
parent 32f7c0ae17
commit 229fb58d4f
2 changed files with 9 additions and 9 deletions

View File

@ -56,7 +56,7 @@ Node *replication_parse_result;
%union { %union {
char *str; char *str;
bool boolval; bool boolval;
int32 intval; uint32 uintval;
XLogRecPtr recptr; XLogRecPtr recptr;
Node *node; Node *node;
@ -66,7 +66,7 @@ Node *replication_parse_result;
/* Non-keyword tokens */ /* Non-keyword tokens */
%token <str> SCONST %token <str> SCONST
%token <intval> ICONST %token <uintval> UCONST
%token <recptr> RECPTR %token <recptr> RECPTR
/* Keyword tokens. */ /* Keyword tokens. */
@ -85,7 +85,7 @@ Node *replication_parse_result;
%type <node> base_backup start_replication identify_system timeline_history %type <node> base_backup start_replication identify_system timeline_history
%type <list> base_backup_opt_list %type <list> base_backup_opt_list
%type <defelt> base_backup_opt %type <defelt> base_backup_opt
%type <intval> opt_timeline %type <uintval> opt_timeline
%% %%
firstcmd: command opt_semicolon firstcmd: command opt_semicolon
@ -175,12 +175,12 @@ start_replication:
; ;
opt_timeline: opt_timeline:
K_TIMELINE ICONST K_TIMELINE UCONST
{ {
if ($2 <= 0) if ($2 <= 0)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
(errmsg("invalid timeline %d", $2)))); (errmsg("invalid timeline %u", $2))));
$$ = $2; $$ = $2;
} }
| /* nothing */ { $$ = 0; } | /* nothing */ { $$ = 0; }
@ -190,14 +190,14 @@ opt_timeline:
* TIMELINE_HISTORY %d * TIMELINE_HISTORY %d
*/ */
timeline_history: timeline_history:
K_TIMELINE_HISTORY ICONST K_TIMELINE_HISTORY UCONST
{ {
TimeLineHistoryCmd *cmd; TimeLineHistoryCmd *cmd;
if ($2 <= 0) if ($2 <= 0)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
(errmsg("invalid timeline %d", $2)))); (errmsg("invalid timeline %u", $2))));
cmd = makeNode(TimeLineHistoryCmd); cmd = makeNode(TimeLineHistoryCmd);
cmd->timeline = $2; cmd->timeline = $2;

View File

@ -83,8 +83,8 @@ TIMELINE_HISTORY { return K_TIMELINE_HISTORY; }
" " ; " " ;
{digit}+ { {digit}+ {
yylval.intval = pg_atoi(yytext, sizeof(int32), 0); yylval.uintval = strtoul(yytext, NULL, 10);
return ICONST; return UCONST;
} }
{hexdigit}+\/{hexdigit}+ { {hexdigit}+\/{hexdigit}+ {