From daafe36c54d14587df6bac41d48d92f0a6f8e1e7 Mon Sep 17 00:00:00 2001 From: Justin Pryzby Date: Tue, 1 Nov 2022 18:32:51 -0500 Subject: [PATCH 2/2] pg_upgrade: prohibit attempts to upgrade a cluster on top of itself ./tmp_install/usr/local/pgsql/bin/initdb -N -D pg16.dat ./tmp_install/usr/local/pgsql/bin/pg_upgrade -D pg16.dat -d `pwd`/pg16.dat -b ./tmp_install/usr/local/pgsql/bin --- src/bin/pg_upgrade/option.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bin/pg_upgrade/option.c b/src/bin/pg_upgrade/option.c index 2939f584b4c..598d9c5fc10 100644 --- a/src/bin/pg_upgrade/option.c +++ b/src/bin/pg_upgrade/option.c @@ -233,6 +233,10 @@ parseCommandLine(int argc, char *argv[]) check_required_directory(&user_opts.socketdir, "PGSOCKETDIR", true, "-s", _("sockets will be created"), false); + if (strcmp(make_absolute_path(old_cluster.pgdata), + make_absolute_path(new_cluster.pgdata)) == 0) + pg_fatal("cannot upgrade a cluster on top of itself"); + #ifdef WIN32 /* -- 2.25.1