* SysCacheGetAttr * * Given a tuple previously fetched by SearchSysCache(), * extract a specific attribute. * * This is equivalent to using heap_getattr() on a tuple fetched * from a non-cached relation. Usually, this is only used for attributes * that could be NULL or variable length; the fixed-size attributes in * a system table are accessed just by mapping the tuple onto the C struct
| 1614 | * a different cache for the same catalog the tuple was fetched from. |
| 1615 | */ |
| 1616 | Datum |
| 1617 | SysCacheGetAttr(int cacheId, HeapTuple tup, |
| 1618 | AttrNumber attributeNumber, |
| 1619 | bool *isNull) |
| 1620 | { |
| 1621 | /* |
| 1622 | * We just need to get the TupleDesc out of the cache entry, and then we |
| 1623 | * can apply heap_getattr(). Normally the cache control data is already |
| 1624 | * valid (because the caller recently fetched the tuple via this same |
| 1625 | * cache), but there are cases where we have to initialize the cache here. |
| 1626 | */ |
| 1627 | if (cacheId < 0 || cacheId >= SysCacheSize || |
| 1628 | !PointerIsValid(SysCache[cacheId])) |
| 1629 | elog(ERROR, "invalid cache ID: %d", cacheId); |
| 1630 | if (!PointerIsValid(SysCache[cacheId]->cc_tupdesc)) |
| 1631 | { |
| 1632 | InitCatCachePhase2(SysCache[cacheId], false); |
| 1633 | Assert(PointerIsValid(SysCache[cacheId]->cc_tupdesc)); |
| 1634 | } |
| 1635 | |
| 1636 | return heap_getattr(tup, attributeNumber, |
| 1637 | SysCache[cacheId]->cc_tupdesc, |
| 1638 | isNull); |
| 1639 | } |
| 1640 | |
| 1641 | /* |
| 1642 | * GetSysCacheHashValue |