* 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
| 3888 | * row. |
| 3889 | */ |
| 3890 | void |
| 3891 | SetRelationHasSubclass(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 |
no test coverage detected