From 78a09145e0f8322e625bbc7d69fcb865ce4f3034 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Sat, 19 Dec 2009 00:47:57 +0000 Subject: [PATCH] binary migration: pg_migrator Add comments about places where system oids have to be preserved for binary migration. --- src/backend/catalog/pg_enum.c | 6 +++++- src/backend/commands/typecmds.c | 8 +++++++- src/backend/utils/adt/arrayfuncs.c | 7 ++++++- src/backend/utils/adt/enum.c | 6 +++++- src/backend/utils/adt/rowtypes.c | 7 ++++++- 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/backend/catalog/pg_enum.c b/src/backend/catalog/pg_enum.c index c6cb004b14..ee075d94c8 100644 --- a/src/backend/catalog/pg_enum.c +++ b/src/backend/catalog/pg_enum.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/pg_enum.c,v 1.9 2009/01/01 17:23:37 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/pg_enum.c,v 1.10 2009/12/19 00:47:57 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -67,6 +67,10 @@ EnumValuesCreate(Oid enumTypeOid, List *vals) oids = (Oid *) palloc(n * sizeof(Oid)); for (i = 0; i < n; i++) { + /* + * The pg_enum.oid is stored in user tables. This oid must be + * preserved by binary upgrades. + */ oids[i] = GetNewOid(pg_enum); } diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c index 54d8220cb3..a11825c8a9 100644 --- a/src/backend/commands/typecmds.c +++ b/src/backend/commands/typecmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.139 2009/12/07 05:22:21 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.140 2009/12/19 00:47:57 momjian Exp $ * * DESCRIPTION * The "DefineFoo" routines take the parse tree and pick out the @@ -531,6 +531,12 @@ DefineType(List *names, List *parameters) * now have TypeCreate do all the real work. */ typoid = + /* + * The pg_type.oid is stored in user tables as array elements + * (base types) in ArrayType and in composite types in + * DatumTupleFields. This oid must be preserved by binary + * upgrades. + */ TypeCreate(InvalidOid, /* no predetermined type OID */ typeName, /* type name */ typeNamespace, /* namespace */ diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index e76734edd5..b7033d4b1c 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.161 2009/09/04 11:20:22 heikki Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.162 2009/12/19 00:47:57 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -328,6 +328,11 @@ array_in(PG_FUNCTION_ARGS) SET_VARSIZE(retval, nbytes); retval->ndim = ndim; retval->dataoffset = dataoffset; + /* + * This comes from the array's pg_type.typelem (which points to the + * base data type's pg_type.oid) and stores system oids in user tables. + * This oid must be preserved by binary upgrades. + */ retval->elemtype = element_type; memcpy(ARR_DIMS(retval), dim, ndim * sizeof(int)); memcpy(ARR_LBOUND(retval), lBound, ndim * sizeof(int)); diff --git a/src/backend/utils/adt/enum.c b/src/backend/utils/adt/enum.c index 009c6c3f92..3880572221 100644 --- a/src/backend/utils/adt/enum.c +++ b/src/backend/utils/adt/enum.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/enum.c,v 1.7 2009/01/01 17:23:49 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/enum.c,v 1.8 2009/12/19 00:47:57 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -56,6 +56,10 @@ enum_in(PG_FUNCTION_ARGS) format_type_be(enumtypoid), name))); + /* + * This comes from pg_enum.oid and stores system oids in user tables. + * This oid must be preserved by binary upgrades. + */ enumoid = HeapTupleGetOid(tup); ReleaseSysCache(tup); diff --git a/src/backend/utils/adt/rowtypes.c b/src/backend/utils/adt/rowtypes.c index 9ea8a2d80f..e86e642603 100644 --- a/src/backend/utils/adt/rowtypes.c +++ b/src/backend/utils/adt/rowtypes.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/rowtypes.c,v 1.25 2009/06/11 14:49:04 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/rowtypes.c,v 1.26 2009/12/19 00:47:57 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -97,6 +97,11 @@ record_in(PG_FUNCTION_ARGS) (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("input of anonymous composite types is not implemented"))); tupTypmod = -1; /* for all non-anonymous types */ + /* + * This comes from the composite type's pg_type.oid and + * stores system oids in user tables, specifically DatumTupleFields. + * This oid must be preserved by binary upgrades. + */ tupdesc = lookup_rowtype_tupdesc(tupType, tupTypmod); ncolumns = tupdesc->natts; -- GitLab