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

Function SerializeParamExecParams

src/backend/executor/execParallel.c:357–407  ·  view source on GitHub ↗

* Serialize specified PARAM_EXEC parameters. * * 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 paramid (location of param in execution time internal * parameter array) and then the datum as serialized by datumSerialize(). */

Source from the content-addressed store, hash-verified

355 * parameter array) and then the datum as serialized by datumSerialize().
356 */
357static dsa_pointer
358SerializeParamExecParams(EState *estate, Bitmapset *params, dsa_area *area)
359{
360 Size size;
361 int nparams;
362 int paramid;
363 ParamExecData *prm;
364 dsa_pointer handle;
365 char *start_address;
366
367 /* Allocate enough space for the current parameter values. */
368 size = EstimateParamExecSpace(estate, params);
369 handle = dsa_allocate(area, size);
370 start_address = dsa_get_address(area, handle);
371
372 /* First write the number of parameters as a 4-byte integer. */
373 nparams = bms_num_members(params);
374 memcpy(start_address, &nparams, sizeof(int));
375 start_address += sizeof(int);
376
377 /* Write details for each parameter in turn. */
378 paramid = -1;
379 while ((paramid = bms_next_member(params, paramid)) >= 0)
380 {
381 Oid typeOid;
382 int16 typLen;
383 bool typByVal;
384
385 prm = &(estate->es_param_exec_vals[paramid]);
386 typeOid = list_nth_oid(estate->es_plannedstmt->paramExecTypes,
387 paramid);
388
389 /* Write paramid. */
390 memcpy(start_address, &paramid, sizeof(int));
391 start_address += sizeof(int);
392
393 /* Write datum/isnull */
394 if (OidIsValid(typeOid))
395 get_typlenbyval(typeOid, &typLen, &typByVal);
396 else
397 {
398 /* If no type OID, assume by-value, like copyParamList does. */
399 typLen = sizeof(Datum);
400 typByVal = true;
401 }
402 datumSerialize(prm->value, prm->isnull, typByVal, typLen,
403 &start_address);
404 }
405
406 return handle;
407}
408
409/*
410 * Restore specified PARAM_EXEC parameters.

Callers 2

ExecInitParallelPlanFunction · 0.85
ExecParallelReinitializeFunction · 0.85

Calls 7

EstimateParamExecSpaceFunction · 0.85
dsa_get_addressFunction · 0.85
bms_num_membersFunction · 0.85
bms_next_memberFunction · 0.85
list_nth_oidFunction · 0.85
get_typlenbyvalFunction · 0.85
datumSerializeFunction · 0.85

Tested by

no test coverage detected