pgsql: pg_upgrade: Check for arrays over system types with auto-assigne - Mailing list pgsql-committers

From John Naylor
Subject pgsql: pg_upgrade: Check for arrays over system types with auto-assigne
Date
Msg-id E1x8uQx-00000000kCN-1HlH@gemulon.postgresql.org
Whole thread
List pgsql-committers
pg_upgrade: Check for arrays over system types with auto-assigned OIDs

Array values embed their element type's OID, and pg_upgrade does not
rewrite user data.  The OIDs of information_schema domains can vary
between major versions, so a stored array over one (e.g. by aggregating
an information_schema query into a table) comes through the upgrade
with at best a dangling element OID.  Whole-array reads and pg_dump
of the upgraded cluster then fail with "cache lookup failed for type
N". Worst case, the OID has been reassigned, leading to values being
misread instead.

The data type checks miss this because nothing flags the domain itself:
domain storage is just the base type, so the recursive expansion in
data_type_check_query() never reaches the array type.

Add a check for arrays whose element type OID was assigned by genbki.pl
or initdb, including anything in information_schema in case it was
dropped and reloaded.

The scenarios that hit this are fairly contrived, which probably
explains the lack of field reports, so no backpatch for now.

Reviewed-by: Chengpeng Yan <chengpeng_yan@outlook.com>
Discussion: https://postgr.es/m/CANWCAZbusXHWWSq_9NpxtOGvR=M5MH4Uj+wO0f1_rtC0uMeSWg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/77f54eb07488341025073a370f6e381a6ee05e04

Modified Files
--------------
src/bin/pg_upgrade/check.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Stamp 19beta4.
Next
From: Peter Eisentraut
Date:
Subject: pgsql: Update .abi-compliance-history for parallel GIN index build fix