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

Function MakeTupleTableSlot

src/backend/executor/execTuples.c:1128–1179  ·  view source on GitHub ↗

-------------------------------- * MakeTupleTableSlot * * Basic routine to make an empty TupleTableSlot of given * TupleTableSlotType. If tupleDesc is specified the slot's descriptor is * fixed for its lifetime, gaining some efficiency. If that's * undesirable, pass NULL. * -------------------------------- */

Source from the content-addressed store, hash-verified

1126 * --------------------------------
1127 */
1128TupleTableSlot *
1129MakeTupleTableSlot(TupleDesc tupleDesc,
1130 const TupleTableSlotOps *tts_ops)
1131{
1132 Size basesz,
1133 allocsz;
1134 TupleTableSlot *slot;
1135
1136 basesz = tts_ops->base_slot_size;
1137
1138 /*
1139 * When a fixed descriptor is specified, we can reduce overhead by
1140 * allocating the entire slot in one go.
1141 */
1142 if (tupleDesc)
1143 allocsz = MAXALIGN(basesz) +
1144 MAXALIGN(tupleDesc->natts * sizeof(Datum)) +
1145 MAXALIGN(tupleDesc->natts * sizeof(bool));
1146 else
1147 allocsz = basesz;
1148
1149 slot = palloc0(allocsz);
1150 /* const for optimization purposes, OK to modify at allocation time */
1151 *((const TupleTableSlotOps **) &slot->tts_ops) = tts_ops;
1152 slot->type = T_TupleTableSlot;
1153 slot->tts_flags |= TTS_FLAG_EMPTY;
1154 if (tupleDesc != NULL)
1155 slot->tts_flags |= TTS_FLAG_FIXED;
1156 slot->tts_tupleDescriptor = tupleDesc;
1157 slot->tts_mcxt = CurrentMemoryContext;
1158 slot->tts_nvalid = 0;
1159
1160 if (tupleDesc != NULL)
1161 {
1162 slot->tts_values = (Datum *)
1163 (((char *) slot)
1164 + MAXALIGN(basesz));
1165 slot->tts_isnull = (bool *)
1166 (((char *) slot)
1167 + MAXALIGN(basesz)
1168 + MAXALIGN(tupleDesc->natts * sizeof(Datum)));
1169
1170 PinTupleDesc(tupleDesc);
1171 }
1172
1173 /*
1174 * And allow slot type specific initialization.
1175 */
1176 slot->tts_ops->init(slot);
1177
1178 return slot;
1179}
1180
1181/* --------------------------------
1182 * ExecAllocTableSlot

Callers 15

CreateTestTupleTableSlotFunction · 0.85
CreateVecEmptyTupleSlotFunction · 0.85
BeginMethod · 0.85
UpdateStatsInAuxTableMethod · 0.85
CreateTupleSlotMethod · 0.85
TEST_FFunction · 0.85
TEST_PFunction · 0.85
CreateFakeTupleSlotMethod · 0.85
attach_receiver_mqFunction · 0.85
ExecConstraintsFunction · 0.85

Calls 2

palloc0Function · 0.50
initMethod · 0.45

Tested by 7

CreateTestTupleTableSlotFunction · 0.68
CreateVecEmptyTupleSlotFunction · 0.68
CreateTupleSlotMethod · 0.68
TEST_FFunction · 0.68
TEST_PFunction · 0.68
CreateFakeTupleSlotMethod · 0.68