diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2011-07-12 07:13:51 +0300 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2011-07-12 07:13:51 +0300 |
commit | 912bc4f038b3daaea4477c4b4e79fbd8c15e67a0 (patch) | |
tree | 3abbc8e1ae427b65afc1566f63b31d88c41826d2 /contrib/pg_upgrade | |
parent | afc9635c600ace716294a12d78abd37f65abd0ea (diff) | |
download | postgresql-912bc4f038b3daaea4477c4b4e79fbd8c15e67a0.tar.gz |
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.
Diffstat (limited to 'contrib/pg_upgrade')
-rw-r--r-- | contrib/pg_upgrade/check.c | 77 | ||||
-rw-r--r-- | contrib/pg_upgrade/controldata.c | 8 | ||||
-rw-r--r-- | contrib/pg_upgrade/dump.c | 6 | ||||
-rw-r--r-- | contrib/pg_upgrade/exec.c | 18 | ||||
-rw-r--r-- | contrib/pg_upgrade/file.c | 10 | ||||
-rw-r--r-- | contrib/pg_upgrade/function.c | 17 | ||||
-rw-r--r-- | contrib/pg_upgrade/info.c | 8 | ||||
-rw-r--r-- | contrib/pg_upgrade/option.c | 4 | ||||
-rw-r--r-- | contrib/pg_upgrade/page.c | 6 | ||||
-rw-r--r-- | contrib/pg_upgrade/pg_upgrade.c | 8 | ||||
-rw-r--r-- | contrib/pg_upgrade/relfilenode.c | 16 | ||||
-rw-r--r-- | contrib/pg_upgrade/server.c | 4 | ||||
-rw-r--r-- | contrib/pg_upgrade/version.c | 24 | ||||
-rw-r--r-- | contrib/pg_upgrade/version_old_8_3.c | 125 |
14 files changed, 155 insertions, 176 deletions
diff --git a/contrib/pg_upgrade/check.c b/contrib/pg_upgrade/check.c index 5c5ce72294..fa4ef8dcc7 100644 --- a/contrib/pg_upgrade/check.c +++ b/contrib/pg_upgrade/check.c @@ -147,10 +147,9 @@ report_clusters_compatible(void) } pg_log(PG_REPORT, "\n" - "| If pg_upgrade fails after this point, you must\n" - "| re-initdb the new cluster before continuing.\n" - "| You will also need to remove the \".old\" suffix\n" - "| from %s/global/pg_control.old.\n", old_cluster.pgdata); + "If pg_upgrade fails after this point, you must re-initdb the new cluster\n" + "before continuing. You will also need to remove the \".old\" suffix from\n" + "%s/global/pg_control.old.\n", old_cluster.pgdata); } @@ -198,21 +197,20 @@ output_completion_banner(char *deletion_script_file_name) /* Did we copy the free space files? */ if (GET_MAJOR_VERSION(old_cluster.major_version) >= 804) pg_log(PG_REPORT, - "| Optimizer statistics are not transferred by pg_upgrade\n" - "| so consider running:\n" - "| \tvacuumdb --all --analyze-only\n" - "| on the newly-upgraded cluster.\n\n"); + "Optimizer statistics are not transferred by pg_upgrade so consider\n" + "running:\n" + " vacuumdb --all --analyze-only\n" + "on the newly-upgraded cluster.\n\n"); else pg_log(PG_REPORT, - "| Optimizer statistics and free space information\n" - "| are not transferred by pg_upgrade so consider\n" - "| running:\n" - "| \tvacuumdb --all --analyze\n" - "| on the newly-upgraded cluster.\n\n"); + "Optimizer statistics and free space information are not transferred\n" + "by pg_upgrade so consider running:\n" + " vacuumdb --all --analyze\n" + "on the newly-upgraded cluster.\n\n"); pg_log(PG_REPORT, - "| Running this script will delete the old cluster's data files:\n" - "| \t%s\n", + "Running this script will delete the old cluster's data files:\n" + " %s\n", deletion_script_file_name); } @@ -427,8 +425,8 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name) os_info.cwd, SCRIPT_EXT); if ((script = fopen(*deletion_script_file_name, "w")) == NULL) - pg_log(PG_FATAL, "Could not create necessary file: %s\n", - *deletion_script_file_name); + pg_log(PG_FATAL, "Could not open file \"%s\": %s\n", + *deletion_script_file_name, getErrorText(errno)); #ifndef WIN32 /* add shebang header */ @@ -477,8 +475,8 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name) #ifndef WIN32 if (chmod(*deletion_script_file_name, S_IRWXU) != 0) - pg_log(PG_FATAL, "Could not add execute permission to file: %s\n", - *deletion_script_file_name); + pg_log(PG_FATAL, "Could not add execute permission to file \"%s\": %s\n", + *deletion_script_file_name, getErrorText(errno)); #endif check_ok(); @@ -600,10 +598,11 @@ check_for_isn_and_int8_passing_mismatch(ClusterInfo *cluster) { found = true; 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) { - fprintf(script, "Database: %s\n", active_db->db_name); + fprintf(script, "Database: %s\n", active_db->db_name); db_used = true; } fprintf(script, " %s.%s\n", @@ -623,15 +622,13 @@ check_for_isn_and_int8_passing_mismatch(ClusterInfo *cluster) { pg_log(PG_REPORT, "fatal\n"); pg_log(PG_FATAL, - "| Your installation contains \"contrib/isn\" functions\n" - "| which rely on the bigint data type. Your old and\n" - "| new clusters pass bigint values differently so this\n" - "| cluster cannot currently be upgraded. You can\n" - "| manually upgrade data that use \"contrib/isn\"\n" - "| facilities and remove \"contrib/isn\" from the\n" - "| old cluster and restart the upgrade. A list\n" - "| of the problem functions is in the file:\n" - "| \t%s\n\n", output_path); + "Your installation contains \"contrib/isn\" functions which rely on the\n" + "bigint data type. Your old and new clusters pass bigint values\n" + "differently so this cluster cannot currently be upgraded. You can\n" + "manually upgrade databases that use \"contrib/isn\" facilities and remove\n" + "\"contrib/isn\" from the old cluster and restart the upgrade. A list of\n" + "the problem functions is in the file:\n" + " %s\n\n", output_path); } else check_ok(); @@ -657,7 +654,7 @@ check_for_reg_data_type_usage(ClusterInfo *cluster) bool found = false; 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", os_info.cwd); @@ -702,10 +699,11 @@ check_for_reg_data_type_usage(ClusterInfo *cluster) { found = true; 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) { - fprintf(script, "Database: %s\n", active_db->db_name); + fprintf(script, "Database: %s\n", active_db->db_name); db_used = true; } fprintf(script, " %s.%s.%s\n", @@ -726,13 +724,12 @@ check_for_reg_data_type_usage(ClusterInfo *cluster) { pg_log(PG_REPORT, "fatal\n"); pg_log(PG_FATAL, - "| Your installation contains one of the reg* data types in\n" - "| user tables. These data types reference system oids that\n" - "| are not preserved by pg_upgrade, so this cluster cannot\n" - "| currently be upgraded. You can remove the problem tables\n" - "| and restart the upgrade. A list of the problem columns\n" - "| is in the file:\n" - "| \t%s\n\n", output_path); + "Your installation contains one of the reg* data types in user tables.\n" + "These data types reference system OIDs that are not preserved by\n" + "pg_upgrade, so this cluster cannot currently be upgraded. You can\n" + "remove the problem tables and restart the upgrade. A list of the problem\n" + "columns is in the file:\n" + " %s\n\n", output_path); } else check_ok(); diff --git a/contrib/pg_upgrade/controldata.c b/contrib/pg_upgrade/controldata.c index 8e0db7750f..1c64f39aa3 100644 --- a/contrib/pg_upgrade/controldata.c +++ b/contrib/pg_upgrade/controldata.c @@ -451,7 +451,7 @@ get_control_data(ClusterInfo *cluster, bool live_check) pg_log(PG_REPORT, " float8 argument passing method\n"); 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, * 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\n" - "--disable-integer-datetimes or get server binaries built\n" - "with those options.\n"); + "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"); } } diff --git a/contrib/pg_upgrade/dump.c b/contrib/pg_upgrade/dump.c index aba95f44c9..a07ab12d8f 100644 --- a/contrib/pg_upgrade/dump.c +++ b/contrib/pg_upgrade/dump.c @@ -56,13 +56,13 @@ split_old_dump(void) snprintf(filename, sizeof(filename), "%s/%s", os_info.cwd, ALL_DUMP_FILE); 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); 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); 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; /* patterns used to prevent our own username from being recreated */ diff --git a/contrib/pg_upgrade/exec.c b/contrib/pg_upgrade/exec.c index b7d82663ff..a76c06e302 100644 --- a/contrib/pg_upgrade/exec.c +++ b/contrib/pg_upgrade/exec.c @@ -46,7 +46,7 @@ exec_prog(bool throw_error, const char *fmt,...) if (result != 0) { pg_log(throw_error ? PG_FATAL : PG_INFO, - "There were problems executing %s\n", cmd); + "There were problems executing \"%s\"\n", cmd); return 1; } @@ -72,8 +72,8 @@ is_server_running(const char *datadir) { /* ENOTDIR means we will throw a more useful error later */ if (errno != ENOENT && errno != ENOTDIR) - pg_log(PG_FATAL, "could not open file \"%s\" for reading\n", - path); + pg_log(PG_FATAL, "could not open file \"%s\" for reading: %s\n", + path, getErrorText(errno)); return false; } @@ -149,7 +149,7 @@ check_data_dir(const char *pg_data) requiredSubdirs[subdirnum]); 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)); else if (!S_ISDIR(statBuf.st_mode)) report_status(PG_FATAL, "%s is not a directory\n", @@ -173,7 +173,7 @@ check_bin_dir(ClusterInfo *cluster) /* check bindir */ 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)); else if (!S_ISDIR(statBuf.st_mode)) report_status(PG_FATAL, "%s is not a directory\n", @@ -216,10 +216,10 @@ validate_exec(const char *dir, const char *cmdName) * Ensure that the file exists and is a regular file. */ 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)); 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); /* @@ -231,7 +231,7 @@ validate_exec(const char *dir, const char *cmdName) #else if ((buf.st_mode & S_IRUSR) == 0) #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); #ifndef WIN32 @@ -239,6 +239,6 @@ validate_exec(const char *dir, const char *cmdName) #else if ((buf.st_mode & S_IXUSR) == 0) #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); } diff --git a/contrib/pg_upgrade/file.c b/contrib/pg_upgrade/file.c index 02c81a7fc4..fe89785767 100644 --- a/contrib/pg_upgrade/file.c +++ b/contrib/pg_upgrade/file.c @@ -69,12 +69,12 @@ copyAndUpdateFile(pageCnvCtx *pageConverter, const char *msg = NULL; 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) { close(src_fd); - return "can't create destination file"; + return "could not create destination file"; } while ((bytesRead = read(src_fd, buf, BLCKSZ)) == BLCKSZ) @@ -85,7 +85,7 @@ copyAndUpdateFile(pageCnvCtx *pageConverter, #endif if (write(dstfd, buf, BLCKSZ) != BLCKSZ) { - msg = "can't write new page to destination"; + msg = "could not write new page to destination"; break; } } @@ -118,7 +118,7 @@ linkAndUpdateFile(pageCnvCtx *pageConverter, const char *src, const char *dst) { 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) return getErrorText(errno); @@ -360,7 +360,7 @@ check_hard_link(void) if (pg_link_file(existing_file, new_link_file) == -1) { pg_log(PG_FATAL, - "Could not create hard link between old and new data directories: %s\n" + "Could not create hard link between old and new data directories: %s\n" "In link mode the old and new data directories must be on the same file system volume.\n", getErrorText(errno)); } diff --git a/contrib/pg_upgrade/function.c b/contrib/pg_upgrade/function.c index 322014cd23..53d562f3bd 100644 --- a/contrib/pg_upgrade/function.c +++ b/contrib/pg_upgrade/function.c @@ -237,9 +237,9 @@ check_loadable_libraries(void) { found = true; if (script == NULL && (script = fopen(output_path, "w")) == NULL) - pg_log(PG_FATAL, "Could not create necessary file: %s\n", - output_path); - fprintf(script, "Failed to load library: %s\n%s\n", + pg_log(PG_FATAL, "Could not open file \"%s\": %s\n", + output_path, getErrorText(errno)); + fprintf(script, "Could not load library \"%s\"\n%s\n", lib, PQerrorMessage(conn)); } @@ -255,12 +255,11 @@ check_loadable_libraries(void) fclose(script); pg_log(PG_REPORT, "fatal\n"); pg_log(PG_FATAL, - "| Your installation references loadable libraries that are missing\n" - "| from the new installation. You can add these libraries to\n" - "| the new installation, or remove the functions using them\n" - "| from the old installation. A list of the problem libraries\n" - "| is in the file\n" - "| \"%s\".\n\n", output_path); + "Your installation references loadable libraries that are missing from the\n" + "new installation. You can add these libraries to the new installation,\n" + "or remove the functions using them from the old installation. A list of\n" + "problem libraries is in the file:\n" + " %s\n\n", output_path); } else check_ok(); diff --git a/contrib/pg_upgrade/info.c b/contrib/pg_upgrade/info.c index f0cd8e5ede..72bc489d0e 100644 --- a/contrib/pg_upgrade/info.c +++ b/contrib/pg_upgrade/info.c @@ -51,7 +51,7 @@ gen_db_file_maps(DbInfo *old_db, DbInfo *new_db, RelInfo *new_rel = &new_db->rel_arr.rels[relnum]; 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); /* @@ -63,8 +63,8 @@ gen_db_file_maps(DbInfo *old_db, DbInfo *new_db, ((GET_MAJOR_VERSION(old_cluster.major_version) >= 804 || strcmp(old_rel->nspname, "pg_toast") != 0) && strcmp(old_rel->relname, new_rel->relname) != 0)) - pg_log(PG_FATAL, "Mismatch of relation names: database \"%s\", " - "old rel %s.%s, new rel %s.%s\n", + pg_log(PG_FATAL, "Mismatch of relation names in database \"%s\": " + "old name \"%s.%s\", new name \"%s.%s\"\n", old_db->db_name, old_rel->nspname, old_rel->relname, new_rel->nspname, new_rel->relname); @@ -131,7 +131,7 @@ print_maps(FileNameMap *maps, int n_maps, const char *db_name) { 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++) pg_log(PG_DEBUG, "%s.%s: %u to %u\n", diff --git a/contrib/pg_upgrade/option.c b/contrib/pg_upgrade/option.c index d29aad0e1d..1793bb320e 100644 --- a/contrib/pg_upgrade/option.c +++ b/contrib/pg_upgrade/option.c @@ -294,8 +294,8 @@ check_required_directory(char **dirpath, char *envVarName, if ((envVar = getenv(envVarName)) && strlen(envVar)) *dirpath = pg_strdup(envVar); else - 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", + 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", description, cmdLineOption, envVarName); } diff --git a/contrib/pg_upgrade/page.c b/contrib/pg_upgrade/page.c index 22a587f4b1..d9e9f694d8 100644 --- a/contrib/pg_upgrade/page.c +++ b/contrib/pg_upgrade/page.c @@ -74,7 +74,7 @@ setupPageConverter(pageCnvCtx **result) */ 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 { *result = converter; @@ -100,12 +100,12 @@ getPageVersion(uint16 *version, const char *pathName) ssize_t bytesRead; 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)) { close(relfd); - return "can't read page header"; + return "could not read page header"; } *version = PageGetPageLayoutVersion(&page); diff --git a/contrib/pg_upgrade/pg_upgrade.c b/contrib/pg_upgrade/pg_upgrade.c index e329dc3efe..efa5c0f177 100644 --- a/contrib/pg_upgrade/pg_upgrade.c +++ b/contrib/pg_upgrade/pg_upgrade.c @@ -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 * 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\" > " DEVNULL SYSTEMQUOTE, new_cluster.bindir, old_cluster.controldata.chkpnt_nxtoid, new_cluster.pgdata); @@ -165,7 +165,7 @@ setup(char *argv0, bool live_check) /* get path to pg_upgrade executable */ 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 */ *last_dir_separator(exec_path) = '\0'; @@ -298,7 +298,7 @@ copy_clog_xlog_xid(void) 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); 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(); prep_status("Copying old commit clogs to new server"); @@ -314,7 +314,7 @@ copy_clog_xlog_xid(void) check_ok(); /* 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, new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid, new_cluster.pgdata); check_ok(); diff --git a/contrib/pg_upgrade/relfilenode.c b/contrib/pg_upgrade/relfilenode.c index 9a0a3ac18d..d4a420fe2c 100644 --- a/contrib/pg_upgrade/relfilenode.c +++ b/contrib/pg_upgrade/relfilenode.c @@ -91,9 +91,9 @@ get_pg_database_relfilenode(ClusterInfo *cluster) res = executeQueryOrDie(conn, "SELECT c.relname, c.relfilenode " - "FROM pg_catalog.pg_class c, " + "FROM pg_catalog.pg_class c, " " pg_catalog.pg_namespace n " - "WHERE c.relnamespace = n.oid AND " + "WHERE c.relnamespace = n.oid AND " " n.nspname = 'pg_catalog' AND " " c.relname = 'pg_database' " "ORDER BY c.relname"); @@ -232,24 +232,24 @@ transfer_relfile(pageCnvCtx *pageConverter, const char *old_file, const char *msg; if ((user_opts.transfer_mode == TRANSFER_MODE_LINK) && (pageConverter != NULL)) - pg_log(PG_FATAL, "this upgrade requires page-by-page conversion, " - "you must use copy-mode instead of link-mode\n"); + pg_log(PG_FATAL, "This upgrade requires page-by-page conversion, " + "you must use copy mode instead of link mode.\n"); 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) - 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); } 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) 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); } return; diff --git a/contrib/pg_upgrade/server.c b/contrib/pg_upgrade/server.c index 58c1234a94..59eaad9dcf 100644 --- a/contrib/pg_upgrade/server.c +++ b/contrib/pg_upgrade/server.c @@ -84,7 +84,7 @@ executeQueryOrDie(PGconn *conn, const char *fmt,...) 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)); PQclear(result); PQfinish(conn); @@ -200,7 +200,7 @@ start_postmaster(ClusterInfo *cluster) PQerrorMessage(conn)); if (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); } PQfinish(conn); diff --git a/contrib/pg_upgrade/version.c b/contrib/pg_upgrade/version.c index 958bcbb80f..46190b1154 100644 --- a/contrib/pg_upgrade/version.c +++ b/contrib/pg_upgrade/version.c @@ -49,7 +49,7 @@ new_9_0_populate_pg_largeobject_metadata(ClusterInfo *cluster, bool check_mode) if (!check_mode) { 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", quote_identifier(active_db->db_name)); fprintf(script, @@ -70,20 +70,18 @@ new_9_0_populate_pg_largeobject_metadata(ClusterInfo *cluster, bool check_mode) report_status(PG_WARNING, "warning"); if (check_mode) pg_log(PG_WARNING, "\n" - "| Your installation contains large objects.\n" - "| The new database has an additional large object\n" - "| permission table. After upgrading, you will be\n" - "| given a command to populate the pg_largeobject\n" - "| permission table with default permissions.\n\n"); + "Your installation contains large objects. The new database has an\n" + "additional large object permission table. After upgrading, you will be\n" + "given a command to populate the pg_largeobject permission table with\n" + "default permissions.\n\n"); else pg_log(PG_WARNING, "\n" - "| Your installation contains large objects.\n" - "| The new database has an additional large object\n" - "| permission table so default permissions must be\n" - "| defined for all large objects. The file:\n" - "| \t%s\n" - "| when executed by psql by the database super-user\n" - "| will define the default permissions.\n\n", + "Your installation contains large objects. The new database has an\n" + "additional large object permission table, so default permissions must be\n" + "defined for all large objects. The file\n" + " %s\n" + "when executed by psql by the database superuser will set the default\n" + "permissions.\n\n", output_path); } else diff --git a/contrib/pg_upgrade/version_old_8_3.c b/contrib/pg_upgrade/version_old_8_3.c index 1a31f8d683..43bfdc1dba 100644 --- a/contrib/pg_upgrade/version_old_8_3.c +++ b/contrib/pg_upgrade/version_old_8_3.c @@ -26,7 +26,7 @@ old_8_3_check_for_name_data_type_usage(ClusterInfo *cluster) bool found = false; 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", os_info.cwd); @@ -70,10 +70,10 @@ old_8_3_check_for_name_data_type_usage(ClusterInfo *cluster) { found = true; 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) { - fprintf(script, "Database: %s\n", active_db->db_name); + fprintf(script, "Database: %s\n", active_db->db_name); db_used = true; } fprintf(script, " %s.%s.%s\n", @@ -94,13 +94,12 @@ old_8_3_check_for_name_data_type_usage(ClusterInfo *cluster) { pg_log(PG_REPORT, "fatal\n"); pg_log(PG_FATAL, - "| Your installation contains the \"name\" data type in\n" - "| user tables. This data type changed its internal\n" - "| alignment between your old and new clusters so this\n" - "| cluster cannot currently be upgraded. You can\n" - "| remove the problem tables and restart the upgrade.\n" - "| A list of the problem columns is in the file:\n" - "| \t%s\n\n", output_path); + "Your installation contains the \"name\" data type in user tables. This\n" + "data type changed its internal alignment between your old and new\n" + "clusters so this cluster cannot currently be upgraded. You can remove\n" + "the problem tables and restart the upgrade. A list of the problem\n" + "columns is in the file:\n" + " %s\n\n", output_path); } else check_ok(); @@ -160,10 +159,10 @@ old_8_3_check_for_tsquery_usage(ClusterInfo *cluster) { found = true; 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) { - fprintf(script, "Database: %s\n", active_db->db_name); + fprintf(script, "Database: %s\n", active_db->db_name); db_used = true; } fprintf(script, " %s.%s.%s\n", @@ -184,13 +183,12 @@ old_8_3_check_for_tsquery_usage(ClusterInfo *cluster) { pg_log(PG_REPORT, "fatal\n"); pg_log(PG_FATAL, - "| Your installation contains the \"tsquery\" data type.\n" - "| This data type added a new internal field between\n" - "| your old and new clusters so this cluster cannot\n" - "| currently be upgraded. You can remove the problem\n" - "| columns and restart the upgrade. A list of the\n" - "| problem columns is in the file:\n" - "| \t%s\n\n", output_path); + "Your installation contains the \"tsquery\" data type. This data type\n" + "added a new internal field between your old and new clusters so this\n" + "cluster cannot currently be upgraded. You can remove the problem\n" + "columns and restart the upgrade. A list of the problem columns is in the\n" + "file:\n" + " %s\n\n", output_path); } else check_ok(); @@ -278,7 +276,7 @@ old_8_3_rebuild_tsvector_tables(ClusterInfo *cluster, bool check_mode) if (!check_mode) { 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) { fprintf(script, "\\connect %s\n\n", @@ -326,20 +324,17 @@ old_8_3_rebuild_tsvector_tables(ClusterInfo *cluster, bool check_mode) report_status(PG_WARNING, "warning"); if (check_mode) pg_log(PG_WARNING, "\n" - "| Your installation contains tsvector columns.\n" - "| The tsvector internal storage format changed\n" - "| between your old and new clusters so the tables\n" - "| must be rebuilt. After upgrading, you will be\n" - "| given instructions.\n\n"); + "Your installation contains tsvector columns. The tsvector internal\n" + "storage format changed between your old and new clusters so the tables\n" + "must be rebuilt. After upgrading, you will be given instructions.\n\n"); else pg_log(PG_WARNING, "\n" - "| Your installation contains tsvector columns.\n" - "| The tsvector internal storage format changed\n" - "| between your old and new clusters so the tables\n" - "| must be rebuilt. The file:\n" - "| \t%s\n" - "| when executed by psql by the database super-user\n" - "| will rebuild all tables with tsvector columns.\n\n", + "Your installation contains tsvector columns. The tsvector internal\n" + "storage format changed between your old and new clusters so the tables\n" + "must be rebuilt. The file:\n" + " %s\n" + "when executed by psql by the database superuser will rebuild all tables\n" + "with tsvector columns.\n\n", output_path); } else @@ -360,7 +355,7 @@ old_8_3_invalidate_hash_gin_indexes(ClusterInfo *cluster, bool check_mode) bool found = false; 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", os_info.cwd); @@ -379,11 +374,11 @@ old_8_3_invalidate_hash_gin_indexes(ClusterInfo *cluster, bool check_mode) /* find hash and gin indexes */ res = executeQueryOrDie(conn, "SELECT n.nspname, c.relname " - "FROM pg_catalog.pg_class c, " + "FROM pg_catalog.pg_class c, " " pg_catalog.pg_index i, " " pg_catalog.pg_am a, " " pg_catalog.pg_namespace n " - "WHERE i.indexrelid = c.oid AND " + "WHERE i.indexrelid = c.oid AND " " c.relam = a.oid AND " " c.relnamespace = n.oid AND " " a.amname IN ('hash', 'gin') AND " @@ -398,7 +393,7 @@ old_8_3_invalidate_hash_gin_indexes(ClusterInfo *cluster, bool check_mode) if (!check_mode) { 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) { fprintf(script, "\\connect %s\n", @@ -418,10 +413,10 @@ old_8_3_invalidate_hash_gin_indexes(ClusterInfo *cluster, bool check_mode) PQclear(executeQueryOrDie(conn, "UPDATE pg_catalog.pg_index i " "SET indisvalid = false " - "FROM pg_catalog.pg_class c, " + "FROM pg_catalog.pg_class c, " " pg_catalog.pg_am a, " " pg_catalog.pg_namespace n " - "WHERE i.indexrelid = c.oid AND " + "WHERE i.indexrelid = c.oid AND " " c.relam = a.oid AND " " c.relnamespace = n.oid AND " " a.amname IN ('hash', 'gin')")); @@ -437,23 +432,18 @@ old_8_3_invalidate_hash_gin_indexes(ClusterInfo *cluster, bool check_mode) report_status(PG_WARNING, "warning"); if (check_mode) pg_log(PG_WARNING, "\n" - "| Your installation contains hash and/or gin\n" - "| indexes. These indexes have different\n" - "| internal formats between your old and new\n" - "| clusters so they must be reindexed with the\n" - "| REINDEX command. After upgrading, you will\n" - "| be given REINDEX instructions.\n\n"); + "Your installation contains hash and/or GIN indexes. These indexes have\n" + "different internal formats between your old and new clusters, so they\n" + "must be reindexed with the REINDEX command. After upgrading, you will\n" + "be given REINDEX instructions.\n\n"); else pg_log(PG_WARNING, "\n" - "| Your installation contains hash and/or gin\n" - "| indexes. These indexes have different internal\n" - "| formats between your old and new clusters so\n" - "| they must be reindexed with the REINDEX command.\n" - "| The file:\n" - "| \t%s\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", + "Your installation contains hash and/or GIN indexes. These indexes have\n" + "different internal formats between your old and new clusters, so they\n" + "must be reindexed with the REINDEX command. The file:\n" + " %s\n" + "when executed by psql by the database superuser will recreate all invalid\n" + "indexes; until then, none of these indexes will be used.\n\n", output_path); } else @@ -523,7 +513,7 @@ old_8_3_invalidate_bpchar_pattern_ops_indexes(ClusterInfo *cluster, if (!check_mode) { 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) { fprintf(script, "\\connect %s\n", @@ -567,23 +557,18 @@ old_8_3_invalidate_bpchar_pattern_ops_indexes(ClusterInfo *cluster, report_status(PG_WARNING, "warning"); if (check_mode) pg_log(PG_WARNING, "\n" - "| Your installation contains indexes using\n" - "| \"bpchar_pattern_ops\". These indexes have\n" - "| different internal formats between your old and\n" - "| new clusters so they must be reindexed with the\n" - "| REINDEX command. After upgrading, you will be\n" - "| given REINDEX instructions.\n\n"); + "Your installation contains indexes using \"bpchar_pattern_ops\". These\n" + "indexes have different internal formats between your old and new clusters\n" + "so they must be reindexed with the REINDEX command. After upgrading, you\n" + "will be given REINDEX instructions.\n\n"); else pg_log(PG_WARNING, "\n" - "| Your installation contains indexes using\n" - "| \"bpchar_pattern_ops\". These indexes have\n" - "| different internal formats between your old and\n" - "| new clusters so they must be reindexed with the\n" - "| REINDEX command. The file:\n" - "| \t%s\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", + "Your installation contains indexes using \"bpchar_pattern_ops\". These\n" + "indexes have different internal formats between your old and new clusters\n" + "so they must be reindexed with the REINDEX command. The file:\n" + " %s\n" + "when executed by psql by the database superuser will recreate all invalid\n" + "indexes; until then, none of these indexes will be used.\n\n", output_path); } else @@ -648,7 +633,7 @@ old_8_3_create_sequence_script(ClusterInfo *cluster) found = true; 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) { fprintf(script, "\\connect %s\n\n", |