* Create the Datum/isnull representation of an expanded array object * if we didn't do so previously */
| 421 | * if we didn't do so previously |
| 422 | */ |
| 423 | void |
| 424 | deconstruct_expanded_array(ExpandedArrayHeader *eah) |
| 425 | { |
| 426 | if (eah->dvalues == NULL) |
| 427 | { |
| 428 | MemoryContext oldcxt = MemoryContextSwitchTo(eah->hdr.eoh_context); |
| 429 | Datum *dvalues; |
| 430 | bool *dnulls; |
| 431 | int nelems; |
| 432 | |
| 433 | dnulls = NULL; |
| 434 | deconstruct_array(eah->fvalue, |
| 435 | eah->element_type, |
| 436 | eah->typlen, eah->typbyval, eah->typalign, |
| 437 | &dvalues, |
| 438 | ARR_HASNULL(eah->fvalue) ? &dnulls : NULL, |
| 439 | &nelems); |
| 440 | |
| 441 | /* |
| 442 | * Update header only after successful completion of this step. If |
| 443 | * deconstruct_array fails partway through, worst consequence is some |
| 444 | * leaked memory in the object's context. If the caller fails at a |
| 445 | * later point, that's fine, since the deconstructed representation is |
| 446 | * valid anyhow. |
| 447 | */ |
| 448 | eah->dvalues = dvalues; |
| 449 | eah->dnulls = dnulls; |
| 450 | eah->dvalueslen = eah->nelems = nelems; |
| 451 | MemoryContextSwitchTo(oldcxt); |
| 452 | } |
| 453 | } |
no test coverage detected