mirror of
https://github.com/postgres/postgres.git
synced 2025-12-24 06:01:07 +03:00
pg_upgrade: fix CopyFile() on Windows to fail on file existence
Also fix getErrorText() to return the right error string on failure. This behavior now matches that of other operating systems. Report by Noah Misch Backpatch through 9.1
This commit is contained in:
@@ -529,7 +529,7 @@ create_script_for_cluster_analyze(char **analyze_script_file_name)
|
||||
|
||||
if ((script = fopen_priv(*analyze_script_file_name, "w")) == NULL)
|
||||
pg_fatal("Could not open file \"%s\": %s\n",
|
||||
*analyze_script_file_name, getErrorText(errno));
|
||||
*analyze_script_file_name, getErrorText());
|
||||
|
||||
#ifndef WIN32
|
||||
/* add shebang header */
|
||||
@@ -584,7 +584,7 @@ create_script_for_cluster_analyze(char **analyze_script_file_name)
|
||||
#ifndef WIN32
|
||||
if (chmod(*analyze_script_file_name, S_IRWXU) != 0)
|
||||
pg_fatal("Could not add execute permission to file \"%s\": %s\n",
|
||||
*analyze_script_file_name, getErrorText(errno));
|
||||
*analyze_script_file_name, getErrorText());
|
||||
#endif
|
||||
|
||||
if (os_info.user_specified)
|
||||
@@ -687,7 +687,7 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name)
|
||||
|
||||
if ((script = fopen_priv(*deletion_script_file_name, "w")) == NULL)
|
||||
pg_fatal("Could not open file \"%s\": %s\n",
|
||||
*deletion_script_file_name, getErrorText(errno));
|
||||
*deletion_script_file_name, getErrorText());
|
||||
|
||||
#ifndef WIN32
|
||||
/* add shebang header */
|
||||
@@ -741,7 +741,7 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name)
|
||||
#ifndef WIN32
|
||||
if (chmod(*deletion_script_file_name, S_IRWXU) != 0)
|
||||
pg_fatal("Could not add execute permission to file \"%s\": %s\n",
|
||||
*deletion_script_file_name, getErrorText(errno));
|
||||
*deletion_script_file_name, getErrorText());
|
||||
#endif
|
||||
|
||||
check_ok();
|
||||
@@ -877,7 +877,7 @@ check_for_isn_and_int8_passing_mismatch(ClusterInfo *cluster)
|
||||
found = true;
|
||||
if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
|
||||
pg_fatal("Could not open file \"%s\": %s\n",
|
||||
output_path, getErrorText(errno));
|
||||
output_path, getErrorText());
|
||||
if (!db_used)
|
||||
{
|
||||
fprintf(script, "Database: %s\n", active_db->db_name);
|
||||
@@ -980,7 +980,7 @@ check_for_reg_data_type_usage(ClusterInfo *cluster)
|
||||
found = true;
|
||||
if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
|
||||
pg_fatal("Could not open file \"%s\": %s\n",
|
||||
output_path, getErrorText(errno));
|
||||
output_path, getErrorText());
|
||||
if (!db_used)
|
||||
{
|
||||
fprintf(script, "Database: %s\n", active_db->db_name);
|
||||
@@ -1071,7 +1071,7 @@ check_for_jsonb_9_4_usage(ClusterInfo *cluster)
|
||||
found = true;
|
||||
if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
|
||||
pg_fatal("Could not open file \"%s\": %s\n",
|
||||
output_path, getErrorText(errno));
|
||||
output_path, getErrorText());
|
||||
if (!db_used)
|
||||
{
|
||||
fprintf(script, "Database: %s\n", active_db->db_name);
|
||||
@@ -1119,7 +1119,7 @@ get_bin_version(ClusterInfo *cluster)
|
||||
if ((output = popen(cmd, "r")) == NULL ||
|
||||
fgets(cmd_output, sizeof(cmd_output), output) == NULL)
|
||||
pg_fatal("Could not get pg_ctl version data using %s: %s\n",
|
||||
cmd, getErrorText(errno));
|
||||
cmd, getErrorText());
|
||||
|
||||
pclose(output);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user