* deconstruct_composite_datum extract tuple+tupdesc from composite Datum * * The caller must supply a HeapTupleData variable, in which we set up a * tuple header pointing to the composite datum's body. To make the tuple * value outlive that variable, caller would need to apply heap_copytuple... * but current callers only need a short-lived tuple value anyway. * * Returns a pointer to the
| 7317 | * Also, best to call this in a short-lived context, as it might leak memory. |
| 7318 | */ |
| 7319 | static TupleDesc |
| 7320 | deconstruct_composite_datum(Datum value, HeapTupleData *tmptup) |
| 7321 | { |
| 7322 | HeapTupleHeader td; |
| 7323 | Oid tupType; |
| 7324 | int32 tupTypmod; |
| 7325 | |
| 7326 | /* Get tuple body (note this could involve detoasting) */ |
| 7327 | td = DatumGetHeapTupleHeader(value); |
| 7328 | |
| 7329 | /* Build a temporary HeapTuple control structure */ |
| 7330 | tmptup->t_len = HeapTupleHeaderGetDatumLength(td); |
| 7331 | ItemPointerSetInvalid(&(tmptup->t_self)); |
| 7332 | tmptup->t_tableOid = InvalidOid; |
| 7333 | tmptup->t_data = td; |
| 7334 | |
| 7335 | /* Extract rowtype info and find a tupdesc */ |
| 7336 | tupType = HeapTupleHeaderGetTypeId(td); |
| 7337 | tupTypmod = HeapTupleHeaderGetTypMod(td); |
| 7338 | return lookup_rowtype_tupdesc(tupType, tupTypmod); |
| 7339 | } |
| 7340 | |
| 7341 | /* |
| 7342 | * exec_move_row_from_datum Move a composite Datum into a record or row |
no test coverage detected