diff options
author | Bruce Momjian <bruce@momjian.us> | 2000-06-09 01:44:34 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2000-06-09 01:44:34 +0000 |
commit | 8c1d09d591c446aa777668497abd91a60c26dc97 (patch) | |
tree | f8d534926aefb0f366da2a916b812b29e50fcc63 /src/backend/commands/creatinh.c | |
parent | fb070464c1907bfea7c4f15fddf6c6c6f034042c (diff) | |
download | postgresql-8c1d09d591c446aa777668497abd91a60c26dc97.tar.gz postgresql-8c1d09d591c446aa777668497abd91a60c26dc97.zip |
Inheritance overhaul by Chris Bitmead <chris@bitmead.com>
Diffstat (limited to 'src/backend/commands/creatinh.c')
-rw-r--r-- | src/backend/commands/creatinh.c | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/src/backend/commands/creatinh.c b/src/backend/commands/creatinh.c index b8f8a56eafd..f33d301ded2 100644 --- a/src/backend/commands/creatinh.c +++ b/src/backend/commands/creatinh.c @@ -8,7 +8,11 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.58 2000/05/30 00:49:43 momjian Exp $ +<<<<<<< creatinh.c + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.59 2000/06/09 01:44:03 momjian Exp $ +======= + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.59 2000/06/09 01:44:03 momjian Exp $ +>>>>>>> 1.58 * *------------------------------------------------------------------------- */ @@ -34,6 +38,9 @@ static bool checkAttrExists(const char *attributeName, const char *attributeType, List *schema); static List *MergeAttributes(List *schema, List *supers, List **supconstr); static void StoreCatalogInheritance(Oid relationId, List *supers); +static void +setRelhassubclassInRelation(Oid relationId, bool relhassubclass); + /* ---------------------------------------------------------------- * DefineRelation @@ -326,6 +333,7 @@ MergeAttributes(List *schema, List *supers, List **supconstr) TupleConstr *constr; relation = heap_openr(name, AccessShareLock); + setRelhassubclassInRelation(relation->rd_id, true); tupleDesc = RelationGetDescr(relation); constr = tupleDesc->constr; @@ -660,3 +668,39 @@ checkAttrExists(const char *attributeName, const char *attributeType, List *sche } return false; } + + +static void +setRelhassubclassInRelation(Oid relationId, bool relhassubclass) +{ + Relation relationRelation; + HeapTuple tuple; + Relation idescs[Num_pg_class_indices]; + + /* + * Lock a relation given its Oid. Go to the RelationRelation (i.e. + * pg_relation), find the appropriate tuple, and add the specified + * lock to it. + */ + relationRelation = heap_openr(RelationRelationName, RowExclusiveLock); + tuple = SearchSysCacheTuple(RELOID, + ObjectIdGetDatum(relationId), + 0, 0, 0) +; + Assert(HeapTupleIsValid(tuple)); + + ((Form_pg_class) GETSTRUCT(tuple))->relhassubclass = relhassubclass; + heap_update(relationRelation, &tuple->t_self, tuple, NULL); + + /* keep the catalog indices up to date */ + CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, idescs); + CatalogIndexInsert(idescs, Num_pg_class_indices, relationRelation, tuple +); + CatalogCloseIndices(Num_pg_class_indices, idescs); + + heap_close(relationRelation, RowExclusiveLock); +} + + + + |