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

Function ExecSetSlotDescriptor

src/backend/executor/execTuples.c:1305–1340  ·  view source on GitHub ↗

-------------------------------- * ExecSetSlotDescriptor * * This function is used to set the tuple descriptor associated * with the slot's tuple. The passed descriptor must have lifespan * at least equal to the slot's. If it is a reference-counted descriptor * then the reference count is incremented for as long as the slot holds * a reference. * -------------------------------- *

Source from the content-addressed store, hash-verified

1303 * --------------------------------
1304 */
1305void
1306ExecSetSlotDescriptor(TupleTableSlot *slot, /* slot to change */
1307 TupleDesc tupdesc) /* new tuple descriptor */
1308{
1309 Assert(!TTS_FIXED(slot));
1310
1311 /* For safety, make sure slot is empty before changing it */
1312 ExecClearTuple(slot);
1313
1314 /*
1315 * Release any old descriptor. Also release old Datum/isnull arrays if
1316 * present (we don't bother to check if they could be re-used).
1317 */
1318 if (slot->tts_tupleDescriptor)
1319 ReleaseTupleDesc(slot->tts_tupleDescriptor);
1320
1321 if (slot->tts_values)
1322 pfree(slot->tts_values);
1323 if (slot->tts_isnull)
1324 pfree(slot->tts_isnull);
1325
1326 /*
1327 * Install the new descriptor; if it's refcounted, bump its refcount.
1328 */
1329 slot->tts_tupleDescriptor = tupdesc;
1330 PinTupleDesc(tupdesc);
1331
1332 /*
1333 * Allocate Datum/isnull arrays of the appropriate size. These must have
1334 * the same lifetime as the slot, so allocate in the slot's own context.
1335 */
1336 slot->tts_values = (Datum *)
1337 MemoryContextAlloc(slot->tts_mcxt, tupdesc->natts * sizeof(Datum));
1338 slot->tts_isnull = (bool *)
1339 MemoryContextAlloc(slot->tts_mcxt, tupdesc->natts * sizeof(bool));
1340}
1341
1342/* --------------------------------
1343 * ExecStoreHeapTuple

Callers 3

ExecAssignScanTypeFunction · 0.85
ExecInitJunkFilterFunction · 0.85

Calls 3

ExecClearTupleFunction · 0.85
MemoryContextAllocFunction · 0.85
pfreeFunction · 0.50

Tested by

no test coverage detected