Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 229fb58

Browse files
committed
Treat timeline IDs as unsigned in replication parser
Timeline IDs are unsigned ints everywhere, except the replication parser treated them as signed ints.
1 parent 32f7c0a commit 229fb58

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/backend/replication/repl_gram.y

+7-7
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Node *replication_parse_result;
5656
%union {
5757
char *str;
5858
bool boolval;
59-
int32 intval;
59+
uint32 uintval;
6060

6161
XLogRecPtr recptr;
6262
Node *node;
@@ -66,7 +66,7 @@ Node *replication_parse_result;
6666

6767
/* Non-keyword tokens */
6868
%token <str> SCONST
69-
%token <intval> ICONST
69+
%token <uintval> UCONST
7070
%token <recptr> RECPTR
7171

7272
/* Keyword tokens. */
@@ -85,7 +85,7 @@ Node *replication_parse_result;
8585
%type <node> base_backup start_replication identify_system timeline_history
8686
%type <list> base_backup_opt_list
8787
%type <defelt> base_backup_opt
88-
%type <intval> opt_timeline
88+
%type <uintval> opt_timeline
8989
%%
9090

9191
firstcmd: command opt_semicolon
@@ -175,12 +175,12 @@ start_replication:
175175
;
176176

177177
opt_timeline:
178-
K_TIMELINE ICONST
178+
K_TIMELINE UCONST
179179
{
180180
if ($2 <= 0)
181181
ereport(ERROR,
182182
(errcode(ERRCODE_SYNTAX_ERROR),
183-
(errmsg("invalid timeline %d", $2))));
183+
(errmsg("invalid timeline %u", $2))));
184184
$$ = $2;
185185
}
186186
| /* nothing */ { $$ = 0; }
@@ -190,14 +190,14 @@ opt_timeline:
190190
* TIMELINE_HISTORY %d
191191
*/
192192
timeline_history:
193-
K_TIMELINE_HISTORY ICONST
193+
K_TIMELINE_HISTORY UCONST
194194
{
195195
TimeLineHistoryCmd *cmd;
196196

197197
if ($2 <= 0)
198198
ereport(ERROR,
199199
(errcode(ERRCODE_SYNTAX_ERROR),
200-
(errmsg("invalid timeline %d", $2))));
200+
(errmsg("invalid timeline %u", $2))));
201201

202202
cmd = makeNode(TimeLineHistoryCmd);
203203
cmd->timeline = $2;

src/backend/replication/repl_scanner.l

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ TIMELINE_HISTORY { return K_TIMELINE_HISTORY; }
8383
" " ;
8484

8585
{digit}+ {
86-
yylval.intval = pg_atoi(yytext, sizeof(int32), 0);
87-
return ICONST;
86+
yylval.uintval = strtoul(yytext, NULL, 10);
87+
return UCONST;
8888
}
8989

9090
{hexdigit}+\/{hexdigit}+ {

0 commit comments

Comments
 (0)