gpdb
gpdb copied to clipboard
Fix type_array oid assignment for pre-GPDB7 to GPDB7 upgrade
For DOMAINS, GPDB5/6 does not assign an array type, but GPDB7 does. To handle this, we find an unused type Oid to assign.
be8bb094d2ae8ec24c03a399611507a5f1a8f0d9 did not correctly dump the type array namespace and type array name when following this code path. As a result, during a pg_restore to GPDB7 we hit an Assertion failure
/*
* We should never be asked to generate a new pg_type OID during
* pg_upgrade; doing so would risk collisions with the OIDs it wants to
* assign. Hitting this assert means there's some path where we failed to
* ensure that a type OID is determined by commands in the dump script. */ Assert(!IsBinaryUpgrade || RelationGetRelid(relation) != TypeRelationId);
This commit will now use the namespace of the type and prepend an '_' for the type array name to properly assign the Oid.
Before:
-- For binary upgrade, must preserve pg_type oid
SELECT pg_catalog.binary_upgrade_set_next_pg_type_oid('58187'::pg_catalog.oid, '57868'::pg_catalog.oid, $$intdom$$::text);
-- For binary upgrade, must preserve pg_type array oid
SELECT pg_catalog.binary_upgrade_set_next_array_pg_type_oid('16385'::pg_catalog.oid, '0'::pg_catalog.oid, $$$$::text);
CREATE DOMAIN "gpdist_legacy_opclasses"."intdom" AS integer;
After:
-- For binary upgrade, must preserve pg_type oid
SELECT pg_catalog.binary_upgrade_set_next_pg_type_oid('58187'::pg_catalog.oid, '57868'::pg_catalog.oid, $$intdom$$::text);
-- For binary upgrade, must preserve pg_type array oid
SELECT pg_catalog.binary_upgrade_set_next_array_pg_type_oid('16385'::pg_catalog.oid, '57868'::pg_catalog.oid, $$_intdom$$::text);
CREATE DOMAIN "gpdist_legacy_opclasses"."intdom" AS integer;