mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
pg_upgrade: Split off pg_fatal() from pg_log()
This allows decorating pg_fatal() with noreturn compiler hints, leading to better diagnostics. Reviewed-by: Marko Tiikkaja <marko@joh.to>
This commit is contained in:
@ -118,7 +118,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
fflush(stderr);
|
||||
|
||||
if ((output = popen(cmd, "r")) == NULL)
|
||||
pg_log(PG_FATAL, "Could not get control data using %s: %s\n",
|
||||
pg_fatal("Could not get control data using %s: %s\n",
|
||||
cmd, getErrorText(errno));
|
||||
|
||||
/* Only pre-8.4 has these so if they are not set below we will check later */
|
||||
@ -155,8 +155,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
{
|
||||
for (p = bufin; *p; p++)
|
||||
if (!isascii(*p))
|
||||
pg_log(PG_FATAL,
|
||||
"The 8.3 cluster's pg_controldata is incapable of outputting ASCII, even\n"
|
||||
pg_fatal("The 8.3 cluster's pg_controldata is incapable of outputting ASCII, even\n"
|
||||
"with LANG=C. You must upgrade this cluster to a newer version of PostgreSQL\n"
|
||||
"8.3 to fix this bug. PostgreSQL 8.3.7 and later are known to work properly.\n");
|
||||
}
|
||||
@ -167,7 +166,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
p = strchr(p, ':');
|
||||
|
||||
if (p == NULL || strlen(p) <= 1)
|
||||
pg_log(PG_FATAL, "%d: pg_resetxlog problem\n", __LINE__);
|
||||
pg_fatal("%d: pg_resetxlog problem\n", __LINE__);
|
||||
|
||||
p++; /* removing ':' char */
|
||||
cluster->controldata.ctrl_ver = str2uint(p);
|
||||
@ -177,7 +176,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
p = strchr(p, ':');
|
||||
|
||||
if (p == NULL || strlen(p) <= 1)
|
||||
pg_log(PG_FATAL, "%d: controldata retrieval problem\n", __LINE__);
|
||||
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
|
||||
|
||||
p++; /* removing ':' char */
|
||||
cluster->controldata.cat_ver = str2uint(p);
|
||||
@ -187,14 +186,14 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
/* Skip the colon and any whitespace after it */
|
||||
p = strchr(p, ':');
|
||||
if (p == NULL || strlen(p) <= 1)
|
||||
pg_log(PG_FATAL, "%d: controldata retrieval problem\n", __LINE__);
|
||||
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
|
||||
p = strpbrk(p, "01234567890ABCDEF");
|
||||
if (p == NULL || strlen(p) <= 1)
|
||||
pg_log(PG_FATAL, "%d: controldata retrieval problem\n", __LINE__);
|
||||
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
|
||||
|
||||
/* Make sure it looks like a valid WAL file name */
|
||||
if (strspn(p, "0123456789ABCDEF") != 24)
|
||||
pg_log(PG_FATAL, "%d: controldata retrieval problem\n", __LINE__);
|
||||
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
|
||||
|
||||
strlcpy(cluster->controldata.nextxlogfile, p, 25);
|
||||
got_nextxlogfile = true;
|
||||
@ -204,7 +203,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
p = strchr(p, ':');
|
||||
|
||||
if (p == NULL || strlen(p) <= 1)
|
||||
pg_log(PG_FATAL, "%d: controldata retrieval problem\n", __LINE__);
|
||||
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
|
||||
|
||||
p++; /* removing ':' char */
|
||||
logid = str2uint(p);
|
||||
@ -215,7 +214,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
p = strchr(p, ':');
|
||||
|
||||
if (p == NULL || strlen(p) <= 1)
|
||||
pg_log(PG_FATAL, "%d: controldata retrieval problem\n", __LINE__);
|
||||
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
|
||||
|
||||
p++; /* removing ':' char */
|
||||
segno = str2uint(p);
|
||||
@ -226,7 +225,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
p = strchr(p, ':');
|
||||
|
||||
if (p == NULL || strlen(p) <= 1)
|
||||
pg_log(PG_FATAL, "%d: controldata retrieval problem\n", __LINE__);
|
||||
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
|
||||
|
||||
p++; /* removing ':' char */
|
||||
cluster->controldata.chkpnt_tli = str2uint(p);
|
||||
@ -240,7 +239,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
op = strchr(p, ':');
|
||||
|
||||
if (op == NULL || strlen(op) <= 1)
|
||||
pg_log(PG_FATAL, "%d: controldata retrieval problem\n", __LINE__);
|
||||
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
|
||||
|
||||
op++; /* removing ':' char */
|
||||
cluster->controldata.chkpnt_nxtxid = str2uint(op);
|
||||
@ -251,7 +250,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
p = strchr(p, ':');
|
||||
|
||||
if (p == NULL || strlen(p) <= 1)
|
||||
pg_log(PG_FATAL, "%d: controldata retrieval problem\n", __LINE__);
|
||||
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
|
||||
|
||||
p++; /* removing ':' char */
|
||||
cluster->controldata.chkpnt_nxtoid = str2uint(p);
|
||||
@ -262,7 +261,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
p = strchr(p, ':');
|
||||
|
||||
if (p == NULL || strlen(p) <= 1)
|
||||
pg_log(PG_FATAL, "%d: controldata retrieval problem\n", __LINE__);
|
||||
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
|
||||
|
||||
p++; /* removing ':' char */
|
||||
cluster->controldata.chkpnt_nxtmulti = str2uint(p);
|
||||
@ -273,7 +272,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
p = strchr(p, ':');
|
||||
|
||||
if (p == NULL || strlen(p) <= 1)
|
||||
pg_log(PG_FATAL, "%d: controldata retrieval problem\n", __LINE__);
|
||||
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
|
||||
|
||||
p++; /* removing ':' char */
|
||||
cluster->controldata.chkpnt_oldstMulti = str2uint(p);
|
||||
@ -284,7 +283,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
p = strchr(p, ':');
|
||||
|
||||
if (p == NULL || strlen(p) <= 1)
|
||||
pg_log(PG_FATAL, "%d: controldata retrieval problem\n", __LINE__);
|
||||
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
|
||||
|
||||
p++; /* removing ':' char */
|
||||
cluster->controldata.chkpnt_nxtmxoff = str2uint(p);
|
||||
@ -295,7 +294,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
p = strchr(p, ':');
|
||||
|
||||
if (p == NULL || strlen(p) <= 1)
|
||||
pg_log(PG_FATAL, "%d: controldata retrieval problem\n", __LINE__);
|
||||
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
|
||||
|
||||
p++; /* removing ':' char */
|
||||
cluster->controldata.align = str2uint(p);
|
||||
@ -306,7 +305,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
p = strchr(p, ':');
|
||||
|
||||
if (p == NULL || strlen(p) <= 1)
|
||||
pg_log(PG_FATAL, "%d: controldata retrieval problem\n", __LINE__);
|
||||
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
|
||||
|
||||
p++; /* removing ':' char */
|
||||
cluster->controldata.blocksz = str2uint(p);
|
||||
@ -317,7 +316,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
p = strchr(p, ':');
|
||||
|
||||
if (p == NULL || strlen(p) <= 1)
|
||||
pg_log(PG_FATAL, "%d: controldata retrieval problem\n", __LINE__);
|
||||
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
|
||||
|
||||
p++; /* removing ':' char */
|
||||
cluster->controldata.largesz = str2uint(p);
|
||||
@ -328,7 +327,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
p = strchr(p, ':');
|
||||
|
||||
if (p == NULL || strlen(p) <= 1)
|
||||
pg_log(PG_FATAL, "%d: controldata retrieval problem\n", __LINE__);
|
||||
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
|
||||
|
||||
p++; /* removing ':' char */
|
||||
cluster->controldata.walsz = str2uint(p);
|
||||
@ -339,7 +338,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
p = strchr(p, ':');
|
||||
|
||||
if (p == NULL || strlen(p) <= 1)
|
||||
pg_log(PG_FATAL, "%d: controldata retrieval problem\n", __LINE__);
|
||||
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
|
||||
|
||||
p++; /* removing ':' char */
|
||||
cluster->controldata.walseg = str2uint(p);
|
||||
@ -350,7 +349,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
p = strchr(p, ':');
|
||||
|
||||
if (p == NULL || strlen(p) <= 1)
|
||||
pg_log(PG_FATAL, "%d: controldata retrieval problem\n", __LINE__);
|
||||
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
|
||||
|
||||
p++; /* removing ':' char */
|
||||
cluster->controldata.ident = str2uint(p);
|
||||
@ -361,7 +360,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
p = strchr(p, ':');
|
||||
|
||||
if (p == NULL || strlen(p) <= 1)
|
||||
pg_log(PG_FATAL, "%d: controldata retrieval problem\n", __LINE__);
|
||||
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
|
||||
|
||||
p++; /* removing ':' char */
|
||||
cluster->controldata.index = str2uint(p);
|
||||
@ -372,7 +371,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
p = strchr(p, ':');
|
||||
|
||||
if (p == NULL || strlen(p) <= 1)
|
||||
pg_log(PG_FATAL, "%d: controldata retrieval problem\n", __LINE__);
|
||||
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
|
||||
|
||||
p++; /* removing ':' char */
|
||||
cluster->controldata.toast = str2uint(p);
|
||||
@ -383,7 +382,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
p = strchr(p, ':');
|
||||
|
||||
if (p == NULL || strlen(p) <= 1)
|
||||
pg_log(PG_FATAL, "%d: controldata retrieval problem\n", __LINE__);
|
||||
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
|
||||
|
||||
p++; /* removing ':' char */
|
||||
cluster->controldata.date_is_int = strstr(p, "64-bit integers") != NULL;
|
||||
@ -394,7 +393,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
p = strchr(p, ':');
|
||||
|
||||
if (p == NULL || strlen(p) <= 1)
|
||||
pg_log(PG_FATAL, "%d: controldata retrieval problem\n", __LINE__);
|
||||
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
|
||||
|
||||
p++; /* removing ':' char */
|
||||
/* used later for contrib check */
|
||||
@ -406,7 +405,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
p = strchr(p, ':');
|
||||
|
||||
if (p == NULL || strlen(p) <= 1)
|
||||
pg_log(PG_FATAL, "%d: controldata retrieval problem\n", __LINE__);
|
||||
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
|
||||
|
||||
p++; /* removing ':' char */
|
||||
/* used later for contrib check */
|
||||
@ -419,7 +418,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
p = strchr(p, ':');
|
||||
|
||||
if (p == NULL || strlen(p) <= 1)
|
||||
pg_log(PG_FATAL, "%d: controldata retrieval problem\n", __LINE__);
|
||||
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
|
||||
|
||||
p++; /* removing ':' char */
|
||||
/* skip leading spaces and remove trailing newline */
|
||||
@ -434,7 +433,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
p = strchr(p, ':');
|
||||
|
||||
if (p == NULL || strlen(p) <= 1)
|
||||
pg_log(PG_FATAL, "%d: controldata retrieval problem\n", __LINE__);
|
||||
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
|
||||
|
||||
p++; /* removing ':' char */
|
||||
/* skip leading spaces and remove trailing newline */
|
||||
@ -559,8 +558,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
if (!got_data_checksum_version)
|
||||
pg_log(PG_REPORT, " data checksum version\n");
|
||||
|
||||
pg_log(PG_FATAL,
|
||||
"Cannot continue without required control information, terminating\n");
|
||||
pg_fatal("Cannot continue without required control information, terminating\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -575,37 +573,29 @@ check_control_data(ControlData *oldctrl,
|
||||
ControlData *newctrl)
|
||||
{
|
||||
if (oldctrl->align == 0 || oldctrl->align != newctrl->align)
|
||||
pg_log(PG_FATAL,
|
||||
"old and new pg_controldata alignments are invalid or do not match\n"
|
||||
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\n");
|
||||
|
||||
if (oldctrl->blocksz == 0 || oldctrl->blocksz != newctrl->blocksz)
|
||||
pg_log(PG_FATAL,
|
||||
"old and new pg_controldata block sizes are invalid or do not match\n");
|
||||
pg_fatal("old and new pg_controldata block sizes are invalid or do not match\n");
|
||||
|
||||
if (oldctrl->largesz == 0 || oldctrl->largesz != newctrl->largesz)
|
||||
pg_log(PG_FATAL,
|
||||
"old and new pg_controldata maximum relation segement sizes are invalid or do not match\n");
|
||||
pg_fatal("old and new pg_controldata maximum relation segement sizes are invalid or do not match\n");
|
||||
|
||||
if (oldctrl->walsz == 0 || oldctrl->walsz != newctrl->walsz)
|
||||
pg_log(PG_FATAL,
|
||||
"old and new pg_controldata WAL block sizes are invalid or do not match\n");
|
||||
pg_fatal("old and new pg_controldata WAL block sizes are invalid or do not match\n");
|
||||
|
||||
if (oldctrl->walseg == 0 || oldctrl->walseg != newctrl->walseg)
|
||||
pg_log(PG_FATAL,
|
||||
"old and new pg_controldata WAL segment sizes are invalid or do not match\n");
|
||||
pg_fatal("old and new pg_controldata WAL segment sizes are invalid or do not match\n");
|
||||
|
||||
if (oldctrl->ident == 0 || oldctrl->ident != newctrl->ident)
|
||||
pg_log(PG_FATAL,
|
||||
"old and new pg_controldata maximum identifier lengths are invalid or do not match\n");
|
||||
pg_fatal("old and new pg_controldata maximum identifier lengths are invalid or do not match\n");
|
||||
|
||||
if (oldctrl->index == 0 || oldctrl->index != newctrl->index)
|
||||
pg_log(PG_FATAL,
|
||||
"old and new pg_controldata maximum indexed columns are invalid or do not match\n");
|
||||
pg_fatal("old and new pg_controldata maximum indexed columns are invalid or do not match\n");
|
||||
|
||||
if (oldctrl->toast == 0 || oldctrl->toast != newctrl->toast)
|
||||
pg_log(PG_FATAL,
|
||||
"old and new pg_controldata maximum TOAST chunk sizes are invalid or do not match\n");
|
||||
pg_fatal("old and new pg_controldata maximum TOAST chunk sizes are invalid or do not match\n");
|
||||
|
||||
if (oldctrl->date_is_int != newctrl->date_is_int)
|
||||
{
|
||||
@ -615,8 +605,7 @@ check_control_data(ControlData *oldctrl,
|
||||
/*
|
||||
* This is a common 8.3 -> 8.4 upgrade problem, so we are more verbose
|
||||
*/
|
||||
pg_log(PG_FATAL,
|
||||
"You will need to rebuild the new server with configure option\n"
|
||||
pg_fatal("You will need to rebuild the new server with configure option\n"
|
||||
"--disable-integer-datetimes or get server binaries built with those\n"
|
||||
"options.\n");
|
||||
}
|
||||
@ -627,8 +616,7 @@ check_control_data(ControlData *oldctrl,
|
||||
*/
|
||||
if (oldctrl->data_checksum_version != newctrl->data_checksum_version)
|
||||
{
|
||||
pg_log(PG_FATAL,
|
||||
"old and new pg_controldata checksum versions are invalid or do not match\n");
|
||||
pg_fatal("old and new pg_controldata checksum versions are invalid or do not match\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -645,7 +633,7 @@ disable_old_cluster(void)
|
||||
snprintf(old_path, sizeof(old_path), "%s/global/pg_control", old_cluster.pgdata);
|
||||
snprintf(new_path, sizeof(new_path), "%s/global/pg_control.old", old_cluster.pgdata);
|
||||
if (pg_mv_file(old_path, new_path) != 0)
|
||||
pg_log(PG_FATAL, "Unable to rename %s to %s.\n", old_path, new_path);
|
||||
pg_fatal("Unable to rename %s to %s.\n", old_path, new_path);
|
||||
check_ok();
|
||||
|
||||
pg_log(PG_REPORT, "\n"
|
||||
|
Reference in New Issue
Block a user