Skip to content

Commit a6427f1

Browse files
committed
Unbreak pg_resetxlog -l.
Fujii Masao
1 parent 2dfa87b commit a6427f1

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/bin/pg_resetxlog/pg_resetxlog.c

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,13 @@ main(int argc, char *argv[])
8686
Oid set_oid = 0;
8787
MultiXactId set_mxid = 0;
8888
MultiXactOffset set_mxoff = (MultiXactOffset) -1;
89-
uint32 minXlogTli = 0;
89+
uint32 minXlogTli = 0,
90+
minXlogId = 0,
91+
minXlogSeg = 0;
9092
XLogSegNo minXlogSegNo = 0;
9193
char *endptr;
94+
char *endptr2;
95+
char *endptr3;
9296
char *DataDir;
9397
int fd;
9498
char path[MAXPGPATH];
@@ -200,13 +204,28 @@ main(int argc, char *argv[])
200204
break;
201205

202206
case 'l':
203-
if (strspn(optarg, "01234567890ABCDEFabcdef") != 24)
207+
minXlogTli = strtoul(optarg, &endptr, 0);
208+
if (endptr == optarg || *endptr != ',')
204209
{
205210
fprintf(stderr, _("%s: invalid argument for option -l\n"), progname);
206211
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
207212
exit(1);
208213
}
209-
XLogFromFileName(optarg, &minXlogTli, &minXlogSegNo);
214+
minXlogId = strtoul(endptr + 1, &endptr2, 0);
215+
if (endptr2 == endptr + 1 || *endptr2 != ',')
216+
{
217+
fprintf(stderr, _("%s: invalid argument for option -l\n"), progname);
218+
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
219+
exit(1);
220+
}
221+
minXlogSeg = strtoul(endptr2 + 1, &endptr3, 0);
222+
if (endptr3 == endptr2 + 1 || *endptr3 != '\0')
223+
{
224+
fprintf(stderr, _("%s: invalid argument for option -l\n"), progname);
225+
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
226+
exit(1);
227+
}
228+
minXlogSegNo = (uint64) minXlogId * XLogSegmentsPerXLogId + minXlogSeg;
210229
break;
211230

212231
default:

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