static uint32 minXlogTli = 0;
static XLogSegNo minXlogSegNo = 0;
static int WalSegSz;
+static int set_wal_segsize;
static void CheckDataVersion(void);
static bool ReadControlFile(void);
{"next-oid", required_argument, NULL, 'o'},
{"multixact-offset", required_argument, NULL, 'O'},
{"next-transaction-id", required_argument, NULL, 'x'},
+ {"wal-segsize", required_argument, NULL, 1},
{NULL, 0, NULL, 0}
};
log_fname = pg_strdup(optarg);
break;
+ case 1:
+ set_wal_segsize = strtol(optarg, &endptr, 10) * 1024 * 1024;
+ if (endptr == optarg || *endptr != '\0')
+ {
+ fprintf(stderr,
+ _("%s: argument of --wal-segsize must be a number\n"),
+ progname);
+ exit(1);
+ }
+ if (!IsValidWalSegSize(set_wal_segsize))
+ {
+ fprintf(stderr,
+ _("%s: argument of --wal-segsize must be a power of 2 between 1 and 1024\n"),
+ progname);
+ exit(1);
+ }
+ break;
+
default:
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
exit(1);
if (!ReadControlFile())
GuessControlValues();
+ /*
+ * If no new WAL segment size was specified, use the control file value.
+ */
+ if (set_wal_segsize != 0)
+ WalSegSz = set_wal_segsize;
+ else
+ WalSegSz = ControlFile.xlog_seg_size;
+
if (log_fname != NULL)
XLogFromFileName(log_fname, &minXlogTli, &minXlogSegNo, WalSegSz);
ControlFile.checkPointCopy.PrevTimeLineID = minXlogTli;
}
+ if (set_wal_segsize != 0)
+ ControlFile.xlog_seg_size = WalSegSz;
+
if (minXlogSegNo > newXlogSegNo)
newXlogSegNo = minXlogSegNo;
}
memcpy(&ControlFile, buffer, sizeof(ControlFile));
- WalSegSz = ControlFile.xlog_seg_size;
- /* return false if WalSegSz is not valid */
- if (!IsValidWalSegSize(WalSegSz))
+ /* return false if WAL segment size is not valid */
+ if (!IsValidWalSegSize(ControlFile.xlog_seg_size))
{
fprintf(stderr,
_("%s: pg_control specifies invalid WAL segment size (%d bytes); proceed with caution \n"),
- progname, WalSegSz);
+ progname, ControlFile.xlog_seg_size);
return false;
}
ControlFile.blcksz = BLCKSZ;
ControlFile.relseg_size = RELSEG_SIZE;
ControlFile.xlog_blcksz = XLOG_BLCKSZ;
- WalSegSz = ControlFile.xlog_seg_size = DEFAULT_XLOG_SEG_SIZE;
+ ControlFile.xlog_seg_size = DEFAULT_XLOG_SEG_SIZE;
ControlFile.nameDataLen = NAMEDATALEN;
ControlFile.indexMaxKeys = INDEX_MAX_KEYS;
ControlFile.toast_max_chunk_size = TOAST_MAX_CHUNK_SIZE;
printf(_("newestCommitTsXid: %u\n"),
ControlFile.checkPointCopy.newestCommitTsXid);
}
+
+ if (set_wal_segsize != 0)
+ {
+ printf(_("Bytes per WAL segment: %u\n"),
+ ControlFile.xlog_seg_size);
+ }
}
ControlFile.max_prepared_xacts = 0;
ControlFile.max_locks_per_xact = 64;
- /* Now we can force the recorded xlog seg size to the right thing. */
- ControlFile.xlog_seg_size = WalSegSz;
-
/* Contents are protected with a CRC */
INIT_CRC32C(ControlFile.crc);
COMP_CRC32C(ControlFile.crc,
* are in virgin territory.
*/
xlogbytepos = newXlogSegNo * ControlFile.xlog_seg_size;
- newXlogSegNo = (xlogbytepos + WalSegSz - 1) / WalSegSz;
+ newXlogSegNo = (xlogbytepos + ControlFile.xlog_seg_size - 1) / WalSegSz;
newXlogSegNo++;
}
printf(_(" -O, --multixact-offset=OFFSET set next multitransaction offset\n"));
printf(_(" -V, --version output version information, then exit\n"));
printf(_(" -x, --next-transaction-id=XID set next transaction ID\n"));
+ printf(_(" --wal-segsize=SIZE size of WAL segments, in megabytes\n"));
printf(_(" -?, --help show this help, then exit\n"));
printf(_("\nReport bugs to <pgsql-bugs@postgresql.org>.\n"));
}