dead code in pg_upgrade

Lists: pgsql-hackers
From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: dead code in pg_upgrade
Date: 2025-03-17 17:33:18
Message-ID: Z9hc3mkYFKR56Xof@nathan
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

While trying to decipher this comment:

/*
* Do the old cluster's per-database directories share a directory
* with a new version-specific tablespace?
*/

I noticed that the condition it's referring to

if (strlen(old_cluster.tablespace_suffix) == 0)

doesn't appear to have been reachable since support for upgrading from
pre-9.2 was removed in v15 (commit e469f0a). Before then, this case seems
to have only applied to upgrades from v8.4 or older versions.

I'm planning to commit the attached patch shortly after I double-check that
I'm not missing anything.

--
nathan

Attachment Content-Type Size
v1-0001-pg_upgrade-Remove-some-dead-code.patch text/plain 2.3 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: dead code in pg_upgrade
Date: 2025-03-17 17:56:49
Message-ID: [email protected]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Nathan Bossart <nathandbossart(at)gmail(dot)com> writes:
> I noticed that the condition it's referring to
> if (strlen(old_cluster.tablespace_suffix) == 0)
> doesn't appear to have been reachable since support for upgrading from
> pre-9.2 was removed in v15 (commit e469f0a). Before then, this case seems
> to have only applied to upgrades from v8.4 or older versions.

> I'm planning to commit the attached patch shortly after I double-check that
> I'm not missing anything.

+1. e469f0aaf just removed code that was immediately connected to a
version check; I didn't look too hard for consequent simplifications.
After looking, I concur that tablespace_suffix can never be empty
anymore. I don't see any other spots checking this condition.

regards, tom lane


From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: dead code in pg_upgrade
Date: 2025-03-17 18:19:37
Message-ID: Z9hnua7Go5RgD0NT@nathan
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Mar 17, 2025 at 01:56:49PM -0400, Tom Lane wrote:
> Nathan Bossart <nathandbossart(at)gmail(dot)com> writes:
>> I noticed that the condition it's referring to
>> if (strlen(old_cluster.tablespace_suffix) == 0)
>> doesn't appear to have been reachable since support for upgrading from
>> pre-9.2 was removed in v15 (commit e469f0a). Before then, this case seems
>> to have only applied to upgrades from v8.4 or older versions.
>
>> I'm planning to commit the attached patch shortly after I double-check that
>> I'm not missing anything.
>
> +1. e469f0aaf just removed code that was immediately connected to a
> version check; I didn't look too hard for consequent simplifications.
> After looking, I concur that tablespace_suffix can never be empty
> anymore. I don't see any other spots checking this condition.

Committed, thanks for looking.

--
nathan