/* *Becausewetestthepg_resetwaloutputasstrings,ithastobein *English.Copiedfrompg_regress.c.
*/ if (getenv("LC_COLLATE"))
lc_collate = pg_strdup(getenv("LC_COLLATE")); if (getenv("LC_CTYPE"))
lc_ctype = pg_strdup(getenv("LC_CTYPE")); if (getenv("LC_MONETARY"))
lc_monetary = pg_strdup(getenv("LC_MONETARY")); if (getenv("LC_NUMERIC"))
lc_numeric = pg_strdup(getenv("LC_NUMERIC")); if (getenv("LC_TIME"))
lc_time = pg_strdup(getenv("LC_TIME")); if (getenv("LANG"))
lang = pg_strdup(getenv("LANG")); if (getenv("LANGUAGE"))
language = pg_strdup(getenv("LANGUAGE")); if (getenv("LC_ALL"))
lc_all = pg_strdup(getenv("LC_ALL")); if (getenv("LC_MESSAGES"))
lc_messages = pg_strdup(getenv("LC_MESSAGES"));
unsetenv("LC_COLLATE");
unsetenv("LC_CTYPE");
unsetenv("LC_MONETARY");
unsetenv("LC_NUMERIC");
unsetenv("LC_TIME"); #ifndef WIN32
unsetenv("LANG"); #else /* On Windows the default locale may not be English, so force it */
setenv("LANG", "en", 1); #endif
unsetenv("LANGUAGE");
unsetenv("LC_ALL");
setenv("LC_MESSAGES", "C", 1);
/* *Checkforcleanshutdown
*/ if (!live_check || cluster == &new_cluster)
{ /* only pg_controldata outputs the cluster state */
snprintf(cmd, sizeof(cmd), "\"%s/pg_controldata\" \"%s\"",
cluster->bindir, cluster->pgdata);
fflush(NULL);
if ((output = popen(cmd, "r")) == NULL)
pg_fatal("could not get control data using %s: %m", cmd);
/* we have the result of cmd in "output". so parse it line by line now */ while (fgets(bufin, sizeof(bufin), output))
{ if ((p = strstr(bufin, "Database cluster state:")) != NULL)
{
p = strchr(p, ':');
if (p == NULL || strlen(p) <= 1)
pg_fatal("%d: database cluster state problem", __LINE__);
p++; /* remove ':' char */
/* *Wecheckedearlierforapostmasterlockfile,andifwe *foundone,wetriedtostart/stoptheservertoreplaythe *WAL.However,pg_ctl-mimmediatedoesn'tleavealock *file,butdoesrequireWALreplay,sowecheckherethat *theserverwasshutdowncleanly,fromthecontroldata *perspective.
*/ /* Remove trailing newline and leading spaces */
(void) pg_strip_crlf(p); while (*p == ' ')
p++; if (strcmp(p, "shut down in recovery") == 0)
{ if (cluster == &old_cluster)
pg_fatal("The source cluster was shut down while in recovery mode. To upgrade, use \"rsync\" as documented or shut it down as a primary."); else
pg_fatal("The target cluster was shut down while in recovery mode. To upgrade, use \"rsync\" as documented or shut it down as a primary.");
} elseif (strcmp(p, "shut down") != 0)
{ if (cluster == &old_cluster)
pg_fatal("The source cluster was not shut down cleanly, state reported as: \"%s\"", p); else
pg_fatal("The target cluster was not shut down cleanly, state reported as: \"%s\"", p);
}
got_cluster_state = true;
}
}
rc = pclose(output); if (rc != 0)
pg_fatal("could not get control data using %s: %s",
cmd, wait_result_to_str(rc));
if (!got_cluster_state)
{ if (cluster == &old_cluster)
pg_fatal("The source cluster lacks cluster state information:"); else
pg_fatal("The target cluster lacks cluster state information:");
}
}
/* pg_resetxlog has been renamed to pg_resetwal in version 10 */ if (GET_MAJOR_VERSION(cluster->bin_version) <= 906)
resetwal_bin = "pg_resetxlog\" -n"; else
resetwal_bin = "pg_resetwal\" -n";
snprintf(cmd, sizeof(cmd), "\"%s/%s \"%s\"",
cluster->bindir,
live_check ? "pg_controldata\"" : resetwal_bin,
cluster->pgdata);
fflush(NULL);
if ((output = popen(cmd, "r")) == NULL)
pg_fatal("could not get control data using %s: %m", cmd);
/* Only in <= 9.2 */ if (GET_MAJOR_VERSION(cluster->major_version) <= 902)
{
cluster->controldata.data_checksum_version = 0;
got_data_checksum_version = true;
}
/* we have the result of cmd in "output". so parse it line by line now */ while (fgets(bufin, sizeof(bufin), output))
{ /* In verbose mode, log each line */
pg_strip_crlf(bufin);
pg_log(PG_VERBOSE, "%s", bufin);
if ((p = strstr(bufin, "pg_control version number:")) != NULL)
{
p = strchr(p, ':');
/* Skip the colon and any whitespace after it */
p++; while (isspace((unsignedchar) *p))
p++;
/* The value should be either 'signed' or 'unsigned' */ if (strcmp(p, "signed") != 0 && strcmp(p, "unsigned") != 0)
pg_fatal("%d: controldata retrieval problem", __LINE__);
if (!got_date_is_int)
pg_log(PG_REPORT, " dates/times are integers?");
/* value added in Postgres 9.3 */ if (!got_data_checksum_version)
pg_log(PG_REPORT, " data checksum version");
/* value added in Postgres 18 */ if (!got_default_char_signedness)
pg_log(PG_REPORT, " default char signedness");
pg_fatal("Cannot continue without required control information, terminating");
}
}
/* *check_control_data() * *checktomakesurethecontroldatasettingsarecompatible
*/ void
check_control_data(ControlData *oldctrl,
ControlData *newctrl)
{ if (oldctrl->align == 0 || oldctrl->align != newctrl->align)
pg_fatal("old and new pg_controldata alignments are invalid or do not match.\n" "Likely one cluster is a 32-bit install, the other 64-bit");
if (oldctrl->blocksz == 0 || oldctrl->blocksz != newctrl->blocksz)
pg_fatal("old and new pg_controldata block sizes are invalid or do not match");
if (oldctrl->largesz == 0 || oldctrl->largesz != newctrl->largesz)
pg_fatal("old and new pg_controldata maximum relation segment sizes are invalid or do not match");
if (oldctrl->walsz == 0 || oldctrl->walsz != newctrl->walsz)
pg_fatal("old and new pg_controldata WAL block sizes are invalid or do not match");
if (oldctrl->walseg == 0 || oldctrl->walseg != newctrl->walseg)
pg_fatal("old and new pg_controldata WAL segment sizes are invalid or do not match");
if (oldctrl->ident == 0 || oldctrl->ident != newctrl->ident)
pg_fatal("old and new pg_controldata maximum identifier lengths are invalid or do not match");
if (oldctrl->index == 0 || oldctrl->index != newctrl->index)
pg_fatal("old and new pg_controldata maximum indexed columns are invalid or do not match");
if (oldctrl->toast == 0 || oldctrl->toast != newctrl->toast)
pg_fatal("old and new pg_controldata maximum TOAST chunk sizes are invalid or do not match");
/* large_object added in 9.5, so it might not exist in the old cluster */ if (oldctrl->large_object != 0 &&
oldctrl->large_object != newctrl->large_object)
pg_fatal("old and new pg_controldata large-object chunk sizes are invalid or do not match");
if (oldctrl->date_is_int != newctrl->date_is_int)
pg_fatal("old and new pg_controldata date/time storage types do not match");
/* *Wemighteventuallyallowupgradesfromchecksumtono-checksum *clusters.
*/ if (oldctrl->data_checksum_version == 0 &&
newctrl->data_checksum_version != 0)
pg_fatal("old cluster does not use data checksums but the new one does"); elseif (oldctrl->data_checksum_version != 0 &&
newctrl->data_checksum_version == 0)
pg_fatal("old cluster uses data checksums but the new one does not"); elseif (oldctrl->data_checksum_version != newctrl->data_checksum_version)
pg_fatal("old and new cluster pg_controldata checksum versions do not match");
}
/* rename pg_control so old server cannot be accidentally started */ /* translator: %s is the file path of the control file */
prep_status("Adding \".old\" suffix to old \"%s\"", XLOG_CONTROL_FILE);
snprintf(old_path, sizeof(old_path), "%s/%s", old_cluster.pgdata, XLOG_CONTROL_FILE);
snprintf(new_path, sizeof(new_path), "%s/%s.old", old_cluster.pgdata, XLOG_CONTROL_FILE); if (pg_mv_file(old_path, new_path) != 0)
pg_fatal("could not rename file \"%s\" to \"%s\": %m",
old_path, new_path);
check_ok();
if (transfer_mode == TRANSFER_MODE_LINK) /* translator: %s/%s is the file path of the control file */
pg_log(PG_REPORT, "\n" "If you want to start the old cluster, you will need to remove\n" "the \".old\" suffix from \"%s/%s.old\".\n" "Because \"link\" mode was used, the old cluster cannot be safely\n" "started once the new cluster has been started.",
old_cluster.pgdata, XLOG_CONTROL_FILE); elseif (transfer_mode == TRANSFER_MODE_SWAP)
pg_log(PG_REPORT, "\n" "Because \"swap\" mode was used, the old cluster can no longer be\n" "safely started."); else
pg_fatal("unrecognized transfer mode");
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.4 Sekunden
(vorverarbeitet am 2026-08-07)
¤
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.