Re: pg_upgrade fails to detect unsupported arrays and ranges

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Daniel Gustafsson <daniel(at)yesql(dot)se>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
Subject: Re: pg_upgrade fails to detect unsupported arrays and ranges
Date: 2021-04-28 15:09:15
Message-ID: 2798740.1619622555@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

[ blast-from-the-past department ]

I wrote:
> Daniel Gustafsson <daniel(at)yesql(dot)se> writes:
>> I can see the appeal of
>> including it before the wrap, even though I personally would've held off.

> Nah, I'm not gonna risk it at this stage. I concur with your point
> that this is an ancient bug, and one that is unlikely to bite many
> people. I'll push it Wednesday or so.

I happened across a couple of further pg_upgrade oversights in the
same vein as 29aeda6e4 et al:

* Those commits fixed the bugs in pg_upgrade/version.c about not
checking the contents of arrays/ranges/etc, but there are two
similar functions in pg_upgrade/check.c that I failed to notice
(probably due to the haste with which that patch was prepared).

* We really need to also reject user tables that contain instances
of system-defined composite types (i.e. catalog rowtypes), because
except for a few bootstrap catalogs, those type OIDs are assigned by
genbki.pl not by hand, so they aren't stable across major versions.
For example, in HEAD I get

regression=# select 'pg_enum'::regtype::oid;
oid
-------
13045
(1 row)

but the same OID was 12022 in v13, 11551 in v11, etc. So if you
had a column of type pg_enum, you'd likely get no-such-type-OID
failures when reading the values after an upgrade. I don't see
much use-case for doing such a thing, so it seems saner to just
block off the possibility rather than trying to support it.
(We'd have little choice in the back branches anyway, as their
OID values are locked down now.)

The attached proposed patch fixes these cases too. I generalized
the recursive query a little more so that it could start from an
arbitrary query yielding pg_type OIDs, rather than just one type
name; otherwise it's pretty straightforward.

Barring objections I'll apply and back-patch this soon.

regards, tom lane

Attachment Content-Type Size
fix-pg_upgrade-data-type-checks-2.patch text/x-diff 13.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Christensen 2021-04-28 15:44:11 Re: [PATCH] expand the units that pg_size_pretty supports on output
Previous Message Tom Lane 2021-04-28 14:30:27 Re: pg_hba.conf.sample wording improvement