* step 2 ...
*
*
- * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* src/bin/pg_resetxlog/pg_resetxlog.c
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
-#ifdef HAVE_GETOPT_H
-#include <getopt.h>
-#endif
#include "access/transam.h"
#include "access/tuptoaster.h"
#include "catalog/catversion.h"
#include "catalog/pg_control.h"
#include "common/fe_memutils.h"
-
-extern int optind;
-extern char *optarg;
+#include "pg_getopt.h"
static ControlFileData ControlFile; /* pg_control values */
/* minRecoveryPoint, backupStartPoint and backupEndPoint can be left zero */
ControlFile.wal_level = WAL_LEVEL_MINIMAL;
- ControlFile.wal_log_hintbits = false;
+ ControlFile.wal_log_hints = false;
ControlFile.MaxConnections = 100;
ControlFile.max_worker_processes = 8;
ControlFile.max_prepared_xacts = 0;
* anyway at startup.
*/
ControlFile.wal_level = WAL_LEVEL_MINIMAL;
- ControlFile.wal_log_hintbits = false;
+ ControlFile.wal_log_hints = false;
ControlFile.MaxConnections = 100;
ControlFile.max_worker_processes = 8;
ControlFile.max_prepared_xacts = 0;
exit(1);
}
- errno = 0;
- while ((xlde = readdir(xldir)) != NULL)
+ while (errno = 0, (xlde = readdir(xldir)) != NULL)
{
if (strlen(xlde->d_name) == 24 &&
strspn(xlde->d_name, "0123456789ABCDEF") == 24)
if (segno > newXlogSegNo)
newXlogSegNo = segno;
}
- errno = 0;
}
-#ifdef WIN32
- /*
- * This fix is in mingw cvs (runtime/mingwex/dirent.c rev 1.4), but not in
- * released version
- */
+#ifdef WIN32
+ /* Bug in old Mingw dirent.c; fixed in mingw-runtime-3.2, 2003-10-10 */
if (GetLastError() == ERROR_NO_MORE_FILES)
errno = 0;
#endif
if (errno)
{
- fprintf(stderr, _("%s: could not read from directory \"%s\": %s\n"),
+ fprintf(stderr, _("%s: could not read directory \"%s\": %s\n"),
+ progname, XLOGDIR, strerror(errno));
+ exit(1);
+ }
+
+ if (closedir(xldir))
+ {
+ fprintf(stderr, _("%s: could not close directory \"%s\": %s\n"),
progname, XLOGDIR, strerror(errno));
exit(1);
}
- closedir(xldir);
/*
* Finally, convert to new xlog seg size, and advance by one to ensure we
exit(1);
}
- errno = 0;
- while ((xlde = readdir(xldir)) != NULL)
+ while (errno = 0, (xlde = readdir(xldir)) != NULL)
{
if (strlen(xlde->d_name) == 24 &&
strspn(xlde->d_name, "0123456789ABCDEF") == 24)
exit(1);
}
}
- errno = 0;
}
-#ifdef WIN32
- /*
- * This fix is in mingw cvs (runtime/mingwex/dirent.c rev 1.4), but not in
- * released version
- */
+#ifdef WIN32
+ /* Bug in old Mingw dirent.c; fixed in mingw-runtime-3.2, 2003-10-10 */
if (GetLastError() == ERROR_NO_MORE_FILES)
errno = 0;
#endif
if (errno)
{
- fprintf(stderr, _("%s: could not read from directory \"%s\": %s\n"),
+ fprintf(stderr, _("%s: could not read directory \"%s\": %s\n"),
+ progname, XLOGDIR, strerror(errno));
+ exit(1);
+ }
+
+ if (closedir(xldir))
+ {
+ fprintf(stderr, _("%s: could not close directory \"%s\": %s\n"),
progname, XLOGDIR, strerror(errno));
exit(1);
}
- closedir(xldir);
}
exit(1);
}
- errno = 0;
- while ((xlde = readdir(xldir)) != NULL)
+ while (errno = 0, (xlde = readdir(xldir)) != NULL)
{
if (strspn(xlde->d_name, "0123456789ABCDEF") == 24 &&
(strcmp(xlde->d_name + 24, ".ready") == 0 ||
exit(1);
}
}
- errno = 0;
}
-#ifdef WIN32
- /*
- * This fix is in mingw cvs (runtime/mingwex/dirent.c rev 1.4), but not in
- * released version
- */
+#ifdef WIN32
+ /* Bug in old Mingw dirent.c; fixed in mingw-runtime-3.2, 2003-10-10 */
if (GetLastError() == ERROR_NO_MORE_FILES)
errno = 0;
#endif
if (errno)
{
- fprintf(stderr, _("%s: could not read from directory \"%s\": %s\n"),
+ fprintf(stderr, _("%s: could not read directory \"%s\": %s\n"),
+ progname, ARCHSTATDIR, strerror(errno));
+ exit(1);
+ }
+
+ if (closedir(xldir))
+ {
+ fprintf(stderr, _("%s: could not close directory \"%s\": %s\n"),
progname, ARCHSTATDIR, strerror(errno));
exit(1);
}
- closedir(xldir);
}