static MultiXactOffset set_mxoff = (MultiXactOffset) -1;
static uint32 minXlogTli = 0;
static XLogSegNo minXlogSegNo = 0;
+static uint64 set_sysid = 0;
+static uint64 GenerateSystemIdentifier(void);
static bool ReadControlFile(void);
static void GuessControlValues(void);
static void PrintControlValues(bool guessed);
static void WriteEmptyXLOG(void);
static void usage(void);
-
int
main(int argc, char *argv[])
{
}
- while ((c = getopt(argc, argv, "fl:m:no:O:x:e:")) != -1)
+ while ((c = getopt(argc, argv, "fl:m:no:O:x:e:s::")) != -1)
{
switch (c)
{
XLogFromFileName(optarg, &minXlogTli, &minXlogSegNo);
break;
+ case 's':
+ if (optarg)
+ {
+ if (sscanf(optarg, UINT64_FORMAT, &set_sysid) != 1)
+ {
+ fprintf(stderr, _("%s: invalid argument for option -s\n"), progname);
+ fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
+ exit(1);
+ }
+ }
+ else
+ {
+ set_sysid = GenerateSystemIdentifier();
+ }
+ break;
+
default:
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
exit(1);
if (minXlogSegNo > newXlogSegNo)
newXlogSegNo = minXlogSegNo;
+ if (set_sysid != 0)
+ ControlFile.system_identifier = set_sysid;
+
/*
* If we had to guess anything, and -f was not given, just print the
* guessed values and exit. Also print if -n is given.
}
+/*
+ * Create a new unique installation identifier.
+ *
+ * See notes in xlog.c about the algorithm.
+ */
+static uint64
+GenerateSystemIdentifier(void)
+{
+ uint64 sysidentifier;
+ struct timeval tv;
+
+ gettimeofday(&tv, NULL);
+ sysidentifier = ((uint64) tv.tv_sec) << 32;
+ sysidentifier |= ((uint64) tv.tv_usec) << 12;
+ sysidentifier |= getpid() & 0xFFF;
+
+ return sysidentifier;
+}
+
+
/*
* Try to read the existing pg_control file.
*
GuessControlValues(void)
{
uint64 sysidentifier;
- struct timeval tv;
/*
* Set up a completely default set of pg_control values.
/*
* Create a new unique installation identifier, since we can no longer use
- * any old XLOG records. See notes in xlog.c about the algorithm.
+ * any old XLOG records.
*/
- gettimeofday(&tv, NULL);
- sysidentifier = ((uint64) tv.tv_sec) << 32;
- sysidentifier |= ((uint64) tv.tv_usec) << 12;
- sysidentifier |= getpid() & 0xFFF;
+ sysidentifier = GenerateSystemIdentifier();
ControlFile.system_identifier = sysidentifier;
printf(_(" -o OID set next OID\n"));
printf(_(" -O OFFSET set next multitransaction offset\n"));
printf(_(" -V, --version output version information, then exit\n"));
+ printf(_(" -s [SYSID] set system identifier (or generate one)\n"));
printf(_(" -x XID set next transaction ID\n"));
printf(_(" -?, --help show this help, then exit\n"));
printf(_("\nReport bugs to <pgsql-bugs@postgresql.org>.\n"));