* Estimate the amount of space required to serialize the indicated parameters. */
| 311 | * Estimate the amount of space required to serialize the indicated parameters. |
| 312 | */ |
| 313 | static Size |
| 314 | EstimateParamExecSpace(EState *estate, Bitmapset *params) |
| 315 | { |
| 316 | int paramid; |
| 317 | Size sz = sizeof(int); |
| 318 | |
| 319 | paramid = -1; |
| 320 | while ((paramid = bms_next_member(params, paramid)) >= 0) |
| 321 | { |
| 322 | Oid typeOid; |
| 323 | int16 typLen; |
| 324 | bool typByVal; |
| 325 | ParamExecData *prm; |
| 326 | |
| 327 | prm = &(estate->es_param_exec_vals[paramid]); |
| 328 | typeOid = list_nth_oid(estate->es_plannedstmt->paramExecTypes, |
| 329 | paramid); |
| 330 | |
| 331 | sz = add_size(sz, sizeof(int)); /* space for paramid */ |
| 332 | |
| 333 | /* space for datum/isnull */ |
| 334 | if (OidIsValid(typeOid)) |
| 335 | get_typlenbyval(typeOid, &typLen, &typByVal); |
| 336 | else |
| 337 | { |
| 338 | /* If no type OID, assume by-value, like copyParamList does. */ |
| 339 | typLen = sizeof(Datum); |
| 340 | typByVal = true; |
| 341 | } |
| 342 | sz = add_size(sz, |
| 343 | datumEstimateSpace(prm->value, prm->isnull, |
| 344 | typByVal, typLen)); |
| 345 | } |
| 346 | return sz; |
| 347 | } |
| 348 | |
| 349 | /* |
| 350 | * Serialize specified PARAM_EXEC parameters. |
no test coverage detected