From 3ed990b6ffe18e794b5020a5e5e841aacd72524e Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Wed, 14 Aug 2013 23:18:49 -0400 Subject: [PATCH] Treat timeline IDs as unsigned in replication parser Timeline IDs are unsigned ints everywhere, except the replication parser treated them as signed ints. --- src/backend/replication/repl_gram.y | 14 +++++++------- src/backend/replication/repl_scanner.l | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/backend/replication/repl_gram.y b/src/backend/replication/repl_gram.y index bce18b8476..8c8378045e 100644 --- a/src/backend/replication/repl_gram.y +++ b/src/backend/replication/repl_gram.y @@ -56,7 +56,7 @@ Node *replication_parse_result; %union { char *str; bool boolval; - int32 intval; + uint32 uintval; XLogRecPtr recptr; Node *node; @@ -66,7 +66,7 @@ Node *replication_parse_result; /* Non-keyword tokens */ %token SCONST -%token ICONST +%token UCONST %token RECPTR /* Keyword tokens. */ @@ -85,7 +85,7 @@ Node *replication_parse_result; %type base_backup start_replication identify_system timeline_history %type base_backup_opt_list %type base_backup_opt -%type opt_timeline +%type opt_timeline %% firstcmd: command opt_semicolon @@ -175,12 +175,12 @@ start_replication: ; opt_timeline: - K_TIMELINE ICONST + K_TIMELINE UCONST { if ($2 <= 0) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - (errmsg("invalid timeline %d", $2)))); + (errmsg("invalid timeline %u", $2)))); $$ = $2; } | /* nothing */ { $$ = 0; } @@ -190,14 +190,14 @@ opt_timeline: * TIMELINE_HISTORY %d */ timeline_history: - K_TIMELINE_HISTORY ICONST + K_TIMELINE_HISTORY UCONST { TimeLineHistoryCmd *cmd; if ($2 <= 0) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - (errmsg("invalid timeline %d", $2)))); + (errmsg("invalid timeline %u", $2)))); cmd = makeNode(TimeLineHistoryCmd); cmd->timeline = $2; diff --git a/src/backend/replication/repl_scanner.l b/src/backend/replication/repl_scanner.l index b4743e6357..3d930f1301 100644 --- a/src/backend/replication/repl_scanner.l +++ b/src/backend/replication/repl_scanner.l @@ -83,8 +83,8 @@ TIMELINE_HISTORY { return K_TIMELINE_HISTORY; } " " ; {digit}+ { - yylval.intval = pg_atoi(yytext, sizeof(int32), 0); - return ICONST; + yylval.uintval = strtoul(yytext, NULL, 10); + return UCONST; } {hexdigit}+\/{hexdigit}+ { -- 2.40.0