* 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
| 4544 | * extracting fields. |
| 4545 | */ |
| 4546 | static TupleDesc |
| 4547 | BuildHardcodedDescriptor(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 | |
| 4576 | static TupleDesc |
| 4577 | GetPgClassDescriptor(void) |
no test coverage detected