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

Function SerializeParamList

src/backend/nodes/params.c:228–279  ·  view source on GitHub ↗

* Serialize a ParamListInfo structure into caller-provided storage. * * We write the number of parameters first, as a 4-byte integer, and then * write details for each parameter in turn. The details for each parameter * consist of a 4-byte type OID, 2 bytes of flags, and then the datum as * serialized by datumSerialize(). The caller is responsible for ensuring * that there is enough storag

Source from the content-addressed store, hash-verified

226 * paramValuesStr is not included.
227 */
228void
229SerializeParamList(ParamListInfo paramLI, char **start_address)
230{
231 int nparams;
232 int i;
233
234 /* Write number of parameters. */
235 if (paramLI == NULL || paramLI->numParams <= 0)
236 nparams = 0;
237 else
238 nparams = paramLI->numParams;
239 memcpy(*start_address, &nparams, sizeof(int));
240 *start_address += sizeof(int);
241
242 /* Write each parameter in turn. */
243 for (i = 0; i < nparams; i++)
244 {
245 ParamExternData *prm;
246 ParamExternData prmdata;
247 Oid typeOid;
248 int16 typLen;
249 bool typByVal;
250
251 /* give hook a chance in case parameter is dynamic */
252 if (paramLI->paramFetch != NULL)
253 prm = paramLI->paramFetch(paramLI, i + 1, false, &prmdata);
254 else
255 prm = &paramLI->params[i];
256
257 typeOid = prm->ptype;
258
259 /* Write type OID. */
260 memcpy(*start_address, &typeOid, sizeof(Oid));
261 *start_address += sizeof(Oid);
262
263 /* Write flags. */
264 memcpy(*start_address, &prm->pflags, sizeof(uint16));
265 *start_address += sizeof(uint16);
266
267 /* Write datum/isnull. */
268 if (OidIsValid(typeOid))
269 get_typlenbyval(typeOid, &typLen, &typByVal);
270 else
271 {
272 /* If no type OID, assume by-value, like copyParamList does. */
273 typLen = sizeof(Datum);
274 typByVal = true;
275 }
276 datumSerialize(prm->value, prm->isnull, typByVal, typLen,
277 start_address);
278 }
279}
280
281/*
282 * Copy a ParamListInfo structure.

Callers 1

ExecInitParallelPlanFunction · 0.85

Calls 2

get_typlenbyvalFunction · 0.85
datumSerializeFunction · 0.85

Tested by

no test coverage detected