File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -229,6 +229,26 @@ parseCommandLine(int argc, char *argv[])
229229 "PGDATAOLD" , "-d" , "old cluster data resides" );
230230 check_required_directory (& new_cluster .pgdata , & new_cluster .pgconfig ,
231231 "PGDATANEW" , "-D" , "new cluster data resides" );
232+
233+ #ifndef WIN32
234+ /*
235+ * On Windows, initdb --sync-only will fail with a "Permission denied"
236+ * error on file pg_upgrade_utility.log if pg_upgrade is run inside
237+ * the new cluster directory, so we do a check here.
238+ */
239+ {
240+ char cwd [MAXPGPATH ], new_cluster_pgdata [MAXPGPATH ];
241+
242+ strlcpy (new_cluster_pgdata , new_cluster .pgdata , MAXPGPATH );
243+ canonicalize_path (new_cluster_pgdata );
244+
245+ if (!getcwd (cwd , MAXPGPATH ))
246+ pg_fatal ("cannot find current directory\n" );
247+ canonicalize_path (cwd );
248+ if (path_is_prefix_of_path (new_cluster_pgdata , cwd ))
249+ pg_fatal ("cannot run pg_upgrade from inside the new cluster data directory on Windows\n" );
250+ }
251+ #endif
232252}
233253
234254
You can’t perform that action at this time.
0 commit comments