pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: a.akenteva@postgrespro.ru
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@postgresql.org
Cc: pgsql-hackers-owner@postgresql.org
Subject: Re: [HACKERS] A weird bit in pg_upgrade/exec.c
Date: Thu, 16 Nov 2017 15:05:59 +0300
Message-ID: <ba81b93e77c4bc1778ae6f0def7be883@postgrespro.ru> (raw)
In-Reply-To: <21596.1510244246@sss.pgh.pa.us>
References: <f9266a85d918a3cf3a386b5148aee666@postgrespro.ru>
	<21596.1510244246@sss.pgh.pa.us>

Tom Lane <tgl@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.

Attachments:

  [text/x-diff] Fixed-exec-c.patch (1.0K, ../ba81b93e77c4bc1778ae6f0def7be883@postgrespro.ru/2-Fixed-exec-c.patch)
  download | inline diff:
From 9b63a7fc5d1dce6d254aec0abe412f2c1cd5f889 Mon Sep 17 00:00:00 2001
From: Akenteva Anna <a.akenteva@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



view thread (6+ messages)  latest in thread

Message-ID: <ba81b93e77c4bc1778ae6f0def7be883@postgrespro.ru>
Permalink:  ../ba81b93e77c4bc1778ae6f0def7be883@postgrespro.ru/
Also on:    postgresql.org/message-id/ba81b93e77c4bc1778ae6f0def7be883@postgrespro.ru

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: a.akenteva@postgrespro.ru, tgl@sss.pgh.pa.us, pgsql-hackers-owner@postgresql.org
  Subject: Re: [HACKERS] A weird bit in pg_upgrade/exec.c
  In-Reply-To: <ba81b93e77c4bc1778ae6f0def7be883@postgrespro.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox