Commit 912bc4f0 authored by Peter Eisentraut's avatar Peter Eisentraut

Make pg_upgrade output more consistent with project style

Add errno-based output to error messages where appropriate, reformat
blocks to about 72 characters per line, use spaces instead of tabs for
indentation, and other style adjustments.
parent afc9635c
...@@ -147,10 +147,9 @@ report_clusters_compatible(void) ...@@ -147,10 +147,9 @@ report_clusters_compatible(void)
} }
pg_log(PG_REPORT, "\n" pg_log(PG_REPORT, "\n"
"| If pg_upgrade fails after this point, you must\n" "If pg_upgrade fails after this point, you must re-initdb the new cluster\n"
"| re-initdb the new cluster before continuing.\n" "before continuing. You will also need to remove the \".old\" suffix from\n"
"| You will also need to remove the \".old\" suffix\n" "%s/global/pg_control.old.\n", old_cluster.pgdata);
"| from %s/global/pg_control.old.\n", old_cluster.pgdata);
} }
...@@ -198,21 +197,20 @@ output_completion_banner(char *deletion_script_file_name) ...@@ -198,21 +197,20 @@ output_completion_banner(char *deletion_script_file_name)
/* Did we copy the free space files? */ /* Did we copy the free space files? */
if (GET_MAJOR_VERSION(old_cluster.major_version) >= 804) if (GET_MAJOR_VERSION(old_cluster.major_version) >= 804)
pg_log(PG_REPORT, pg_log(PG_REPORT,
"| Optimizer statistics are not transferred by pg_upgrade\n" "Optimizer statistics are not transferred by pg_upgrade so consider\n"
"| so consider running:\n" "running:\n"
"| \tvacuumdb --all --analyze-only\n" " vacuumdb --all --analyze-only\n"
"| on the newly-upgraded cluster.\n\n"); "on the newly-upgraded cluster.\n\n");
else else
pg_log(PG_REPORT, pg_log(PG_REPORT,
"| Optimizer statistics and free space information\n" "Optimizer statistics and free space information are not transferred\n"
"| are not transferred by pg_upgrade so consider\n" "by pg_upgrade so consider running:\n"
"| running:\n" " vacuumdb --all --analyze\n"
"| \tvacuumdb --all --analyze\n" "on the newly-upgraded cluster.\n\n");
"| on the newly-upgraded cluster.\n\n");
pg_log(PG_REPORT, pg_log(PG_REPORT,
"| Running this script will delete the old cluster's data files:\n" "Running this script will delete the old cluster's data files:\n"
"| \t%s\n", " %s\n",
deletion_script_file_name); deletion_script_file_name);
} }
...@@ -427,8 +425,8 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name) ...@@ -427,8 +425,8 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name)
os_info.cwd, SCRIPT_EXT); os_info.cwd, SCRIPT_EXT);
if ((script = fopen(*deletion_script_file_name, "w")) == NULL) if ((script = fopen(*deletion_script_file_name, "w")) == NULL)
pg_log(PG_FATAL, "Could not create necessary file: %s\n", pg_log(PG_FATAL, "Could not open file \"%s\": %s\n",
*deletion_script_file_name); *deletion_script_file_name, getErrorText(errno));
#ifndef WIN32 #ifndef WIN32
/* add shebang header */ /* add shebang header */
...@@ -477,8 +475,8 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name) ...@@ -477,8 +475,8 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name)
#ifndef WIN32 #ifndef WIN32
if (chmod(*deletion_script_file_name, S_IRWXU) != 0) if (chmod(*deletion_script_file_name, S_IRWXU) != 0)
pg_log(PG_FATAL, "Could not add execute permission to file: %s\n", pg_log(PG_FATAL, "Could not add execute permission to file \"%s\": %s\n",
*deletion_script_file_name); *deletion_script_file_name, getErrorText(errno));
#endif #endif
check_ok(); check_ok();
...@@ -600,7 +598,8 @@ check_for_isn_and_int8_passing_mismatch(ClusterInfo *cluster) ...@@ -600,7 +598,8 @@ check_for_isn_and_int8_passing_mismatch(ClusterInfo *cluster)
{ {
found = true; found = true;
if (script == NULL && (script = fopen(output_path, "w")) == NULL) if (script == NULL && (script = fopen(output_path, "w")) == NULL)
pg_log(PG_FATAL, "Could not create necessary file: %s\n", output_path); pg_log(PG_FATAL, "Could not open file \"%s\": %s\n",
output_path, getErrorText(errno));
if (!db_used) if (!db_used)
{ {
fprintf(script, "Database: %s\n", active_db->db_name); fprintf(script, "Database: %s\n", active_db->db_name);
...@@ -623,15 +622,13 @@ check_for_isn_and_int8_passing_mismatch(ClusterInfo *cluster) ...@@ -623,15 +622,13 @@ check_for_isn_and_int8_passing_mismatch(ClusterInfo *cluster)
{ {
pg_log(PG_REPORT, "fatal\n"); pg_log(PG_REPORT, "fatal\n");
pg_log(PG_FATAL, pg_log(PG_FATAL,
"| Your installation contains \"contrib/isn\" functions\n" "Your installation contains \"contrib/isn\" functions which rely on the\n"
"| which rely on the bigint data type. Your old and\n" "bigint data type. Your old and new clusters pass bigint values\n"
"| new clusters pass bigint values differently so this\n" "differently so this cluster cannot currently be upgraded. You can\n"
"| cluster cannot currently be upgraded. You can\n" "manually upgrade databases that use \"contrib/isn\" facilities and remove\n"
"| manually upgrade data that use \"contrib/isn\"\n" "\"contrib/isn\" from the old cluster and restart the upgrade. A list of\n"
"| facilities and remove \"contrib/isn\" from the\n" "the problem functions is in the file:\n"
"| old cluster and restart the upgrade. A list\n" " %s\n\n", output_path);
"| of the problem functions is in the file:\n"
"| \t%s\n\n", output_path);
} }
else else
check_ok(); check_ok();
...@@ -657,7 +654,7 @@ check_for_reg_data_type_usage(ClusterInfo *cluster) ...@@ -657,7 +654,7 @@ check_for_reg_data_type_usage(ClusterInfo *cluster)
bool found = false; bool found = false;
char output_path[MAXPGPATH]; char output_path[MAXPGPATH];
prep_status("Checking for reg* system oid user data types"); prep_status("Checking for reg* system OID user data types");
snprintf(output_path, sizeof(output_path), "%s/tables_using_reg.txt", snprintf(output_path, sizeof(output_path), "%s/tables_using_reg.txt",
os_info.cwd); os_info.cwd);
...@@ -702,7 +699,8 @@ check_for_reg_data_type_usage(ClusterInfo *cluster) ...@@ -702,7 +699,8 @@ check_for_reg_data_type_usage(ClusterInfo *cluster)
{ {
found = true; found = true;
if (script == NULL && (script = fopen(output_path, "w")) == NULL) if (script == NULL && (script = fopen(output_path, "w")) == NULL)
pg_log(PG_FATAL, "Could not create necessary file: %s\n", output_path); pg_log(PG_FATAL, "Could not open file \"%s\": %s\n",
output_path, getErrorText(errno));
if (!db_used) if (!db_used)
{ {
fprintf(script, "Database: %s\n", active_db->db_name); fprintf(script, "Database: %s\n", active_db->db_name);
...@@ -726,13 +724,12 @@ check_for_reg_data_type_usage(ClusterInfo *cluster) ...@@ -726,13 +724,12 @@ check_for_reg_data_type_usage(ClusterInfo *cluster)
{ {
pg_log(PG_REPORT, "fatal\n"); pg_log(PG_REPORT, "fatal\n");
pg_log(PG_FATAL, pg_log(PG_FATAL,
"| Your installation contains one of the reg* data types in\n" "Your installation contains one of the reg* data types in user tables.\n"
"| user tables. These data types reference system oids that\n" "These data types reference system OIDs that are not preserved by\n"
"| are not preserved by pg_upgrade, so this cluster cannot\n" "pg_upgrade, so this cluster cannot currently be upgraded. You can\n"
"| currently be upgraded. You can remove the problem tables\n" "remove the problem tables and restart the upgrade. A list of the problem\n"
"| and restart the upgrade. A list of the problem columns\n" "columns is in the file:\n"
"| is in the file:\n" " %s\n\n", output_path);
"| \t%s\n\n", output_path);
} }
else else
check_ok(); check_ok();
......
...@@ -451,7 +451,7 @@ get_control_data(ClusterInfo *cluster, bool live_check) ...@@ -451,7 +451,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
pg_log(PG_REPORT, " float8 argument passing method\n"); pg_log(PG_REPORT, " float8 argument passing method\n");
pg_log(PG_FATAL, pg_log(PG_FATAL,
"Unable to continue without required control information, terminating\n"); "Cannot continue without required control information, terminating\n");
} }
} }
...@@ -506,9 +506,9 @@ check_control_data(ControlData *oldctrl, ...@@ -506,9 +506,9 @@ check_control_data(ControlData *oldctrl,
* This is a common 8.3 -> 8.4 upgrade problem, so we are more verbose * This is a common 8.3 -> 8.4 upgrade problem, so we are more verbose
*/ */
pg_log(PG_FATAL, pg_log(PG_FATAL,
"You will need to rebuild the new server with configure\n" "You will need to rebuild the new server with configure option\n"
"--disable-integer-datetimes or get server binaries built\n" "--disable-integer-datetimes or get server binaries built with those\n"
"with those options.\n"); "options.\n");
} }
} }
......
...@@ -56,13 +56,13 @@ split_old_dump(void) ...@@ -56,13 +56,13 @@ split_old_dump(void)
snprintf(filename, sizeof(filename), "%s/%s", os_info.cwd, ALL_DUMP_FILE); snprintf(filename, sizeof(filename), "%s/%s", os_info.cwd, ALL_DUMP_FILE);
if ((all_dump = fopen(filename, "r")) == NULL) if ((all_dump = fopen(filename, "r")) == NULL)
pg_log(PG_FATAL, "Cannot open dump file %s\n", filename); pg_log(PG_FATAL, "Could not open dump file \"%s\": %s\n", filename, getErrorText(errno));
snprintf(filename, sizeof(filename), "%s/%s", os_info.cwd, GLOBALS_DUMP_FILE); snprintf(filename, sizeof(filename), "%s/%s", os_info.cwd, GLOBALS_DUMP_FILE);
if ((globals_dump = fopen(filename, "w")) == NULL) if ((globals_dump = fopen(filename, "w")) == NULL)
pg_log(PG_FATAL, "Cannot write to dump file %s\n", filename); pg_log(PG_FATAL, "Could not write to dump file \"%s\": %s\n", filename, getErrorText(errno));
snprintf(filename, sizeof(filename), "%s/%s", os_info.cwd, DB_DUMP_FILE); snprintf(filename, sizeof(filename), "%s/%s", os_info.cwd, DB_DUMP_FILE);
if ((db_dump = fopen(filename, "w")) == NULL) if ((db_dump = fopen(filename, "w")) == NULL)
pg_log(PG_FATAL, "Cannot write to dump file %s\n", filename); pg_log(PG_FATAL, "Could not write to dump file \"%s\": %s\n", filename, getErrorText(errno));
current_output = globals_dump; current_output = globals_dump;
/* patterns used to prevent our own username from being recreated */ /* patterns used to prevent our own username from being recreated */
......
...@@ -46,7 +46,7 @@ exec_prog(bool throw_error, const char *fmt,...) ...@@ -46,7 +46,7 @@ exec_prog(bool throw_error, const char *fmt,...)
if (result != 0) if (result != 0)
{ {
pg_log(throw_error ? PG_FATAL : PG_INFO, pg_log(throw_error ? PG_FATAL : PG_INFO,
"There were problems executing %s\n", cmd); "There were problems executing \"%s\"\n", cmd);
return 1; return 1;
} }
...@@ -72,8 +72,8 @@ is_server_running(const char *datadir) ...@@ -72,8 +72,8 @@ is_server_running(const char *datadir)
{ {
/* ENOTDIR means we will throw a more useful error later */ /* ENOTDIR means we will throw a more useful error later */
if (errno != ENOENT && errno != ENOTDIR) if (errno != ENOENT && errno != ENOTDIR)
pg_log(PG_FATAL, "could not open file \"%s\" for reading\n", pg_log(PG_FATAL, "could not open file \"%s\" for reading: %s\n",
path); path, getErrorText(errno));
return false; return false;
} }
...@@ -149,7 +149,7 @@ check_data_dir(const char *pg_data) ...@@ -149,7 +149,7 @@ check_data_dir(const char *pg_data)
requiredSubdirs[subdirnum]); requiredSubdirs[subdirnum]);
if (stat(subDirName, &statBuf) != 0) if (stat(subDirName, &statBuf) != 0)
report_status(PG_FATAL, "check for %s failed: %s\n", report_status(PG_FATAL, "check for \"%s\" failed: %s\n",
subDirName, getErrorText(errno)); subDirName, getErrorText(errno));
else if (!S_ISDIR(statBuf.st_mode)) else if (!S_ISDIR(statBuf.st_mode))
report_status(PG_FATAL, "%s is not a directory\n", report_status(PG_FATAL, "%s is not a directory\n",
...@@ -173,7 +173,7 @@ check_bin_dir(ClusterInfo *cluster) ...@@ -173,7 +173,7 @@ check_bin_dir(ClusterInfo *cluster)
/* check bindir */ /* check bindir */
if (stat(cluster->bindir, &statBuf) != 0) if (stat(cluster->bindir, &statBuf) != 0)
report_status(PG_FATAL, "check for %s failed: %s\n", report_status(PG_FATAL, "check for \"%s\" failed: %s\n",
cluster->bindir, getErrorText(errno)); cluster->bindir, getErrorText(errno));
else if (!S_ISDIR(statBuf.st_mode)) else if (!S_ISDIR(statBuf.st_mode))
report_status(PG_FATAL, "%s is not a directory\n", report_status(PG_FATAL, "%s is not a directory\n",
...@@ -216,10 +216,10 @@ validate_exec(const char *dir, const char *cmdName) ...@@ -216,10 +216,10 @@ validate_exec(const char *dir, const char *cmdName)
* Ensure that the file exists and is a regular file. * Ensure that the file exists and is a regular file.
*/ */
if (stat(path, &buf) < 0) if (stat(path, &buf) < 0)
pg_log(PG_FATAL, "check for %s failed - %s\n", pg_log(PG_FATAL, "check for \"%s\" failed: %s\n",
path, getErrorText(errno)); path, getErrorText(errno));
else if (!S_ISREG(buf.st_mode)) else if (!S_ISREG(buf.st_mode))
pg_log(PG_FATAL, "check for %s failed - not an executable file\n", pg_log(PG_FATAL, "check for \"%s\" failed: not an executable file\n",
path); path);
/* /*
...@@ -231,7 +231,7 @@ validate_exec(const char *dir, const char *cmdName) ...@@ -231,7 +231,7 @@ validate_exec(const char *dir, const char *cmdName)
#else #else
if ((buf.st_mode & S_IRUSR) == 0) if ((buf.st_mode & S_IRUSR) == 0)
#endif #endif
pg_log(PG_FATAL, "check for %s failed - cannot read file (permission denied)\n", pg_log(PG_FATAL, "check for \"%s\" failed: cannot read file (permission denied)\n",
path); path);
#ifndef WIN32 #ifndef WIN32
...@@ -239,6 +239,6 @@ validate_exec(const char *dir, const char *cmdName) ...@@ -239,6 +239,6 @@ validate_exec(const char *dir, const char *cmdName)
#else #else
if ((buf.st_mode & S_IXUSR) == 0) if ((buf.st_mode & S_IXUSR) == 0)
#endif #endif
pg_log(PG_FATAL, "check for %s failed - cannot execute (permission denied)\n", pg_log(PG_FATAL, "check for \"%s\" failed: cannot execute (permission denied)\n",
path); path);
} }
...@@ -69,12 +69,12 @@ copyAndUpdateFile(pageCnvCtx *pageConverter, ...@@ -69,12 +69,12 @@ copyAndUpdateFile(pageCnvCtx *pageConverter,
const char *msg = NULL; const char *msg = NULL;
if ((src_fd = open(src, O_RDONLY, 0)) < 0) if ((src_fd = open(src, O_RDONLY, 0)) < 0)
return "can't open source file"; return "could not open source file";
if ((dstfd = open(dst, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR)) < 0) if ((dstfd = open(dst, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR)) < 0)
{ {
close(src_fd); close(src_fd);
return "can't create destination file"; return "could not create destination file";
} }
while ((bytesRead = read(src_fd, buf, BLCKSZ)) == BLCKSZ) while ((bytesRead = read(src_fd, buf, BLCKSZ)) == BLCKSZ)
...@@ -85,7 +85,7 @@ copyAndUpdateFile(pageCnvCtx *pageConverter, ...@@ -85,7 +85,7 @@ copyAndUpdateFile(pageCnvCtx *pageConverter,
#endif #endif
if (write(dstfd, buf, BLCKSZ) != BLCKSZ) if (write(dstfd, buf, BLCKSZ) != BLCKSZ)
{ {
msg = "can't write new page to destination"; msg = "could not write new page to destination";
break; break;
} }
} }
...@@ -118,7 +118,7 @@ linkAndUpdateFile(pageCnvCtx *pageConverter, ...@@ -118,7 +118,7 @@ linkAndUpdateFile(pageCnvCtx *pageConverter,
const char *src, const char *dst) const char *src, const char *dst)
{ {
if (pageConverter != NULL) if (pageConverter != NULL)
return "Can't in-place update this cluster, page-by-page conversion is required"; return "Cannot in-place update this cluster, page-by-page conversion is required";
if (pg_link_file(src, dst) == -1) if (pg_link_file(src, dst) == -1)
return getErrorText(errno); return getErrorText(errno);
......
...@@ -237,9 +237,9 @@ check_loadable_libraries(void) ...@@ -237,9 +237,9 @@ check_loadable_libraries(void)
{ {
found = true; found = true;
if (script == NULL && (script = fopen(output_path, "w")) == NULL) if (script == NULL && (script = fopen(output_path, "w")) == NULL)
pg_log(PG_FATAL, "Could not create necessary file: %s\n", pg_log(PG_FATAL, "Could not open file \"%s\": %s\n",
output_path); output_path, getErrorText(errno));
fprintf(script, "Failed to load library: %s\n%s\n", fprintf(script, "Could not load library \"%s\"\n%s\n",
lib, lib,
PQerrorMessage(conn)); PQerrorMessage(conn));
} }
...@@ -255,12 +255,11 @@ check_loadable_libraries(void) ...@@ -255,12 +255,11 @@ check_loadable_libraries(void)
fclose(script); fclose(script);
pg_log(PG_REPORT, "fatal\n"); pg_log(PG_REPORT, "fatal\n");
pg_log(PG_FATAL, pg_log(PG_FATAL,
"| Your installation references loadable libraries that are missing\n" "Your installation references loadable libraries that are missing from the\n"
"| from the new installation. You can add these libraries to\n" "new installation. You can add these libraries to the new installation,\n"
"| the new installation, or remove the functions using them\n" "or remove the functions using them from the old installation. A list of\n"
"| from the old installation. A list of the problem libraries\n" "problem libraries is in the file:\n"
"| is in the file\n" " %s\n\n", output_path);
"| \"%s\".\n\n", output_path);
} }
else else
check_ok(); check_ok();
......
...@@ -51,7 +51,7 @@ gen_db_file_maps(DbInfo *old_db, DbInfo *new_db, ...@@ -51,7 +51,7 @@ gen_db_file_maps(DbInfo *old_db, DbInfo *new_db,
RelInfo *new_rel = &new_db->rel_arr.rels[relnum]; RelInfo *new_rel = &new_db->rel_arr.rels[relnum];
if (old_rel->reloid != new_rel->reloid) if (old_rel->reloid != new_rel->reloid)
pg_log(PG_FATAL, "Mismatch of relation id: database \"%s\", old relid %d, new relid %d\n", pg_log(PG_FATAL, "Mismatch of relation OID in database \"%s\": old OID %d, new OID %d\n",
old_db->db_name, old_rel->reloid, new_rel->reloid); old_db->db_name, old_rel->reloid, new_rel->reloid);
/* /*
...@@ -63,8 +63,8 @@ gen_db_file_maps(DbInfo *old_db, DbInfo *new_db, ...@@ -63,8 +63,8 @@ gen_db_file_maps(DbInfo *old_db, DbInfo *new_db,
((GET_MAJOR_VERSION(old_cluster.major_version) >= 804 || ((GET_MAJOR_VERSION(old_cluster.major_version) >= 804 ||
strcmp(old_rel->nspname, "pg_toast") != 0) && strcmp(old_rel->nspname, "pg_toast") != 0) &&
strcmp(old_rel->relname, new_rel->relname) != 0)) strcmp(old_rel->relname, new_rel->relname) != 0))
pg_log(PG_FATAL, "Mismatch of relation names: database \"%s\", " pg_log(PG_FATAL, "Mismatch of relation names in database \"%s\": "
"old rel %s.%s, new rel %s.%s\n", "old name \"%s.%s\", new name \"%s.%s\"\n",
old_db->db_name, old_rel->nspname, old_rel->relname, old_db->db_name, old_rel->nspname, old_rel->relname,
new_rel->nspname, new_rel->relname); new_rel->nspname, new_rel->relname);
...@@ -131,7 +131,7 @@ print_maps(FileNameMap *maps, int n_maps, const char *db_name) ...@@ -131,7 +131,7 @@ print_maps(FileNameMap *maps, int n_maps, const char *db_name)
{ {
int mapnum; int mapnum;
pg_log(PG_DEBUG, "mappings for db %s:\n", db_name); pg_log(PG_DEBUG, "mappings for database \"%s\":\n", db_name);
for (mapnum = 0; mapnum < n_maps; mapnum++) for (mapnum = 0; mapnum < n_maps; mapnum++)
pg_log(PG_DEBUG, "%s.%s: %u to %u\n", pg_log(PG_DEBUG, "%s.%s: %u to %u\n",
......
...@@ -294,8 +294,8 @@ check_required_directory(char **dirpath, char *envVarName, ...@@ -294,8 +294,8 @@ check_required_directory(char **dirpath, char *envVarName,
if ((envVar = getenv(envVarName)) && strlen(envVar)) if ((envVar = getenv(envVarName)) && strlen(envVar))
*dirpath = pg_strdup(envVar); *dirpath = pg_strdup(envVar);
else else
pg_log(PG_FATAL, "You must identify the directory where the %s\n" pg_log(PG_FATAL, "You must identify the directory where the %s.\n"
"Please use the %s command-line option or the %s environment variable\n", "Please use the %s command-line option or the %s environment variable.\n",
description, cmdLineOption, envVarName); description, cmdLineOption, envVarName);
} }
......
...@@ -74,7 +74,7 @@ setupPageConverter(pageCnvCtx **result) ...@@ -74,7 +74,7 @@ setupPageConverter(pageCnvCtx **result)
*/ */
if ((converter = loadConverterPlugin(newPageVersion, oldPageVersion)) == NULL) if ((converter = loadConverterPlugin(newPageVersion, oldPageVersion)) == NULL)
return "can't find plugin to convert from old page layout to new page layout"; return "could not find plugin to convert from old page layout to new page layout";
else else
{ {
*result = converter; *result = converter;
...@@ -100,12 +100,12 @@ getPageVersion(uint16 *version, const char *pathName) ...@@ -100,12 +100,12 @@ getPageVersion(uint16 *version, const char *pathName)
ssize_t bytesRead; ssize_t bytesRead;
if ((relfd = open(pathName, O_RDONLY, 0)) < 0) if ((relfd = open(pathName, O_RDONLY, 0)) < 0)
return "can't open relation"; return "could not open relation";
if ((bytesRead = read(relfd, &page, sizeof(page))) != sizeof(page)) if ((bytesRead = read(relfd, &page, sizeof(page))) != sizeof(page))
{ {
close(relfd); close(relfd);
return "can't read page header"; return "could not read page header";
} }
*version = PageGetPageLayoutVersion(&page); *version = PageGetPageLayoutVersion(&page);
......
...@@ -116,7 +116,7 @@ main(int argc, char **argv) ...@@ -116,7 +116,7 @@ main(int argc, char **argv)
* the old system, but we do it anyway just in case. We do it late here * the old system, but we do it anyway just in case. We do it late here
* because there is no need to have the schema load use new oids. * because there is no need to have the schema load use new oids.
*/ */
prep_status("Setting next oid for new cluster"); prep_status("Setting next OID for new cluster");
exec_prog(true, SYSTEMQUOTE "\"%s/pg_resetxlog\" -o %u \"%s\" > " exec_prog(true, SYSTEMQUOTE "\"%s/pg_resetxlog\" -o %u \"%s\" > "
DEVNULL SYSTEMQUOTE, DEVNULL SYSTEMQUOTE,
new_cluster.bindir, old_cluster.controldata.chkpnt_nxtoid, new_cluster.pgdata); new_cluster.bindir, old_cluster.controldata.chkpnt_nxtoid, new_cluster.pgdata);
...@@ -165,7 +165,7 @@ setup(char *argv0, bool live_check) ...@@ -165,7 +165,7 @@ setup(char *argv0, bool live_check)
/* get path to pg_upgrade executable */ /* get path to pg_upgrade executable */
if (find_my_exec(argv0, exec_path) < 0) if (find_my_exec(argv0, exec_path) < 0)
pg_log(PG_FATAL, "Could not get pathname to pg_upgrade: %s\n", getErrorText(errno)); pg_log(PG_FATAL, "Could not get path name to pg_upgrade: %s\n", getErrorText(errno));
/* Trim off program name and keep just path */ /* Trim off program name and keep just path */
*last_dir_separator(exec_path) = '\0'; *last_dir_separator(exec_path) = '\0';
...@@ -298,7 +298,7 @@ copy_clog_xlog_xid(void) ...@@ -298,7 +298,7 @@ copy_clog_xlog_xid(void)
snprintf(old_clog_path, sizeof(old_clog_path), "%s/pg_clog", old_cluster.pgdata); snprintf(old_clog_path, sizeof(old_clog_path), "%s/pg_clog", old_cluster.pgdata);
snprintf(new_clog_path, sizeof(new_clog_path), "%s/pg_clog", new_cluster.pgdata); snprintf(new_clog_path, sizeof(new_clog_path), "%s/pg_clog", new_cluster.pgdata);
if (!rmtree(new_clog_path, true)) if (!rmtree(new_clog_path, true))
pg_log(PG_FATAL, "unable to delete directory %s\n", new_clog_path); pg_log(PG_FATAL, "could not delete directory \"%s\"\n", new_clog_path);
check_ok(); check_ok();
prep_status("Copying old commit clogs to new server"); prep_status("Copying old commit clogs to new server");
...@@ -314,7 +314,7 @@ copy_clog_xlog_xid(void) ...@@ -314,7 +314,7 @@ copy_clog_xlog_xid(void)
check_ok(); check_ok();
/* set the next transaction id of the new cluster */ /* set the next transaction id of the new cluster */
prep_status("Setting next transaction id for new cluster"); prep_status("Setting next transaction ID for new cluster");
exec_prog(true, SYSTEMQUOTE "\"%s/pg_resetxlog\" -f -x %u \"%s\" > " DEVNULL SYSTEMQUOTE, exec_prog(true, SYSTEMQUOTE "\"%s/pg_resetxlog\" -f -x %u \"%s\" > " DEVNULL SYSTEMQUOTE,
new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid, new_cluster.pgdata); new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid, new_cluster.pgdata);
check_ok(); check_ok();
......
...@@ -232,24 +232,24 @@ transfer_relfile(pageCnvCtx *pageConverter, const char *old_file, ...@@ -232,24 +232,24 @@ transfer_relfile(pageCnvCtx *pageConverter, const char *old_file,
const char *msg; const char *msg;
if ((user_opts.transfer_mode == TRANSFER_MODE_LINK) && (pageConverter != NULL)) if ((user_opts.transfer_mode == TRANSFER_MODE_LINK) && (pageConverter != NULL))
pg_log(PG_FATAL, "this upgrade requires page-by-page conversion, " pg_log(PG_FATAL, "This upgrade requires page-by-page conversion, "
"you must use copy-mode instead of link-mode\n"); "you must use copy mode instead of link mode.\n");
if (user_opts.transfer_mode == TRANSFER_MODE_COPY) if (user_opts.transfer_mode == TRANSFER_MODE_COPY)
{ {
pg_log(PG_INFO, "copying %s to %s\n", old_file, new_file); pg_log(PG_INFO, "copying \"%s\" to \"%s\"\n", old_file, new_file);
if ((msg = copyAndUpdateFile(pageConverter, old_file, new_file, true)) != NULL) if ((msg = copyAndUpdateFile(pageConverter, old_file, new_file, true)) != NULL)
pg_log(PG_FATAL, "error while copying %s.%s (%s to %s): %s\n", pg_log(PG_FATAL, "error while copying relation \"%s.%s\" (\"%s\" to \"%s\"): %s\n",
nspname, relname, old_file, new_file, msg); nspname, relname, old_file, new_file, msg);
} }
else else
{ {
pg_log(PG_INFO, "linking %s to %s\n", old_file, new_file); pg_log(PG_INFO, "linking \"%s\" to \"%s\"\n", old_file, new_file);
if ((msg = linkAndUpdateFile(pageConverter, old_file, new_file)) != NULL) if ((msg = linkAndUpdateFile(pageConverter, old_file, new_file)) != NULL)
pg_log(PG_FATAL, pg_log(PG_FATAL,
"error while creating link from %s.%s (%s to %s): %s\n", "error while creating link for relation \"%s.%s\" (\"%s\" to \"%s\"): %s\n",
nspname, relname, old_file, new_file, msg); nspname, relname, old_file, new_file, msg);
} }
return; return;
......
...@@ -84,7 +84,7 @@ executeQueryOrDie(PGconn *conn, const char *fmt,...) ...@@ -84,7 +84,7 @@ executeQueryOrDie(PGconn *conn, const char *fmt,...)
if ((status != PGRES_TUPLES_OK) && (status != PGRES_COMMAND_OK)) if ((status != PGRES_TUPLES_OK) && (status != PGRES_COMMAND_OK))
{ {
pg_log(PG_REPORT, "DB command failed\n%s\n%s\n", command, pg_log(PG_REPORT, "SQL command failed\n%s\n%s\n", command,
PQerrorMessage(conn)); PQerrorMessage(conn));
PQclear(result); PQclear(result);
PQfinish(conn); PQfinish(conn);
...@@ -200,7 +200,7 @@ start_postmaster(ClusterInfo *cluster) ...@@ -200,7 +200,7 @@ start_postmaster(ClusterInfo *cluster)
PQerrorMessage(conn)); PQerrorMessage(conn));
if (conn) if (conn)
PQfinish(conn); PQfinish(conn);
pg_log(PG_FATAL, "unable to connect to %s postmaster started with the command: %s\n", pg_log(PG_FATAL, "could not connect to %s postmaster started with the command: %s\n",
CLUSTER_NAME(cluster), cmd); CLUSTER_NAME(cluster), cmd);
} }
PQfinish(conn); PQfinish(conn);
......
...@@ -49,7 +49,7 @@ new_9_0_populate_pg_largeobject_metadata(ClusterInfo *cluster, bool check_mode) ...@@ -49,7 +49,7 @@ new_9_0_populate_pg_largeobject_metadata(ClusterInfo *cluster, bool check_mode)
if (!check_mode) if (!check_mode)
{ {
if (script == NULL && (script = fopen(output_path, "w")) == NULL) if (script == NULL && (script = fopen(output_path, "w")) == NULL)
pg_log(PG_FATAL, "could not create necessary file: %s\n", output_path); pg_log(PG_FATAL, "could not open file \"%s\": %s\n", output_path, getErrorText(errno));
fprintf(script, "\\connect %s\n", fprintf(script, "\\connect %s\n",
quote_identifier(active_db->db_name)); quote_identifier(active_db->db_name));
fprintf(script, fprintf(script,
...@@ -70,20 +70,18 @@ new_9_0_populate_pg_largeobject_metadata(ClusterInfo *cluster, bool check_mode) ...@@ -70,20 +70,18 @@ new_9_0_populate_pg_largeobject_metadata(ClusterInfo *cluster, bool check_mode)
report_status(PG_WARNING, "warning"); report_status(PG_WARNING, "warning");
if (check_mode) if (check_mode)
pg_log(PG_WARNING, "\n" pg_log(PG_WARNING, "\n"
"| Your installation contains large objects.\n" "Your installation contains large objects. The new database has an\n"
"| The new database has an additional large object\n" "additional large object permission table. After upgrading, you will be\n"
"| permission table. After upgrading, you will be\n" "given a command to populate the pg_largeobject permission table with\n"
"| given a command to populate the pg_largeobject\n" "default permissions.\n\n");
"| permission table with default permissions.\n\n");
else else
pg_log(PG_WARNING, "\n" pg_log(PG_WARNING, "\n"
"| Your installation contains large objects.\n" "Your installation contains large objects. The new database has an\n"
"| The new database has an additional large object\n" "additional large object permission table, so default permissions must be\n"
"| permission table so default permissions must be\n" "defined for all large objects. The file\n"
"| defined for all large objects. The file:\n" " %s\n"
"| \t%s\n" "when executed by psql by the database superuser will set the default\n"
"| when executed by psql by the database super-user\n" "permissions.\n\n",
"| will define the default permissions.\n\n",
output_path); output_path);
} }
else else
......
...@@ -26,7 +26,7 @@ old_8_3_check_for_name_data_type_usage(ClusterInfo *cluster) ...@@ -26,7 +26,7 @@ old_8_3_check_for_name_data_type_usage(ClusterInfo *cluster)
bool found = false; bool found = false;
char output_path[MAXPGPATH]; char output_path[MAXPGPATH];
prep_status("Checking for invalid 'name' user columns"); prep_status("Checking for invalid \"name\" user columns");
snprintf(output_path, sizeof(output_path), "%s/tables_using_name.txt", snprintf(output_path, sizeof(output_path), "%s/tables_using_name.txt",
os_info.cwd); os_info.cwd);
...@@ -70,7 +70,7 @@ old_8_3_check_for_name_data_type_usage(ClusterInfo *cluster) ...@@ -70,7 +70,7 @@ old_8_3_check_for_name_data_type_usage(ClusterInfo *cluster)
{ {
found = true; found = true;
if (script == NULL && (script = fopen(output_path, "w")) == NULL) if (script == NULL && (script = fopen(output_path, "w")) == NULL)
pg_log(PG_FATAL, "could not create necessary file: %s\n", output_path); pg_log(PG_FATAL, "could not open file \"%s\": %s\n", output_path, getErrorText(errno));
if (!db_used) if (!db_used)
{ {
fprintf(script, "Database: %s\n", active_db->db_name); fprintf(script, "Database: %s\n", active_db->db_name);
...@@ -94,13 +94,12 @@ old_8_3_check_for_name_data_type_usage(ClusterInfo *cluster) ...@@ -94,13 +94,12 @@ old_8_3_check_for_name_data_type_usage(ClusterInfo *cluster)
{ {
pg_log(PG_REPORT, "fatal\n"); pg_log(PG_REPORT, "fatal\n");
pg_log(PG_FATAL, pg_log(PG_FATAL,
"| Your installation contains the \"name\" data type in\n" "Your installation contains the \"name\" data type in user tables. This\n"
"| user tables. This data type changed its internal\n" "data type changed its internal alignment between your old and new\n"
"| alignment between your old and new clusters so this\n" "clusters so this cluster cannot currently be upgraded. You can remove\n"
"| cluster cannot currently be upgraded. You can\n" "the problem tables and restart the upgrade. A list of the problem\n"
"| remove the problem tables and restart the upgrade.\n" "columns is in the file:\n"
"| A list of the problem columns is in the file:\n" " %s\n\n", output_path);
"| \t%s\n\n", output_path);
} }
else else
check_ok(); check_ok();
...@@ -160,7 +159,7 @@ old_8_3_check_for_tsquery_usage(ClusterInfo *cluster) ...@@ -160,7 +159,7 @@ old_8_3_check_for_tsquery_usage(ClusterInfo *cluster)
{ {
found = true; found = true;
if (script == NULL && (script = fopen(output_path, "w")) == NULL) if (script == NULL && (script = fopen(output_path, "w")) == NULL)
pg_log(PG_FATAL, "could not create necessary file: %s\n", output_path); pg_log(PG_FATAL, "could not open file \"%s\": %s\n", output_path, getErrorText(errno));
if (!db_used) if (!db_used)
{ {
fprintf(script, "Database: %s\n", active_db->db_name); fprintf(script, "Database: %s\n", active_db->db_name);
...@@ -184,13 +183,12 @@ old_8_3_check_for_tsquery_usage(ClusterInfo *cluster) ...@@ -184,13 +183,12 @@ old_8_3_check_for_tsquery_usage(ClusterInfo *cluster)
{ {
pg_log(PG_REPORT, "fatal\n"); pg_log(PG_REPORT, "fatal\n");
pg_log(PG_FATAL, pg_log(PG_FATAL,
"| Your installation contains the \"tsquery\" data type.\n" "Your installation contains the \"tsquery\" data type. This data type\n"
"| This data type added a new internal field between\n" "added a new internal field between your old and new clusters so this\n"
"| your old and new clusters so this cluster cannot\n" "cluster cannot currently be upgraded. You can remove the problem\n"
"| currently be upgraded. You can remove the problem\n" "columns and restart the upgrade. A list of the problem columns is in the\n"
"| columns and restart the upgrade. A list of the\n" "file:\n"
"| problem columns is in the file:\n" " %s\n\n", output_path);
"| \t%s\n\n", output_path);
} }
else else
check_ok(); check_ok();
...@@ -278,7 +276,7 @@ old_8_3_rebuild_tsvector_tables(ClusterInfo *cluster, bool check_mode) ...@@ -278,7 +276,7 @@ old_8_3_rebuild_tsvector_tables(ClusterInfo *cluster, bool check_mode)
if (!check_mode) if (!check_mode)
{ {
if (script == NULL && (script = fopen(output_path, "w")) == NULL) if (script == NULL && (script = fopen(output_path, "w")) == NULL)
pg_log(PG_FATAL, "could not create necessary file: %s\n", output_path); pg_log(PG_FATAL, "could not open file \"%s\": %s\n", output_path, getErrorText(errno));
if (!db_used) if (!db_used)
{ {
fprintf(script, "\\connect %s\n\n", fprintf(script, "\\connect %s\n\n",
...@@ -326,20 +324,17 @@ old_8_3_rebuild_tsvector_tables(ClusterInfo *cluster, bool check_mode) ...@@ -326,20 +324,17 @@ old_8_3_rebuild_tsvector_tables(ClusterInfo *cluster, bool check_mode)
report_status(PG_WARNING, "warning"); report_status(PG_WARNING, "warning");
if (check_mode) if (check_mode)
pg_log(PG_WARNING, "\n" pg_log(PG_WARNING, "\n"
"| Your installation contains tsvector columns.\n" "Your installation contains tsvector columns. The tsvector internal\n"
"| The tsvector internal storage format changed\n" "storage format changed between your old and new clusters so the tables\n"
"| between your old and new clusters so the tables\n" "must be rebuilt. After upgrading, you will be given instructions.\n\n");
"| must be rebuilt. After upgrading, you will be\n"
"| given instructions.\n\n");
else else
pg_log(PG_WARNING, "\n" pg_log(PG_WARNING, "\n"
"| Your installation contains tsvector columns.\n" "Your installation contains tsvector columns. The tsvector internal\n"
"| The tsvector internal storage format changed\n" "storage format changed between your old and new clusters so the tables\n"
"| between your old and new clusters so the tables\n" "must be rebuilt. The file:\n"
"| must be rebuilt. The file:\n" " %s\n"
"| \t%s\n" "when executed by psql by the database superuser will rebuild all tables\n"
"| when executed by psql by the database super-user\n" "with tsvector columns.\n\n",
"| will rebuild all tables with tsvector columns.\n\n",
output_path); output_path);
} }
else else
...@@ -360,7 +355,7 @@ old_8_3_invalidate_hash_gin_indexes(ClusterInfo *cluster, bool check_mode) ...@@ -360,7 +355,7 @@ old_8_3_invalidate_hash_gin_indexes(ClusterInfo *cluster, bool check_mode)
bool found = false; bool found = false;
char output_path[MAXPGPATH]; char output_path[MAXPGPATH];
prep_status("Checking for hash and gin indexes"); prep_status("Checking for hash and GIN indexes");
snprintf(output_path, sizeof(output_path), "%s/reindex_hash_and_gin.sql", snprintf(output_path, sizeof(output_path), "%s/reindex_hash_and_gin.sql",
os_info.cwd); os_info.cwd);
...@@ -398,7 +393,7 @@ old_8_3_invalidate_hash_gin_indexes(ClusterInfo *cluster, bool check_mode) ...@@ -398,7 +393,7 @@ old_8_3_invalidate_hash_gin_indexes(ClusterInfo *cluster, bool check_mode)
if (!check_mode) if (!check_mode)
{ {
if (script == NULL && (script = fopen(output_path, "w")) == NULL) if (script == NULL && (script = fopen(output_path, "w")) == NULL)
pg_log(PG_FATAL, "could not create necessary file: %s\n", output_path); pg_log(PG_FATAL, "could not open file \"%s\": %s\n", output_path, getErrorText(errno));
if (!db_used) if (!db_used)
{ {
fprintf(script, "\\connect %s\n", fprintf(script, "\\connect %s\n",
...@@ -437,23 +432,18 @@ old_8_3_invalidate_hash_gin_indexes(ClusterInfo *cluster, bool check_mode) ...@@ -437,23 +432,18 @@ old_8_3_invalidate_hash_gin_indexes(ClusterInfo *cluster, bool check_mode)
report_status(PG_WARNING, "warning"); report_status(PG_WARNING, "warning");
if (check_mode) if (check_mode)
pg_log(PG_WARNING, "\n" pg_log(PG_WARNING, "\n"
"| Your installation contains hash and/or gin\n" "Your installation contains hash and/or GIN indexes. These indexes have\n"
"| indexes. These indexes have different\n" "different internal formats between your old and new clusters, so they\n"
"| internal formats between your old and new\n" "must be reindexed with the REINDEX command. After upgrading, you will\n"
"| clusters so they must be reindexed with the\n" "be given REINDEX instructions.\n\n");
"| REINDEX command. After upgrading, you will\n"
"| be given REINDEX instructions.\n\n");
else else
pg_log(PG_WARNING, "\n" pg_log(PG_WARNING, "\n"
"| Your installation contains hash and/or gin\n" "Your installation contains hash and/or GIN indexes. These indexes have\n"
"| indexes. These indexes have different internal\n" "different internal formats between your old and new clusters, so they\n"
"| formats between your old and new clusters so\n" "must be reindexed with the REINDEX command. The file:\n"
"| they must be reindexed with the REINDEX command.\n" " %s\n"
"| The file:\n" "when executed by psql by the database superuser will recreate all invalid\n"
"| \t%s\n" "indexes; until then, none of these indexes will be used.\n\n",
"| when executed by psql by the database super-user\n"
"| will recreate all invalid indexes; until then,\n"
"| none of these indexes will be used.\n\n",
output_path); output_path);
} }
else else
...@@ -523,7 +513,7 @@ old_8_3_invalidate_bpchar_pattern_ops_indexes(ClusterInfo *cluster, ...@@ -523,7 +513,7 @@ old_8_3_invalidate_bpchar_pattern_ops_indexes(ClusterInfo *cluster,
if (!check_mode) if (!check_mode)
{ {
if (script == NULL && (script = fopen(output_path, "w")) == NULL) if (script == NULL && (script = fopen(output_path, "w")) == NULL)
pg_log(PG_FATAL, "could not create necessary file: %s\n", output_path); pg_log(PG_FATAL, "could not open file \"%s\": %s\n", output_path, getErrorText(errno));
if (!db_used) if (!db_used)
{ {
fprintf(script, "\\connect %s\n", fprintf(script, "\\connect %s\n",
...@@ -567,23 +557,18 @@ old_8_3_invalidate_bpchar_pattern_ops_indexes(ClusterInfo *cluster, ...@@ -567,23 +557,18 @@ old_8_3_invalidate_bpchar_pattern_ops_indexes(ClusterInfo *cluster,
report_status(PG_WARNING, "warning"); report_status(PG_WARNING, "warning");
if (check_mode) if (check_mode)
pg_log(PG_WARNING, "\n" pg_log(PG_WARNING, "\n"
"| Your installation contains indexes using\n" "Your installation contains indexes using \"bpchar_pattern_ops\". These\n"
"| \"bpchar_pattern_ops\". These indexes have\n" "indexes have different internal formats between your old and new clusters\n"
"| different internal formats between your old and\n" "so they must be reindexed with the REINDEX command. After upgrading, you\n"
"| new clusters so they must be reindexed with the\n" "will be given REINDEX instructions.\n\n");
"| REINDEX command. After upgrading, you will be\n"
"| given REINDEX instructions.\n\n");
else else
pg_log(PG_WARNING, "\n" pg_log(PG_WARNING, "\n"
"| Your installation contains indexes using\n" "Your installation contains indexes using \"bpchar_pattern_ops\". These\n"
"| \"bpchar_pattern_ops\". These indexes have\n" "indexes have different internal formats between your old and new clusters\n"
"| different internal formats between your old and\n" "so they must be reindexed with the REINDEX command. The file:\n"
"| new clusters so they must be reindexed with the\n" " %s\n"
"| REINDEX command. The file:\n" "when executed by psql by the database superuser will recreate all invalid\n"
"| \t%s\n" "indexes; until then, none of these indexes will be used.\n\n",
"| when executed by psql by the database super-user\n"
"| will recreate all invalid indexes; until then,\n"
"| none of these indexes will be used.\n\n",
output_path); output_path);
} }
else else
...@@ -648,7 +633,7 @@ old_8_3_create_sequence_script(ClusterInfo *cluster) ...@@ -648,7 +633,7 @@ old_8_3_create_sequence_script(ClusterInfo *cluster)
found = true; found = true;
if (script == NULL && (script = fopen(output_path, "w")) == NULL) if (script == NULL && (script = fopen(output_path, "w")) == NULL)
pg_log(PG_FATAL, "could not create necessary file: %s\n", output_path); pg_log(PG_FATAL, "could not open file \"%s\": %s\n", output_path, getErrorText(errno));
if (!db_used) if (!db_used)
{ {
fprintf(script, "\\connect %s\n\n", fprintf(script, "\\connect %s\n\n",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment