MCPcopy Create free account
hub / github.com/apache/cloudberry / SendFunctionResult

Function SendFunctionResult

src/backend/tcop/fastpath.c:66–110  ·  view source on GitHub ↗

---------------- * SendFunctionResult * ---------------- */

Source from the content-addressed store, hash-verified

64 * ----------------
65 */
66static void
67SendFunctionResult(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

Callers 1

HandleFunctionRequestFunction · 0.85

Calls 12

pq_beginmessageFunction · 0.85
pq_sendint32Function · 0.85
getTypeOutputInfoFunction · 0.85
OidOutputFunctionCallFunction · 0.85
pq_sendcountedtextFunction · 0.85
getTypeBinaryOutputInfoFunction · 0.85
OidSendFunctionCallFunction · 0.85
pq_sendbytesFunction · 0.85
pq_endmessageFunction · 0.85
pfreeFunction · 0.50
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected