104 if (
getenv(
"LC_MESSAGES"))
120 setenv(
"LC_MESSAGES",
"C", 1);
128 snprintf(cmd,
sizeof(cmd),
"\"%s/pg_controldata\" \"%s\"",
133 pg_fatal(
"could not get control data using %s: %m", cmd);
159 if (
strcmp(p,
"shut down in recovery") == 0)
162 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.");
164 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.");
166 else if (
strcmp(p,
"shut down") != 0)
169 pg_fatal(
"The source cluster was not shut down cleanly, state reported as: \"%s\"", p);
171 pg_fatal(
"The target cluster was not shut down cleanly, state reported as: \"%s\"", p);
179 pg_fatal(
"could not get control data using %s: %s",
185 pg_fatal(
"The source cluster lacks cluster state information:");
187 pg_fatal(
"The target cluster lacks cluster state information:");
196 snprintf(cmd,
sizeof(cmd),
"\"%s/%s \"%s\"",
203 pg_fatal(
"could not get control data using %s: %m", cmd);
208 cluster->controldata.data_checksum_version = 0;
239 else if ((p =
strstr(
bufin,
"Latest checkpoint's TimeLineID:")) !=
NULL)
250 else if ((p =
strstr(
bufin,
"First log file ID after reset:")) !=
NULL)
261 else if ((p =
strstr(
bufin,
"First log file segment after reset:")) !=
NULL)
313 else if ((p =
strstr(
bufin,
"Latest checkpoint's NextMultiXactId:")) !=
NULL)
324 else if ((p =
strstr(
bufin,
"Latest checkpoint's oldestXID:")) !=
NULL)
335 else if ((p =
strstr(
bufin,
"Latest checkpoint's oldestMultiXid:")) !=
NULL)
346 else if ((p =
strstr(
bufin,
"Latest checkpoint's NextMultiOffset:")) !=
NULL)
357 else if ((p =
strstr(
bufin,
"First log segment after reset:")) !=
NULL)
363 p =
strpbrk(p,
"01234567890ABCDEF");
368 if (
strspn(p,
"0123456789ABCDEF") != 24)
408 else if ((p =
strstr(
bufin,
"Blocks per segment of large relation:")) !=
NULL)
441 else if ((p =
strstr(
bufin,
"Maximum length of identifiers:")) !=
NULL)
463 else if ((p =
strstr(
bufin,
"Maximum size of a TOAST chunk:")) !=
NULL)
516 while (
isspace((
unsigned char) *p))
520 if (
strcmp(p,
"signed") != 0 &&
strcmp(p,
"unsigned") != 0)
523 cluster->controldata.default_char_signedness =
strcmp(p,
"signed") == 0;
530 pg_fatal(
"could not get control data using %s: %s",
595 cluster->controldata.default_char_signedness =
true;
597 cluster->controldata.default_char_signedness =
false;
618 "The source cluster lacks some required control information:");
621 "The target cluster lacks some required control information:");
687 pg_fatal(
"Cannot continue without required control information, terminating");
702 pg_fatal(
"old and new pg_controldata alignments are invalid or do not match.\n"
703 "Likely one cluster is a 32-bit install, the other 64-bit");
706 pg_fatal(
"old and new pg_controldata block sizes are invalid or do not match");
709 pg_fatal(
"old and new pg_controldata maximum relation segment sizes are invalid or do not match");
712 pg_fatal(
"old and new pg_controldata WAL block sizes are invalid or do not match");
715 pg_fatal(
"old and new pg_controldata WAL segment sizes are invalid or do not match");
718 pg_fatal(
"old and new pg_controldata maximum identifier lengths are invalid or do not match");
721 pg_fatal(
"old and new pg_controldata maximum indexed columns are invalid or do not match");
724 pg_fatal(
"old and new pg_controldata maximum TOAST chunk sizes are invalid or do not match");
727 if (
oldctrl->large_object != 0 &&
729 pg_fatal(
"old and new pg_controldata large-object chunk sizes are invalid or do not match");
732 pg_fatal(
"old and new pg_controldata date/time storage types do not match");
743 if (
oldctrl->data_checksum_version == 0 &&
744 newctrl->data_checksum_version != 0)
745 pg_fatal(
"old cluster does not use data checksums but the new one does");
746 else if (
oldctrl->data_checksum_version != 0 &&
747 newctrl->data_checksum_version == 0)
748 pg_fatal(
"old cluster uses data checksums but the new one does not");
749 else if (
oldctrl->data_checksum_version !=
newctrl->data_checksum_version)
750 pg_fatal(
"old and new cluster pg_controldata checksum versions do not match");
767 pg_fatal(
"could not rename file \"%s\" to \"%s\": %m",
774 "If you want to start the old cluster, you will need to remove\n"
775 "the \".old\" suffix from \"%s/%s.old\".\n"
776 "Because \"link\" mode was used, the old cluster cannot be safely\n"
777 "started once the new cluster has been started.",
781 "Because \"swap\" mode was used, the old cluster can no longer be\n"
784 pg_fatal(
"unrecognized transfer mode");
#define Assert(condition)
void cluster(ParseState *pstate, ClusterStmt *stmt, bool isTopLevel)
void get_control_data(ClusterInfo *cluster)
void check_control_data(ControlData *oldctrl, ControlData *newctrl)
void disable_old_cluster(transferMode transfer_mode)
char * pg_strdup(const char *in)
static char * lc_messages
static void check_ok(void)
static char * lc_monetary
#define LARGE_OBJECT_SIZE_PG_CONTROL_VER
#define MULTIXACT_FORMATCHANGE_CAT_VER
void void unsigned int str2uint(const char *str)
void void pg_log(eLogType type, const char *fmt,...) pg_attribute_printf(2
#define GET_MAJOR_VERSION(v)
#define DEFAULT_CHAR_SIGNEDNESS_CAT_VER
void prep_status(const char *fmt,...) pg_attribute_printf(1
size_t strlcpy(char *dst, const char *src, size_t siz)
int pg_strip_crlf(char *str)
char * wait_result_to_str(int exitstatus)
#define XLOG_CONTROL_FILE