Tom Lane <t...@sss.pgh.pa.us> writes:
Yeah, the way it is now seems outright broken.  It will try to do
get_bin_version on the new cluster before having done validate_exec
there, violating its own comment.

I think we should change this as a bug fix, independently of whatever
else you had in mind to do here.

I see this bug is now fixed in pg_upgrade/exec.c => check_bin_dir().

There's another bit exactly like that in check_data_dir() though.
We use global variables instead of using the argument passed to the function, which makes the function not reusable. Sorry if I mentioned it too vaguely
in the previous letter.

I attached a patch with the change that would fix it.
In pg_upgrade/exec.c => check_data_dir() I substituted these two lines
    old_cluster.major_version = get_major_server_version(&old_cluster);
    new_cluster.major_version = get_major_server_version(&new_cluster);
with this line:
    cluster->major_version = get_major_server_version(cluster);
and changed the comment accordingly.
From 9b63a7fc5d1dce6d254aec0abe412f2c1cd5f889 Mon Sep 17 00:00:00 2001
From: Akenteva Anna <a.akent...@postgrespro.ru>
Date: Thu, 16 Nov 2017 13:25:29 +0300
Subject: [PATCH] Fixed check_data_dir in pg_upgrade/exec.c

Changed using global variables (old_cluster and new_cluster) into
using the argument of the check_data_dir function.
---
 src/bin/pg_upgrade/exec.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
index 810a5a0..f5cd74f 100644
--- a/src/bin/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -331,9 +331,8 @@ check_data_dir(ClusterInfo *cluster)
 {
 	const char *pg_data = cluster->pgdata;
 
-	/* get old and new cluster versions */
-	old_cluster.major_version = get_major_server_version(&old_cluster);
-	new_cluster.major_version = get_major_server_version(&new_cluster);
+	/* get the cluster version */
+	cluster->major_version = get_major_server_version(cluster);
 
 	check_single_dir(pg_data, "");
 	check_single_dir(pg_data, "base");
-- 
2.7.4

Reply via email to