* getTypeInputInfo * * Get info needed for converting values of a type to internal form */
| 3472 | * Get info needed for converting values of a type to internal form |
| 3473 | */ |
| 3474 | void |
| 3475 | getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam) |
| 3476 | { |
| 3477 | HeapTuple typeTuple; |
| 3478 | Form_pg_type pt; |
| 3479 | |
| 3480 | typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type)); |
| 3481 | if (!HeapTupleIsValid(typeTuple)) |
| 3482 | elog(ERROR, "cache lookup failed for type %u", type); |
| 3483 | pt = (Form_pg_type) GETSTRUCT(typeTuple); |
| 3484 | |
| 3485 | if (!pt->typisdefined) |
| 3486 | ereport(ERROR, |
| 3487 | (errcode(ERRCODE_UNDEFINED_OBJECT), |
| 3488 | errmsg("type %s is only a shell", |
| 3489 | format_type_be(type)))); |
| 3490 | if (!OidIsValid(pt->typinput)) |
| 3491 | ereport(ERROR, |
| 3492 | (errcode(ERRCODE_UNDEFINED_FUNCTION), |
| 3493 | errmsg("no input function available for type %s", |
| 3494 | format_type_be(type)))); |
| 3495 | |
| 3496 | *typInput = pt->typinput; |
| 3497 | *typIOParam = getTypeIOParam(typeTuple); |
| 3498 | |
| 3499 | ReleaseSysCache(typeTuple); |
| 3500 | } |
| 3501 | |
| 3502 | /* |
| 3503 | * getTypeOutputInfo |
no test coverage detected