mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
Don't create pg_type entries for sequences or toast tables.
Commit f7f70d5e2
left one inconsistency behind: we're still creating
pg_type entries for the composite types of sequences and toast tables,
but not arrays over those composites. But there seems precious little
reason to have named composite types for toast tables, and not much more
to have them for sequences (especially given the thought that sequences
may someday not be standalone relations at all).
So, let's close that inconsistency by removing these composite types,
rather than adding arrays for them. This buys back a little bit of
the initial pg_type bloat added by the previous patch, and could be
a significant savings in a large database with many toast tables.
Aside from a small logic rearrangement in heap_create_with_catalog,
this patch mostly needs to clean up some places that were assuming that
pg_class.reltype always has a valid value. Those are really pre-existing
bugs, given that it's documented otherwise; notably, the plpgsql changes
fix code that gives "cache lookup failed for type 0" on indexes today.
But none of these seem interesting enough to back-patch.
Also, remove the pg_dump/pg_upgrade infrastructure for propagating
a toast table's pg_type OID into the new database, since we no longer
need that.
Discussion: https://postgr.es/m/761F1389-C6A8-4C15-80CE-950C961F5341@gmail.com
This commit is contained in:
13
src/backend/utils/cache/relcache.c
vendored
13
src/backend/utils/cache/relcache.c
vendored
@ -506,9 +506,10 @@ RelationBuildTupleDesc(Relation relation)
|
||||
AttrMissing *attrmiss = NULL;
|
||||
int ndef = 0;
|
||||
|
||||
/* copy some fields from pg_class row to rd_att */
|
||||
relation->rd_att->tdtypeid = relation->rd_rel->reltype;
|
||||
relation->rd_att->tdtypmod = -1; /* unnecessary, but... */
|
||||
/* fill rd_att's type ID fields (compare heap.c's AddNewRelationTuple) */
|
||||
relation->rd_att->tdtypeid =
|
||||
relation->rd_rel->reltype ? relation->rd_rel->reltype : RECORDOID;
|
||||
relation->rd_att->tdtypmod = -1; /* just to be sure */
|
||||
|
||||
constr = (TupleConstr *) MemoryContextAlloc(CacheMemoryContext,
|
||||
sizeof(TupleConstr));
|
||||
@ -1886,7 +1887,7 @@ formrdesc(const char *relationName, Oid relationReltype,
|
||||
relation->rd_att->tdrefcount = 1; /* mark as refcounted */
|
||||
|
||||
relation->rd_att->tdtypeid = relationReltype;
|
||||
relation->rd_att->tdtypmod = -1; /* unnecessary, but... */
|
||||
relation->rd_att->tdtypmod = -1; /* just to be sure */
|
||||
|
||||
/*
|
||||
* initialize tuple desc info
|
||||
@ -5692,8 +5693,8 @@ load_relcache_init_file(bool shared)
|
||||
rel->rd_att = CreateTemplateTupleDesc(relform->relnatts);
|
||||
rel->rd_att->tdrefcount = 1; /* mark as refcounted */
|
||||
|
||||
rel->rd_att->tdtypeid = relform->reltype;
|
||||
rel->rd_att->tdtypmod = -1; /* unnecessary, but... */
|
||||
rel->rd_att->tdtypeid = relform->reltype ? relform->reltype : RECORDOID;
|
||||
rel->rd_att->tdtypmod = -1; /* just to be sure */
|
||||
|
||||
/* next read all the attribute tuple form data entries */
|
||||
has_not_null = false;
|
||||
|
Reference in New Issue
Block a user