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

Function BuildHardcodedDescriptor

src/backend/utils/cache/relcache.c:4546–4574  ·  view source on GitHub ↗

* GetPgClassDescriptor -- get a predefined tuple descriptor for pg_class * GetPgIndexDescriptor -- get a predefined tuple descriptor for pg_index * * We need this kluge because we have to be able to access non-fixed-width * fields of pg_class and pg_index before we have the standard catalog caches * available. We use predefined data that's set up in just the same way as * the bootstrapped r

Source from the content-addressed store, hash-verified

4544 * extracting fields.
4545 */
4546static TupleDesc
4547BuildHardcodedDescriptor(int natts, const FormData_pg_attribute *attrs)
4548{
4549 TupleDesc result;
4550 MemoryContext oldcxt;
4551 int i;
4552
4553 oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
4554
4555 result = CreateTemplateTupleDesc(natts);
4556 result->tdtypeid = RECORDOID; /* not right, but we don't care */
4557 result->tdtypmod = -1;
4558
4559 for (i = 0; i < natts; i++)
4560 {
4561 memcpy(TupleDescAttr(result, i), &attrs[i], ATTRIBUTE_FIXED_PART_SIZE);
4562 /* make sure attcacheoff is valid */
4563 TupleDescAttr(result, i)->attcacheoff = -1;
4564 }
4565
4566 /* initialize first attribute's attcacheoff, cf RelationBuildTupleDesc */
4567 TupleDescAttr(result, 0)->attcacheoff = 0;
4568
4569 /* Note: we don't bother to set up a TupleConstr entry */
4570
4571 MemoryContextSwitchTo(oldcxt);
4572
4573 return result;
4574}
4575
4576static TupleDesc
4577GetPgClassDescriptor(void)

Callers 2

GetPgClassDescriptorFunction · 0.85
GetPgIndexDescriptorFunction · 0.85

Calls 2

MemoryContextSwitchToFunction · 0.85
CreateTemplateTupleDescFunction · 0.85

Tested by

no test coverage detected