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

Function deconstruct_composite_datum

src/pl/plpgsql/src/pl_exec.c:7319–7339  ·  view source on GitHub ↗

* 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

Source from the content-addressed store, hash-verified

7317 * Also, best to call this in a short-lived context, as it might leak memory.
7318 */
7319static TupleDesc
7320deconstruct_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

Callers 3

plpgsql_exec_triggerFunction · 0.85
exec_stmt_return_nextFunction · 0.85

Calls 1

lookup_rowtype_tupdescFunction · 0.85

Tested by

no test coverage detected