summaryrefslogtreecommitdiff
path: root/contrib/pg_upgrade/check.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/pg_upgrade/check.c')
-rw-r--r--contrib/pg_upgrade/check.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/contrib/pg_upgrade/check.c b/contrib/pg_upgrade/check.c
index 1a37b79a8b7..464bbe2604f 100644
--- a/contrib/pg_upgrade/check.c
+++ b/contrib/pg_upgrade/check.c
@@ -455,18 +455,13 @@ create_script_for_cluster_analyze(char **analyze_script_file_name)
FILE *script = NULL;
char *user_specification = "";
- if (os_info.user_specified)
- {
- user_specification = pg_malloc(strlen(os_info.user) + 7);
- sprintf(user_specification, "-U \"%s\" ", os_info.user);
- }
-
- *analyze_script_file_name = pg_malloc(MAXPGPATH);
-
prep_status("Creating script to analyze new cluster");
- snprintf(*analyze_script_file_name, MAXPGPATH, "analyze_new_cluster.%s",
- SCRIPT_EXT);
+ if (os_info.user_specified)
+ pg_asprintf(&user_specification, "-U \"%s\" ", os_info.user);
+
+ pg_asprintf(analyze_script_file_name, "analyze_new_cluster.%s",
+ SCRIPT_EXT);
if ((script = fopen_priv(*analyze_script_file_name, "w")) == NULL)
pg_fatal("Could not open file \"%s\": %s\n",
@@ -597,10 +592,8 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name)
int tblnum;
char old_cluster_pgdata[MAXPGPATH];
- *deletion_script_file_name = pg_malloc(MAXPGPATH);
-
- snprintf(*deletion_script_file_name, MAXPGPATH, "delete_old_cluster.%s",
- SCRIPT_EXT);
+ pg_asprintf(deletion_script_file_name, "delete_old_cluster.%s",
+ SCRIPT_EXT);
/*
* Some users (oddly) create tablespaces inside the cluster data