* Given a typeid, return the type's typrelid (associated relation), if any. * Returns InvalidOid if type is not a composite type. */
| 665 | * Returns InvalidOid if type is not a composite type. |
| 666 | */ |
| 667 | Oid |
| 668 | typeidTypeRelid(Oid type_id) |
| 669 | { |
| 670 | HeapTuple typeTuple; |
| 671 | Form_pg_type type; |
| 672 | Oid result; |
| 673 | |
| 674 | typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type_id)); |
| 675 | if (!HeapTupleIsValid(typeTuple)) |
| 676 | elog(ERROR, "cache lookup failed for type %u", type_id); |
| 677 | type = (Form_pg_type) GETSTRUCT(typeTuple); |
| 678 | result = type->typrelid; |
| 679 | ReleaseSysCache(typeTuple); |
| 680 | return result; |
| 681 | } |
| 682 | |
| 683 | /* |
| 684 | * Given a typeid, return the type's typrelid (associated relation), if any. |
no test coverage detected