case'e':
errno = 0;
set_xid_epoch = strtoul(optarg, &endptr, 0); if (endptr == optarg || *endptr != '\0' || errno != 0)
{ /*------
translator: the second %s is a command line argument (-e, etc) */
pg_log_error("invalid argument for option %s", "-e");
pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1);
} if (set_xid_epoch == -1)
pg_fatal("transaction ID epoch (-e) must not be -1"); break;
case'u':
errno = 0;
set_oldest_xid = strtoul(optarg, &endptr, 0); if (endptr == optarg || *endptr != '\0' || errno != 0)
{
pg_log_error("invalid argument for option %s", "-u");
pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1);
} if (!TransactionIdIsNormal(set_oldest_xid))
pg_fatal("oldest transaction ID (-u) must be greater than or equal to %u", FirstNormalTransactionId); break;
case'x':
errno = 0;
set_xid = strtoul(optarg, &endptr, 0); if (endptr == optarg || *endptr != '\0' || errno != 0)
{
pg_log_error("invalid argument for option %s", "-x");
pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1);
} if (!TransactionIdIsNormal(set_xid))
pg_fatal("transaction ID (-x) must be greater than or equal to %u", FirstNormalTransactionId); break;
case'c':
errno = 0;
set_oldest_commit_ts_xid = strtoul(optarg, &endptr, 0); if (endptr == optarg || *endptr != ',' || errno != 0)
{
pg_log_error("invalid argument for option %s", "-c");
pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1);
}
set_newest_commit_ts_xid = strtoul(endptr + 1, &endptr2, 0); if (endptr2 == endptr + 1 || *endptr2 != '\0' || errno != 0)
{
pg_log_error("invalid argument for option %s", "-c");
pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1);
}
if (set_oldest_commit_ts_xid < FirstNormalTransactionId &&
set_oldest_commit_ts_xid != InvalidTransactionId)
pg_fatal("transaction ID (-c) must be either %u or greater than or equal to %u", InvalidTransactionId, FirstNormalTransactionId);
if (set_newest_commit_ts_xid < FirstNormalTransactionId &&
set_newest_commit_ts_xid != InvalidTransactionId)
pg_fatal("transaction ID (-c) must be either %u or greater than or equal to %u", InvalidTransactionId, FirstNormalTransactionId); break;
case'o':
errno = 0;
set_oid = strtoul(optarg, &endptr, 0); if (endptr == optarg || *endptr != '\0' || errno != 0)
{
pg_log_error("invalid argument for option %s", "-o");
pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1);
} if (set_oid == 0)
pg_fatal("OID (-o) must not be 0"); break;
case'm':
errno = 0;
set_mxid = strtoul(optarg, &endptr, 0); if (endptr == optarg || *endptr != ',' || errno != 0)
{
pg_log_error("invalid argument for option %s", "-m");
pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1);
}
set_oldestmxid = strtoul(endptr + 1, &endptr2, 0); if (endptr2 == endptr + 1 || *endptr2 != '\0' || errno != 0)
{
pg_log_error("invalid argument for option %s", "-m");
pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1);
}
/* *XXXIt'dbenicetohavemoresanitycheckshere,e.g.so *thatoldestisnotwrappedaroundw.r.t.nextMulti.
*/ if (set_oldestmxid == 0)
pg_fatal("oldest multitransaction ID (-m) must not be 0");
mxid_given = true; break;
case'O':
errno = 0;
tmpi64 = strtoi64(optarg, &endptr, 0); if (endptr == optarg || *endptr != '\0' || errno != 0)
{
pg_log_error("invalid argument for option %s", "-O");
pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1);
} if (tmpi64 < 0 || tmpi64 > (int64) MaxMultiXactOffset)
pg_fatal("multitransaction offset (-O) must be between 0 and %u", MaxMultiXactOffset);
if (!option_parse_int(optarg, "--wal-segsize", 1, 1024, &wal_segsize_mb)) exit(1);
set_wal_segsize = wal_segsize_mb * 1024 * 1024; if (!IsValidWalSegSize(set_wal_segsize))
pg_fatal("argument of %s must be a power of two between 1 and 1024", "--wal-segsize"); break;
}
case2:
{
errno = 0;
if (pg_strcasecmp(optarg, "signed") == 0)
set_char_signedness = 1; elseif (pg_strcasecmp(optarg, "unsigned") == 0)
set_char_signedness = 0; else
{
pg_log_error("invalid argument for option %s", "--char-signedness");
pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1);
} break;
}
default: /* getopt_long already emitted a complaint */
pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1);
}
}
/* Complain if any arguments remain */ if (optind < argc)
{
pg_log_error("too many command-line arguments (first is \"%s\")",
argv[optind]);
pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1);
}
if (DataDir == NULL)
{
pg_log_error("no data directory specified");
pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1);
}
/* *Don'tallowpg_resetwaltoberunasroot,toavoidoverwritingthe *ownershipoffilesinthedatadirectory.Weneedonlycheckforroot *--anyotheruserwon'thavesufficientpermissionstomodifyfilesin *thedatadirectory.
*/ #ifndef WIN32 if (geteuid() == 0)
{
pg_log_error("cannot be executed by \"root\"");
pg_log_error_hint("You must run %s as the PostgreSQL superuser.",
progname); exit(1);
} #endif
get_restricted_token();
/* Set mask based on PGDATA permissions */ if (!GetDataDirectoryCreatePerm(DataDir))
pg_fatal("could not read permissions of directory \"%s\": %m",
DataDir);
umask(pg_mode_mask);
if (chdir(DataDir) < 0)
pg_fatal("could not change directory to \"%s\": %m",
DataDir);
/* Check that data directory matches our server version */
CheckDataVersion();
/* *Checkforapostmasterlockfile---ifthereisone,refuseto *proceed,ongroundswemightbeinterferingwithaliveinstallation.
*/ if ((fd = open("postmaster.pid", O_RDONLY, 0)) < 0)
{ if (errno != ENOENT)
pg_fatal("could not open file \"%s\" for reading: %m", "postmaster.pid");
} else
{
pg_log_error("lock file \"%s\" exists", "postmaster.pid");
pg_log_error_hint("Is a server running? If not, delete the lock file and try again."); exit(1);
}
/* *Attempttoreadtheexistingpg_controlfile
*/ if (!read_controlfile())
GuessControlValues();
if (set_wal_segsize != 0)
ControlFile.xlog_seg_size = WalSegSz;
if (set_char_signedness != -1)
ControlFile.default_char_signedness = (set_char_signedness == 1);
if (minXlogSegNo > newXlogSegNo)
newXlogSegNo = minXlogSegNo;
if (noupdate)
{
PrintNewControlValues(); exit(0);
}
/* *Ifwehadtoguessanything,and-fwasnotgiven,justprintthe *guessedvaluesandexit.
*/ if (guessed && !force)
{
PrintNewControlValues();
pg_log_error("not proceeding because control file values were guessed");
pg_log_error_hint("If these values seem acceptable, use -f to force reset."); exit(1);
}
/* *Don'tresetfromadirtypg_controlwithout-f,either.
*/ if (ControlFile.state != DB_SHUTDOWNED && !force)
{
pg_log_error("database server was not shut down cleanly");
pg_log_error_detail("Resetting the write-ahead log might cause data to be lost.");
pg_log_error_hint("If you want to proceed anyway, use -f to force reset."); exit(1);
}
if ((ver_fd = fopen(ver_file, "r")) == NULL)
pg_fatal("could not open file \"%s\" for reading: %m",
ver_file);
/* version number has to be the first line read */ if (!fgets(rawline, sizeof(rawline), ver_fd))
{ if (!ferror(ver_fd))
pg_fatal("unexpected empty file \"%s\"", ver_file); else
pg_fatal("could not read file \"%s\": %m", ver_file);
}
/* strip trailing newline and carriage return */
(void) pg_strip_crlf(rawline);
if (strcmp(rawline, PG_MAJORVERSION) != 0)
{
pg_log_error("data directory is of wrong version");
pg_log_error_detail("File \"%s\" contains \"%s\", which is not compatible with this program's version \"%s\".",
ver_file, rawline, PG_MAJORVERSION); exit(1);
}
fclose(ver_fd);
}
/* *Trytoreadtheexistingpg_controlfile. * *Thisroutineisalsoresponsibleforupdatingoldpg_controlversions *tothecurrentformat.(Currentlywedon'tdoanythingofthesort.)
*/ staticbool
read_controlfile(void)
{ int fd; int len; char *buffer;
pg_crc32c crc;
if ((fd = open(XLOG_CONTROL_FILE, O_RDONLY | PG_BINARY, 0)) < 0)
{ /* *Ifpg_controlisnotthereatall,orwecan'treadit,theodds *arewe'vebeenhandedabadDataDirpath,sogiveup.Usercando *"touchpg_control"toforceustoproceed.
*/
pg_log_error("could not open file \"%s\" for reading: %m",
XLOG_CONTROL_FILE); if (errno == ENOENT)
pg_log_error_hint("If you are sure the data directory path is correct, execute\n" " touch %s\n" "and try again.",
XLOG_CONTROL_FILE); exit(1);
}
/* Use malloc to ensure we have a maxaligned buffer */
buffer = (char *) pg_malloc(PG_CONTROL_FILE_SIZE);
len = read(fd, buffer, PG_CONTROL_FILE_SIZE); if (len < 0)
pg_fatal("could not read file \"%s\": %m", XLOG_CONTROL_FILE);
close(fd);
if (!EQ_CRC32C(crc, ((ControlFileData *) buffer)->crc))
{ /* We will use the data but treat it as guessed. */
pg_log_warning("pg_control exists but has invalid CRC; proceed with caution");
guessed = true;
}
/* Write the first page */
XLogFilePath(path, ControlFile.checkPointCopy.ThisTimeLineID,
newXlogSegNo, WalSegSz);
unlink(path);
fd = open(path, O_RDWR | O_CREAT | O_EXCL | PG_BINARY,
pg_file_create_mode); if (fd < 0)
pg_fatal("could not open file \"%s\": %m", path);
errno = 0; if (write(fd, buffer.data, XLOG_BLCKSZ) != XLOG_BLCKSZ)
{ /* if write didn't set errno, assume problem is no disk space */ if (errno == 0)
errno = ENOSPC;
pg_fatal("could not write file \"%s\": %m", path);
}
/* Fill the rest of the file with zeroes */
memset(buffer.data, 0, XLOG_BLCKSZ); for (nbytes = XLOG_BLCKSZ; nbytes < WalSegSz; nbytes += XLOG_BLCKSZ)
{
errno = 0; if (write(fd, buffer.data, XLOG_BLCKSZ) != XLOG_BLCKSZ)
{ if (errno == 0)
errno = ENOSPC;
pg_fatal("could not write file \"%s\": %m", path);
}
}
printf(_("\nOptions:\n"));
printf(_(" [-D, --pgdata=]DATADIR data directory\n"));
printf(_(" -f, --force force update to be done even after unclean shutdown or\n" " if pg_control values had to be guessed\n"));
printf(_(" -n, --dry-run no update, just show what would be done\n"));
printf(_(" -V, --version output version information, then exit\n"));
printf(_(" -?, --help show this help, then exit\n"));
printf(_("\nOptions to override control file values:\n"));
printf(_(" -c, --commit-timestamp-ids=XID,XID\n" " set oldest and newest transactions bearing\n" " commit timestamp (zero means no change)\n"));
printf(_(" -e, --epoch=XIDEPOCH set next transaction ID epoch\n"));
printf(_(" -l, --next-wal-file=WALFILE set minimum starting location for new WAL\n"));
printf(_(" -m, --multixact-ids=MXID,MXID set next and oldest multitransaction ID\n"));
printf(_(" -o, --next-oid=OID set next OID\n"));
printf(_(" -O, --multixact-offset=OFFSET set next multitransaction offset\n"));
printf(_(" -u, --oldest-transaction-id=XID set oldest transaction ID\n"));
printf(_(" -x, --next-transaction-id=XID set next transaction ID\n"));
printf(_(" --char-signedness=OPTION set char signedness to \"signed\" or \"unsigned\"\n"));
printf(_(" --wal-segsize=SIZE size of WAL segments, in megabytes\n"));
printf(_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
printf(_("%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.20 Sekunden
(vorverarbeitet am 2026-08-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.