23
23
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
24
24
* Portions Copyright (c) 1994, Regents of the University of California
26
* $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.73 2009/05/03 23:13:37 tgl Exp $
28
28
*-------------------------------------------------------------------------
71
71
static void RewriteControlFile(void);
72
72
static void FindEndOfXLOG(void);
73
73
static void KillExistingXLOG(void);
74
static void KillExistingArchiveStatus(void);
74
75
static void WriteEmptyXLOG(void);
75
76
static void usage(void);
817
* Remove existing archive status files
820
KillExistingArchiveStatus(void)
824
char path[MAXPGPATH];
826
#define ARCHSTATDIR XLOGDIR "/archive_status"
828
xldir = opendir(ARCHSTATDIR);
831
fprintf(stderr, _("%s: could not open directory \"%s\": %s\n"),
832
progname, ARCHSTATDIR, strerror(errno));
837
while ((xlde = readdir(xldir)) != NULL)
839
if (strspn(xlde->d_name, "0123456789ABCDEF") == 24 &&
840
(strcmp(xlde->d_name + 24, ".ready") == 0 ||
841
strcmp(xlde->d_name + 24, ".done") == 0))
843
snprintf(path, MAXPGPATH, "%s/%s", ARCHSTATDIR, xlde->d_name);
844
if (unlink(path) < 0)
846
fprintf(stderr, _("%s: could not delete file \"%s\": %s\n"),
847
progname, path, strerror(errno));
856
* This fix is in mingw cvs (runtime/mingwex/dirent.c rev 1.4), but not in
859
if (GetLastError() == ERROR_NO_MORE_FILES)
865
fprintf(stderr, _("%s: could not read from directory \"%s\": %s\n"),
866
progname, ARCHSTATDIR, strerror(errno));
815
874
* Write an empty XLOG file, containing only the checkpoint record
816
875
* already set up in ControlFile.