From: Nathan Bossart Date: Mon, 17 Mar 2025 18:18:14 +0000 (-0500) Subject: pg_upgrade: Remove some dead code. X-Git-Tag: REL_18_BETA1~554 X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=7e05df430be36ad34d9c797b21f56a4b9c64bbc8;p=postgresql.git pg_upgrade: Remove some dead code. Since commit e469f0aaf3, tablespace_suffix can't be empty. Reviewed-by: Tom Lane Discussion: https://postgr.es/m/Z9hc3mkYFKR56Xof%40nathan --- diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c index 88db8869b6e..d32fc3d88ec 100644 --- a/src/bin/pg_upgrade/check.c +++ b/src/bin/pg_upgrade/check.c @@ -936,6 +936,7 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name) int tblnum; char old_cluster_pgdata[MAXPGPATH], new_cluster_pgdata[MAXPGPATH]; + char *old_tblspc_suffix; *deletion_script_file_name = psprintf("%sdelete_old_cluster.%s", SCRIPT_PREFIX, SCRIPT_EXT); @@ -1000,39 +1001,13 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name) fix_path_separator(old_cluster.pgdata), PATH_QUOTE); /* delete old cluster's alternate tablespaces */ + old_tblspc_suffix = pg_strdup(old_cluster.tablespace_suffix); + fix_path_separator(old_tblspc_suffix); for (tblnum = 0; tblnum < os_info.num_old_tablespaces; tblnum++) - { - /* - * Do the old cluster's per-database directories share a directory - * with a new version-specific tablespace? - */ - if (strlen(old_cluster.tablespace_suffix) == 0) - { - /* delete per-database directories */ - int dbnum; - - fprintf(script, "\n"); - - for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++) - fprintf(script, RMDIR_CMD " %c%s%c%u%c\n", PATH_QUOTE, - fix_path_separator(os_info.old_tablespaces[tblnum]), - PATH_SEPARATOR, old_cluster.dbarr.dbs[dbnum].db_oid, - PATH_QUOTE); - } - else - { - char *suffix_path = pg_strdup(old_cluster.tablespace_suffix); - - /* - * Simply delete the tablespace directory, which might be ".old" - * or a version-specific subdirectory. - */ - fprintf(script, RMDIR_CMD " %c%s%s%c\n", PATH_QUOTE, - fix_path_separator(os_info.old_tablespaces[tblnum]), - fix_path_separator(suffix_path), PATH_QUOTE); - pfree(suffix_path); - } - } + fprintf(script, RMDIR_CMD " %c%s%s%c\n", PATH_QUOTE, + fix_path_separator(os_info.old_tablespaces[tblnum]), + old_tblspc_suffix, PATH_QUOTE); + pfree(old_tblspc_suffix); fclose(script);