* DatumGetExpandedArray: get a writable expanded array from an input argument * * Caution: if the input is a read/write pointer, this returns the input * argument; so callers must be sure that their changes are "safe", that is * they cannot leave the array in a corrupt state. */
| 349 | * they cannot leave the array in a corrupt state. |
| 350 | */ |
| 351 | ExpandedArrayHeader * |
| 352 | DatumGetExpandedArray(Datum d) |
| 353 | { |
| 354 | /* If it's a writable expanded array already, just return it */ |
| 355 | if (VARATT_IS_EXTERNAL_EXPANDED_RW(DatumGetPointer(d))) |
| 356 | { |
| 357 | ExpandedArrayHeader *eah = (ExpandedArrayHeader *) DatumGetEOHP(d); |
| 358 | |
| 359 | Assert(eah->ea_magic == EA_MAGIC); |
| 360 | return eah; |
| 361 | } |
| 362 | |
| 363 | /* Else expand the hard way */ |
| 364 | d = expand_array(d, CurrentMemoryContext, NULL); |
| 365 | return (ExpandedArrayHeader *) DatumGetEOHP(d); |
| 366 | } |
| 367 | |
| 368 | /* |
| 369 | * As above, when caller has the ability to cache element type info |
no test coverage detected