MCPcopy Create free account
hub / github.com/apache/cloudberry / SetRelationHasSubclass

Function SetRelationHasSubclass

src/backend/commands/tablecmds.c:3890–3919  ·  view source on GitHub ↗

* SetRelationHasSubclass * Set the value of the relation's relhassubclass field in pg_class. * * NOTE: caller must be holding an appropriate lock on the relation. * ShareUpdateExclusiveLock is sufficient. * * NOTE: an important side-effect of this operation is that an SI invalidation * message is sent out to all backends --- including me --- causing plans * referencing the relation to be

Source from the content-addressed store, hash-verified

3888 * row.
3889 */
3890void
3891SetRelationHasSubclass(Oid relationId, bool relhassubclass)
3892{
3893 Relation relationRelation;
3894 HeapTuple tuple;
3895 Form_pg_class classtuple;
3896
3897 /*
3898 * Fetch a modifiable copy of the tuple, modify it, update pg_class.
3899 */
3900 relationRelation = table_open(RelationRelationId, RowExclusiveLock);
3901 tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relationId));
3902 if (!HeapTupleIsValid(tuple))
3903 elog(ERROR, "cache lookup failed for relation %u", relationId);
3904 classtuple = (Form_pg_class) GETSTRUCT(tuple);
3905
3906 if (classtuple->relhassubclass != relhassubclass)
3907 {
3908 classtuple->relhassubclass = relhassubclass;
3909 CatalogTupleUpdate(relationRelation, &tuple->t_self, tuple);
3910 }
3911 else
3912 {
3913 /* no need to change tuple, but force relcache rebuild anyway */
3914 CacheInvalidateRelcacheByTuple(tuple);
3915 }
3916
3917 heap_freetuple(tuple);
3918 table_close(relationRelation, RowExclusiveLock);
3919}
3920
3921/*
3922 * CheckRelationTableSpaceMove

Callers 4

IndexSetParentIndexFunction · 0.85
StoreCatalogInheritance1Function · 0.85
index_create_internalFunction · 0.85

Calls 6

table_openFunction · 0.85
ObjectIdGetDatumFunction · 0.85
CatalogTupleUpdateFunction · 0.85
heap_freetupleFunction · 0.85
table_closeFunction · 0.85

Tested by

no test coverage detected