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 <[email protected]>
Discussion: 
https://postgr.es/m/CANWCAZbusXHWWSq_9NpxtOGvR=m5mh4uj+wo0f1_rtc0ume...@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(+)

Reply via email to