* getTypeBinaryOutputInfo * * Get info needed for binary output of values of a type */
| 3571 | * Get info needed for binary output of values of a type |
| 3572 | */ |
| 3573 | void |
| 3574 | getTypeBinaryOutputInfo(Oid type, Oid *typSend, bool *typIsVarlena) |
| 3575 | { |
| 3576 | HeapTuple typeTuple; |
| 3577 | Form_pg_type pt; |
| 3578 | |
| 3579 | typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type)); |
| 3580 | if (!HeapTupleIsValid(typeTuple)) |
| 3581 | elog(ERROR, "cache lookup failed for type %u", type); |
| 3582 | pt = (Form_pg_type) GETSTRUCT(typeTuple); |
| 3583 | |
| 3584 | if (!pt->typisdefined) |
| 3585 | ereport(ERROR, |
| 3586 | (errcode(ERRCODE_UNDEFINED_OBJECT), |
| 3587 | errmsg("type %s is only a shell", |
| 3588 | format_type_be(type)))); |
| 3589 | if (!OidIsValid(pt->typsend)) |
| 3590 | ereport(ERROR, |
| 3591 | (errcode(ERRCODE_UNDEFINED_FUNCTION), |
| 3592 | errmsg("no binary output function available for type %s", |
| 3593 | format_type_be(type)))); |
| 3594 | |
| 3595 | *typSend = pt->typsend; |
| 3596 | *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1); |
| 3597 | |
| 3598 | ReleaseSysCache(typeTuple); |
| 3599 | } |
| 3600 | |
| 3601 | /* |
| 3602 | * get_typmodin |
no test coverage detected