---------------- * SendFunctionResult * ---------------- */
| 64 | * ---------------- |
| 65 | */ |
| 66 | static void |
| 67 | SendFunctionResult(Datum retval, bool isnull, Oid rettype, int16 format) |
| 68 | { |
| 69 | StringInfoData buf; |
| 70 | |
| 71 | pq_beginmessage(&buf, 'V'); |
| 72 | |
| 73 | if (isnull) |
| 74 | { |
| 75 | pq_sendint32(&buf, -1); |
| 76 | } |
| 77 | else |
| 78 | { |
| 79 | if (format == 0) |
| 80 | { |
| 81 | Oid typoutput; |
| 82 | bool typisvarlena; |
| 83 | char *outputstr; |
| 84 | |
| 85 | getTypeOutputInfo(rettype, &typoutput, &typisvarlena); |
| 86 | outputstr = OidOutputFunctionCall(typoutput, retval); |
| 87 | pq_sendcountedtext(&buf, outputstr, strlen(outputstr), false); |
| 88 | pfree(outputstr); |
| 89 | } |
| 90 | else if (format == 1) |
| 91 | { |
| 92 | Oid typsend; |
| 93 | bool typisvarlena; |
| 94 | bytea *outputbytes; |
| 95 | |
| 96 | getTypeBinaryOutputInfo(rettype, &typsend, &typisvarlena); |
| 97 | outputbytes = OidSendFunctionCall(typsend, retval); |
| 98 | pq_sendint32(&buf, VARSIZE(outputbytes) - VARHDRSZ); |
| 99 | pq_sendbytes(&buf, VARDATA(outputbytes), |
| 100 | VARSIZE(outputbytes) - VARHDRSZ); |
| 101 | pfree(outputbytes); |
| 102 | } |
| 103 | else |
| 104 | ereport(ERROR, |
| 105 | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| 106 | errmsg("unsupported format code: %d", format))); |
| 107 | } |
| 108 | |
| 109 | pq_endmessage(&buf); |
| 110 | } |
| 111 | |
| 112 | /* |
| 113 | * fetch_fp_info |
no test coverage detected