Bruce Momjian wrote: > > I think the OIDs for user-defined arrays stored in table data are > > element types, not the array type which is what you're pointing at with > > the line you quote: > > > > > > > array_oid = GetNewOid(pg_type); > > > > IMBFOS. > > Oh, yea, sorry, I was just showing examples of where we get the oids --- > I have not researched the exact calls yet, but I am doing that now and > will apply a patch that adds C comments to the C structures to identify > them. I figure it would be good to document this no matter what we do.
I have applied the attached patch which documents the locations where system oids have to be preserved for binary upgrades. -- Bruce Momjian <br...@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + If your life is a hard drive, Christ can be your backup. +
Index: src/backend/catalog/pg_enum.c =================================================================== RCS file: /cvsroot/pgsql/src/backend/catalog/pg_enum.c,v retrieving revision 1.9 diff -c -c -r1.9 pg_enum.c *** src/backend/catalog/pg_enum.c 1 Jan 2009 17:23:37 -0000 1.9 --- src/backend/catalog/pg_enum.c 19 Dec 2009 00:46:10 -0000 *************** *** 67,72 **** --- 67,76 ---- 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); } Index: src/backend/commands/typecmds.c =================================================================== RCS file: /cvsroot/pgsql/src/backend/commands/typecmds.c,v retrieving revision 1.139 diff -c -c -r1.139 typecmds.c *** src/backend/commands/typecmds.c 7 Dec 2009 05:22:21 -0000 1.139 --- src/backend/commands/typecmds.c 19 Dec 2009 00:46:10 -0000 *************** *** 531,536 **** --- 531,542 ---- * 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 */ Index: src/backend/utils/adt/arrayfuncs.c =================================================================== RCS file: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v retrieving revision 1.161 diff -c -c -r1.161 arrayfuncs.c *** src/backend/utils/adt/arrayfuncs.c 4 Sep 2009 11:20:22 -0000 1.161 --- src/backend/utils/adt/arrayfuncs.c 19 Dec 2009 00:46:13 -0000 *************** *** 328,333 **** --- 328,338 ---- 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)); Index: src/backend/utils/adt/enum.c =================================================================== RCS file: /cvsroot/pgsql/src/backend/utils/adt/enum.c,v retrieving revision 1.7 diff -c -c -r1.7 enum.c *** src/backend/utils/adt/enum.c 1 Jan 2009 17:23:49 -0000 1.7 --- src/backend/utils/adt/enum.c 19 Dec 2009 00:46:13 -0000 *************** *** 56,61 **** --- 56,65 ---- 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); Index: src/backend/utils/adt/rowtypes.c =================================================================== RCS file: /cvsroot/pgsql/src/backend/utils/adt/rowtypes.c,v retrieving revision 1.25 diff -c -c -r1.25 rowtypes.c *** src/backend/utils/adt/rowtypes.c 11 Jun 2009 14:49:04 -0000 1.25 --- src/backend/utils/adt/rowtypes.c 19 Dec 2009 00:46:14 -0000 *************** *** 97,102 **** --- 97,107 ---- (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;
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers