Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbf26c4f

Browse files
committed
pg_upgrade: suppress creation of delete script
Suppress creation of the pg_upgrade delete script when the new datadirectory is inside the old data directory.Reported-by: IRCBackpatch-through: 9.3, where delete script tests were added
1 parent9dfb5b9 commitbf26c4f

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

‎contrib/pg_upgrade/check.c

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,10 @@ output_completion_banner(char *analyze_script_file_name,
255255
deletion_script_file_name);
256256
else
257257
pg_log(PG_REPORT,
258-
"Could not create a script to delete the old cluster's data\n"
259-
"files because user-defined tablespaces exist in the old cluster\n"
260-
"directory. The old cluster's contents must be deleted manually.\n");
258+
"Could not create a script to delete the old cluster's data files\n"
259+
"because user-defined tablespaces or the new cluster's data directory\n"
260+
"exist in the old cluster directory. The old cluster's contents must\n"
261+
"be deleted manually.\n");
261262
}
262263

263264

@@ -693,20 +694,37 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name)
693694
{
694695
FILE*script=NULL;
695696
inttblnum;
696-
charold_cluster_pgdata[MAXPGPATH];
697+
charold_cluster_pgdata[MAXPGPATH],new_cluster_pgdata[MAXPGPATH];
697698

698699
*deletion_script_file_name=pg_malloc(MAXPGPATH);
699700

700701
snprintf(*deletion_script_file_name,MAXPGPATH,"delete_old_cluster.%s",
701702
SCRIPT_EXT);
702703

704+
strlcpy(old_cluster_pgdata,old_cluster.pgdata,MAXPGPATH);
705+
canonicalize_path(old_cluster_pgdata);
706+
707+
strlcpy(new_cluster_pgdata,new_cluster.pgdata,MAXPGPATH);
708+
canonicalize_path(new_cluster_pgdata);
709+
710+
/* Some people put the new data directory inside the old one. */
711+
if (path_is_prefix_of_path(old_cluster_pgdata,new_cluster_pgdata))
712+
{
713+
pg_log(PG_WARNING,
714+
"\nWARNING: new data directory should not be inside the old data directory, e.g. %s\n",old_cluster_pgdata);
715+
716+
/* Unlink file in case it is left over from a previous run. */
717+
unlink(*deletion_script_file_name);
718+
pg_free(*deletion_script_file_name);
719+
*deletion_script_file_name=NULL;
720+
return;
721+
}
722+
703723
/*
704724
* Some users (oddly) create tablespaces inside the cluster data
705725
* directory. We can't create a proper old cluster delete script in that
706726
* case.
707727
*/
708-
strlcpy(old_cluster_pgdata,old_cluster.pgdata,MAXPGPATH);
709-
canonicalize_path(old_cluster_pgdata);
710728
for (tblnum=0;tblnum<os_info.num_old_tablespaces;tblnum++)
711729
{
712730
charold_tablespace_dir[MAXPGPATH];

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp