Age Owner Branch data TLA Line data Source code
1 : : /*-------------------------------------------------------------------------
2 : : *
3 : : * tuptable.h
4 : : * tuple table support stuff
5 : : *
6 : : *
7 : : * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
8 : : * Portions Copyright (c) 1994, Regents of the University of California
9 : : *
10 : : * src/include/executor/tuptable.h
11 : : *
12 : : *-------------------------------------------------------------------------
13 : : */
14 : : #ifndef TUPTABLE_H
15 : : #define TUPTABLE_H
16 : :
17 : : #include "access/htup.h"
18 : : #include "access/sysattr.h"
19 : : #include "access/tupdesc.h"
20 : : #include "storage/buf.h"
21 : :
22 : : /*----------
23 : : * The executor stores tuples in a "tuple table" which is a List of
24 : : * independent TupleTableSlots.
25 : : *
26 : : * There's various different types of tuple table slots, each being able to
27 : : * store different types of tuples. Additional types of slots can be added
28 : : * without modifying core code. The type of a slot is determined by the
29 : : * TupleTableSlotOps* passed to the slot creation routine. The builtin types
30 : : * of slots are
31 : : *
32 : : * 1. physical tuple in a disk buffer page (TTSOpsBufferHeapTuple)
33 : : * 2. physical tuple constructed in palloc'ed memory (TTSOpsHeapTuple)
34 : : * 3. "minimal" physical tuple constructed in palloc'ed memory
35 : : * (TTSOpsMinimalTuple)
36 : : * 4. "virtual" tuple consisting of Datum/isnull arrays (TTSOpsVirtual)
37 : : *
38 : : *
39 : : * The first two cases are similar in that they both deal with "materialized"
40 : : * tuples, but resource management is different. For a tuple in a disk page
41 : : * we need to hold a pin on the buffer until the TupleTableSlot's reference
42 : : * to the tuple is dropped; while for a palloc'd tuple we usually want the
43 : : * tuple pfree'd when the TupleTableSlot's reference is dropped.
44 : : *
45 : : * A "minimal" tuple is handled similarly to a palloc'd regular tuple.
46 : : * At present, minimal tuples never are stored in buffers, so there is no
47 : : * parallel to case 1. Note that a minimal tuple has no "system columns".
48 : : *
49 : : * A "virtual" tuple is an optimization used to minimize physical data copying
50 : : * in a nest of plan nodes. Until materialized pass-by-reference Datums in
51 : : * the slot point to storage that is not directly associated with the
52 : : * TupleTableSlot; generally they will point to part of a tuple stored in a
53 : : * lower plan node's output TupleTableSlot, or to a function result
54 : : * constructed in a plan node's per-tuple econtext. It is the responsibility
55 : : * of the generating plan node to be sure these resources are not released for
56 : : * as long as the virtual tuple needs to be valid or is materialized. Note
57 : : * also that a virtual tuple does not have any "system columns".
58 : : *
59 : : * The Datum/isnull arrays of a TupleTableSlot serve double duty. For virtual
60 : : * slots they are the authoritative data. For the other builtin slots,
61 : : * the arrays contain data extracted from the tuple. (In this state, any
62 : : * pass-by-reference Datums point into the physical tuple.) The extracted
63 : : * information is built "lazily", ie, only as needed. This serves to avoid
64 : : * repeated extraction of data from the physical tuple.
65 : : *
66 : : * A TupleTableSlot can also be "empty", indicated by flag TTS_FLAG_EMPTY set
67 : : * in tts_flags, holding no valid data. This is the only valid state for a
68 : : * freshly-created slot that has not yet had a tuple descriptor assigned to
69 : : * it. In this state, TTS_FLAG_SHOULDFREE should not be set in tts_flags and
70 : : * tts_nvalid should be set to zero.
71 : : *
72 : : * The tupleDescriptor is simply referenced, not copied, by the TupleTableSlot
73 : : * code. The caller of ExecSetSlotDescriptor() is responsible for providing
74 : : * a descriptor that will live as long as the slot does. (Typically, both
75 : : * slots and descriptors are in per-query memory and are freed by memory
76 : : * context deallocation at query end; so it's not worth providing any extra
77 : : * mechanism to do more. However, the slot will increment the tupdesc
78 : : * reference count if a reference-counted tupdesc is supplied.)
79 : : *
80 : : * When TTS_FLAG_SHOULDFREE is set in tts_flags, the physical tuple is "owned"
81 : : * by the slot and should be freed when the slot's reference to the tuple is
82 : : * dropped.
83 : : *
84 : : * tts_values/tts_isnull are allocated either when the slot is created (when
85 : : * the descriptor is provided), or when a descriptor is assigned to the slot;
86 : : * they are of length equal to the descriptor's natts.
87 : : *
88 : : * The TTS_FLAG_SLOW flag is saved state for
89 : : * slot_deform_heap_tuple, and should not be touched by any other code.
90 : : *----------
91 : : */
92 : :
93 : : /* true = slot is empty */
94 : : #define TTS_FLAG_EMPTY (1 << 1)
95 : : #define TTS_EMPTY(slot) (((slot)->tts_flags & TTS_FLAG_EMPTY) != 0)
96 : :
97 : : /* should pfree tuple "owned" by the slot? */
98 : : #define TTS_FLAG_SHOULDFREE (1 << 2)
99 : : #define TTS_SHOULDFREE(slot) (((slot)->tts_flags & TTS_FLAG_SHOULDFREE) != 0)
100 : :
101 : : /* saved state for slot_deform_heap_tuple */
102 : : #define TTS_FLAG_SLOW (1 << 3)
103 : : #define TTS_SLOW(slot) (((slot)->tts_flags & TTS_FLAG_SLOW) != 0)
104 : :
105 : : /* fixed tuple descriptor */
106 : : #define TTS_FLAG_FIXED (1 << 4)
107 : : #define TTS_FIXED(slot) (((slot)->tts_flags & TTS_FLAG_FIXED) != 0)
108 : :
109 : : struct TupleTableSlotOps;
110 : : typedef struct TupleTableSlotOps TupleTableSlotOps;
111 : :
112 : : /* base tuple table slot type */
113 : : typedef struct TupleTableSlot
114 : : {
115 : : NodeTag type;
116 : : #define FIELDNO_TUPLETABLESLOT_FLAGS 1
117 : : uint16 tts_flags; /* Boolean states */
118 : : #define FIELDNO_TUPLETABLESLOT_NVALID 2
119 : : AttrNumber tts_nvalid; /* # of valid values in tts_values */
120 : : const TupleTableSlotOps *const tts_ops; /* implementation of slot */
121 : : #define FIELDNO_TUPLETABLESLOT_TUPLEDESCRIPTOR 4
122 : : TupleDesc tts_tupleDescriptor; /* slot's tuple descriptor */
123 : : #define FIELDNO_TUPLETABLESLOT_VALUES 5
124 : : Datum *tts_values; /* current per-attribute values */
125 : : #define FIELDNO_TUPLETABLESLOT_ISNULL 6
126 : : bool *tts_isnull; /* current per-attribute isnull flags */
127 : : MemoryContext tts_mcxt; /* slot itself is in this context */
128 : : ItemPointerData tts_tid; /* stored tuple's tid */
129 : : Oid tts_tableOid; /* table oid of tuple */
130 : : } TupleTableSlot;
131 : :
132 : : /* routines for a TupleTableSlot implementation */
133 : : struct TupleTableSlotOps
134 : : {
135 : : /* Minimum size of the slot */
136 : : size_t base_slot_size;
137 : :
138 : : /* Initialization. */
139 : : void (*init) (TupleTableSlot *slot);
140 : :
141 : : /* Destruction. */
142 : : void (*release) (TupleTableSlot *slot);
143 : :
144 : : /*
145 : : * Clear the contents of the slot. Only the contents are expected to be
146 : : * cleared and not the tuple descriptor. Typically an implementation of
147 : : * this callback should free the memory allocated for the tuple contained
148 : : * in the slot.
149 : : */
150 : : void (*clear) (TupleTableSlot *slot);
151 : :
152 : : /*
153 : : * Fill up first natts entries of tts_values and tts_isnull arrays with
154 : : * values from the tuple contained in the slot and set the slot's
155 : : * tts_nvalid to natts. The function may be called with an natts value
156 : : * more than the number of attributes available in the tuple, in which
157 : : * case the function must call slot_getmissingattrs() to populate the
158 : : * remaining attributes. The function must raise an ERROR if 'natts' is
159 : : * higher than the number of attributes in the slot's TupleDesc.
160 : : */
161 : : void (*getsomeattrs) (TupleTableSlot *slot, int natts);
162 : :
163 : : /*
164 : : * Returns value of the given system attribute as a datum and sets isnull
165 : : * to false, if it's not NULL. Throws an error if the slot type does not
166 : : * support system attributes.
167 : : */
168 : : Datum (*getsysattr) (TupleTableSlot *slot, int attnum, bool *isnull);
169 : :
170 : : /*
171 : : * Check if the tuple is created by the current transaction. Throws an
172 : : * error if the slot doesn't contain the storage tuple.
173 : : */
174 : : bool (*is_current_xact_tuple) (TupleTableSlot *slot);
175 : :
176 : : /*
177 : : * Make the contents of the slot solely depend on the slot, and not on
178 : : * underlying resources (like another memory context, buffers, etc).
179 : : */
180 : : void (*materialize) (TupleTableSlot *slot);
181 : :
182 : : /*
183 : : * Copy the contents of the source slot into the destination slot's own
184 : : * context. Invoked using callback of the destination slot. 'dstslot' and
185 : : * 'srcslot' can be assumed to have the same number of attributes.
186 : : */
187 : : void (*copyslot) (TupleTableSlot *dstslot, TupleTableSlot *srcslot);
188 : :
189 : : /*
190 : : * Return a heap tuple "owned" by the slot. It is slot's responsibility to
191 : : * free the memory consumed by the heap tuple. If the slot can not "own" a
192 : : * heap tuple, it should not implement this callback and should set it as
193 : : * NULL.
194 : : */
195 : : HeapTuple (*get_heap_tuple) (TupleTableSlot *slot);
196 : :
197 : : /*
198 : : * Return a minimal tuple "owned" by the slot. It is slot's responsibility
199 : : * to free the memory consumed by the minimal tuple. If the slot can not
200 : : * "own" a minimal tuple, it should not implement this callback and should
201 : : * set it as NULL.
202 : : */
203 : : MinimalTuple (*get_minimal_tuple) (TupleTableSlot *slot);
204 : :
205 : : /*
206 : : * Return a copy of heap tuple representing the contents of the slot. The
207 : : * copy needs to be palloc'd in the current memory context. The slot
208 : : * itself is expected to remain unaffected. It is *not* expected to have
209 : : * meaningful "system columns" in the copy. The copy is not be "owned" by
210 : : * the slot i.e. the caller has to take responsibility to free memory
211 : : * consumed by the slot.
212 : : */
213 : : HeapTuple (*copy_heap_tuple) (TupleTableSlot *slot);
214 : :
215 : : /*
216 : : * Return a copy of minimal tuple representing the contents of the slot.
217 : : * The copy needs to be palloc'd in the current memory context. The slot
218 : : * itself is expected to remain unaffected. It is *not* expected to have
219 : : * meaningful "system columns" in the copy. The copy is not be "owned" by
220 : : * the slot i.e. the caller has to take responsibility to free memory
221 : : * consumed by the slot.
222 : : *
223 : : * The copy has "extra" bytes (maxaligned and zeroed) available before the
224 : : * tuple, which is useful so that some callers may store extra data along
225 : : * with the minimal tuple without the need for an additional allocation.
226 : : */
227 : : MinimalTuple (*copy_minimal_tuple) (TupleTableSlot *slot, Size extra);
228 : : };
229 : :
230 : : /*
231 : : * Predefined TupleTableSlotOps for various types of TupleTableSlotOps. The
232 : : * same are used to identify the type of a given slot.
233 : : */
234 : : extern PGDLLIMPORT const TupleTableSlotOps TTSOpsVirtual;
235 : : extern PGDLLIMPORT const TupleTableSlotOps TTSOpsHeapTuple;
236 : : extern PGDLLIMPORT const TupleTableSlotOps TTSOpsMinimalTuple;
237 : : extern PGDLLIMPORT const TupleTableSlotOps TTSOpsBufferHeapTuple;
238 : :
239 : : #define TTS_IS_VIRTUAL(slot) ((slot)->tts_ops == &TTSOpsVirtual)
240 : : #define TTS_IS_HEAPTUPLE(slot) ((slot)->tts_ops == &TTSOpsHeapTuple)
241 : : #define TTS_IS_MINIMALTUPLE(slot) ((slot)->tts_ops == &TTSOpsMinimalTuple)
242 : : #define TTS_IS_BUFFERTUPLE(slot) ((slot)->tts_ops == &TTSOpsBufferHeapTuple)
243 : :
244 : :
245 : : /*
246 : : * Tuple table slot implementations.
247 : : */
248 : :
249 : : typedef struct VirtualTupleTableSlot
250 : : {
251 : : pg_node_attr(abstract)
252 : :
253 : : TupleTableSlot base;
254 : :
255 : : char *data; /* data for materialized slots */
256 : : } VirtualTupleTableSlot;
257 : :
258 : : typedef struct HeapTupleTableSlot
259 : : {
260 : : pg_node_attr(abstract)
261 : :
262 : : TupleTableSlot base;
263 : :
264 : : #define FIELDNO_HEAPTUPLETABLESLOT_TUPLE 1
265 : : HeapTuple tuple; /* physical tuple */
266 : : #define FIELDNO_HEAPTUPLETABLESLOT_OFF 2
267 : : uint32 off; /* saved state for slot_deform_heap_tuple */
268 : : HeapTupleData tupdata; /* optional workspace for storing tuple */
269 : : } HeapTupleTableSlot;
270 : :
271 : : /* heap tuple residing in a buffer */
272 : : typedef struct BufferHeapTupleTableSlot
273 : : {
274 : : pg_node_attr(abstract)
275 : :
276 : : HeapTupleTableSlot base;
277 : :
278 : : /*
279 : : * If buffer is not InvalidBuffer, then the slot is holding a pin on the
280 : : * indicated buffer page; drop the pin when we release the slot's
281 : : * reference to that buffer. (TTS_FLAG_SHOULDFREE should not be set in
282 : : * such a case, since presumably base.tuple is pointing into the buffer.)
283 : : */
284 : : Buffer buffer; /* tuple's buffer, or InvalidBuffer */
285 : : } BufferHeapTupleTableSlot;
286 : :
287 : : typedef struct MinimalTupleTableSlot
288 : : {
289 : : pg_node_attr(abstract)
290 : :
291 : : TupleTableSlot base;
292 : :
293 : : /*
294 : : * In a minimal slot tuple points at minhdr and the fields of that struct
295 : : * are set correctly for access to the minimal tuple; in particular,
296 : : * minhdr.t_data points MINIMAL_TUPLE_OFFSET bytes before mintuple. This
297 : : * allows column extraction to treat the case identically to regular
298 : : * physical tuples.
299 : : */
300 : : #define FIELDNO_MINIMALTUPLETABLESLOT_TUPLE 1
301 : : HeapTuple tuple; /* tuple wrapper */
302 : : MinimalTuple mintuple; /* minimal tuple, or NULL if none */
303 : : HeapTupleData minhdr; /* workspace for minimal-tuple-only case */
304 : : #define FIELDNO_MINIMALTUPLETABLESLOT_OFF 4
305 : : uint32 off; /* saved state for slot_deform_heap_tuple */
306 : : } MinimalTupleTableSlot;
307 : :
308 : : /*
309 : : * TupIsNull -- is a TupleTableSlot empty?
310 : : */
311 : : #define TupIsNull(slot) \
312 : : ((slot) == NULL || TTS_EMPTY(slot))
313 : :
314 : : /* in executor/execTuples.c */
315 : : extern TupleTableSlot *MakeTupleTableSlot(TupleDesc tupleDesc,
316 : : const TupleTableSlotOps *tts_ops);
317 : : extern TupleTableSlot *ExecAllocTableSlot(List **tupleTable, TupleDesc desc,
318 : : const TupleTableSlotOps *tts_ops);
319 : : extern void ExecResetTupleTable(List *tupleTable, bool shouldFree);
320 : : extern TupleTableSlot *MakeSingleTupleTableSlot(TupleDesc tupdesc,
321 : : const TupleTableSlotOps *tts_ops);
322 : : extern void ExecDropSingleTupleTableSlot(TupleTableSlot *slot);
323 : : extern void ExecSetSlotDescriptor(TupleTableSlot *slot, TupleDesc tupdesc);
324 : : extern TupleTableSlot *ExecStoreHeapTuple(HeapTuple tuple,
325 : : TupleTableSlot *slot,
326 : : bool shouldFree);
327 : : extern void ExecForceStoreHeapTuple(HeapTuple tuple,
328 : : TupleTableSlot *slot,
329 : : bool shouldFree);
330 : : extern TupleTableSlot *ExecStoreBufferHeapTuple(HeapTuple tuple,
331 : : TupleTableSlot *slot,
332 : : Buffer buffer);
333 : : extern TupleTableSlot *ExecStorePinnedBufferHeapTuple(HeapTuple tuple,
334 : : TupleTableSlot *slot,
335 : : Buffer buffer);
336 : : extern TupleTableSlot *ExecStoreMinimalTuple(MinimalTuple mtup,
337 : : TupleTableSlot *slot,
338 : : bool shouldFree);
339 : : extern void ExecForceStoreMinimalTuple(MinimalTuple mtup, TupleTableSlot *slot,
340 : : bool shouldFree);
341 : : extern TupleTableSlot *ExecStoreVirtualTuple(TupleTableSlot *slot);
342 : : extern TupleTableSlot *ExecStoreAllNullTuple(TupleTableSlot *slot);
343 : : extern void ExecStoreHeapTupleDatum(Datum data, TupleTableSlot *slot);
344 : : extern HeapTuple ExecFetchSlotHeapTuple(TupleTableSlot *slot, bool materialize, bool *shouldFree);
345 : : extern MinimalTuple ExecFetchSlotMinimalTuple(TupleTableSlot *slot,
346 : : bool *shouldFree);
347 : : extern Datum ExecFetchSlotHeapTupleDatum(TupleTableSlot *slot);
348 : : extern void slot_getmissingattrs(TupleTableSlot *slot, int startAttNum,
349 : : int lastAttNum);
350 : : extern void slot_getsomeattrs_int(TupleTableSlot *slot, int attnum);
351 : :
352 : :
353 : : #ifndef FRONTEND
354 : :
355 : : /*
356 : : * This function forces the entries of the slot's Datum/isnull arrays to be
357 : : * valid at least up through the attnum'th entry.
358 : : */
359 : : static inline void
2676 andres@anarazel.de 360 :CBC 148979964 : slot_getsomeattrs(TupleTableSlot *slot, int attnum)
361 : : {
362 : : /* Populate slot with attributes up to 'attnum', if it's not already */
363 [ + + ]: 148979964 : if (slot->tts_nvalid < attnum)
1 drowley@postgresql.o 364 :GNC 113290968 : slot->tts_ops->getsomeattrs(slot, attnum);
2676 andres@anarazel.de 365 :CBC 148979964 : }
366 : :
367 : : /*
368 : : * slot_getallattrs
369 : : * This function forces all the entries of the slot's Datum/isnull
370 : : * arrays to be valid. The caller may then extract data directly
371 : : * from those arrays instead of using slot_getattr.
372 : : */
373 : : static inline void
2761 374 : 10239350 : slot_getallattrs(TupleTableSlot *slot)
375 : : {
376 : 10239350 : slot_getsomeattrs(slot, slot->tts_tupleDescriptor->natts);
377 : 10239350 : }
378 : :
379 : :
380 : : /*
381 : : * slot_attisnull
382 : : *
383 : : * Detect whether an attribute of the slot is null, without actually fetching
384 : : * it.
385 : : */
386 : : static inline bool
2676 387 : 6763181 : slot_attisnull(TupleTableSlot *slot, int attnum)
388 : : {
1234 peter@eisentraut.org 389 [ - + ]: 6763181 : Assert(attnum > 0);
390 : :
2676 andres@anarazel.de 391 [ + + ]: 6763181 : if (attnum > slot->tts_nvalid)
392 : 5397970 : slot_getsomeattrs(slot, attnum);
393 : :
394 : 6763181 : return slot->tts_isnull[attnum - 1];
395 : : }
396 : :
397 : : /*
398 : : * slot_getattr - fetch one attribute of the slot's contents.
399 : : */
400 : : static inline Datum
401 : 37644987 : slot_getattr(TupleTableSlot *slot, int attnum,
402 : : bool *isnull)
403 : : {
1234 peter@eisentraut.org 404 [ - + ]: 37644987 : Assert(attnum > 0);
405 : :
2676 andres@anarazel.de 406 [ + + ]: 37644987 : if (attnum > slot->tts_nvalid)
407 : 29049617 : slot_getsomeattrs(slot, attnum);
408 : :
409 : 37644987 : *isnull = slot->tts_isnull[attnum - 1];
410 : :
411 : 37644987 : return slot->tts_values[attnum - 1];
412 : : }
413 : :
414 : : /*
415 : : * slot_getsysattr - fetch a system attribute of the slot's current tuple.
416 : : *
417 : : * If the slot type does not contain system attributes, this will throw an
418 : : * error. Hence before calling this function, callers should make sure that
419 : : * the slot type is the one that supports system attributes.
420 : : */
421 : : static inline Datum
422 : 4902289 : slot_getsysattr(TupleTableSlot *slot, int attnum, bool *isnull)
423 : : {
1031 tgl@sss.pgh.pa.us 424 [ - + ]: 4902289 : Assert(attnum < 0); /* caller error */
425 : :
2574 andres@anarazel.de 426 [ + + ]: 4902289 : if (attnum == TableOidAttributeNumber)
427 : : {
428 : 2099529 : *isnull = false;
429 : 2099529 : return ObjectIdGetDatum(slot->tts_tableOid);
430 : : }
431 [ + + ]: 2802760 : else if (attnum == SelfItemPointerAttributeNumber)
432 : : {
433 : 2730041 : *isnull = false;
434 : 2730041 : return PointerGetDatum(&slot->tts_tid);
435 : : }
436 : :
437 : : /* Fetch the system attribute from the underlying tuple. */
2676 438 : 72719 : return slot->tts_ops->getsysattr(slot, attnum, isnull);
439 : : }
440 : :
441 : : /*
442 : : * slot_is_current_xact_tuple - check if the slot's current tuple is created
443 : : * by the current transaction.
444 : : *
445 : : * If the slot does not contain a storage tuple, this will throw an error.
446 : : * Hence before calling this function, callers should make sure that the
447 : : * slot type supports storage tuples and that there is currently one inside
448 : : * the slot.
449 : : */
450 : : static inline bool
724 akorotkov@postgresql 451 : 465 : slot_is_current_xact_tuple(TupleTableSlot *slot)
452 : : {
453 : 465 : return slot->tts_ops->is_current_xact_tuple(slot);
454 : : }
455 : :
456 : : /*
457 : : * ExecClearTuple - clear the slot's contents
458 : : */
459 : : static inline TupleTableSlot *
2676 andres@anarazel.de 460 : 87052235 : ExecClearTuple(TupleTableSlot *slot)
461 : : {
462 : 87052235 : slot->tts_ops->clear(slot);
463 : :
464 : 87052235 : return slot;
465 : : }
466 : :
467 : : /* ExecMaterializeSlot - force a slot into the "materialized" state.
468 : : *
469 : : * This causes the slot's tuple to be a local copy not dependent on any
470 : : * external storage (i.e. pointing into a Buffer, or having allocations in
471 : : * another memory context).
472 : : *
473 : : * A typical use for this operation is to prepare a computed tuple for being
474 : : * stored on disk. The original data may or may not be virtual, but in any
475 : : * case we need a private copy for heap_insert to scribble on.
476 : : */
477 : : static inline void
478 : 8877720 : ExecMaterializeSlot(TupleTableSlot *slot)
479 : : {
480 : 8877720 : slot->tts_ops->materialize(slot);
481 : 8877720 : }
482 : :
483 : : /*
484 : : * ExecCopySlotHeapTuple - return HeapTuple allocated in caller's context
485 : : */
486 : : static inline HeapTuple
487 : 13401584 : ExecCopySlotHeapTuple(TupleTableSlot *slot)
488 : : {
489 [ - + ]: 13401584 : Assert(!TTS_EMPTY(slot));
490 : :
491 : 13401584 : return slot->tts_ops->copy_heap_tuple(slot);
492 : : }
493 : :
494 : : /*
495 : : * ExecCopySlotMinimalTuple - return MinimalTuple allocated in caller's context
496 : : */
497 : : static inline MinimalTuple
498 : 9061522 : ExecCopySlotMinimalTuple(TupleTableSlot *slot)
499 : : {
356 jdavis@postgresql.or 500 : 9061522 : return slot->tts_ops->copy_minimal_tuple(slot, 0);
501 : : }
502 : :
503 : : /*
504 : : * ExecCopySlotMinimalTupleExtra - return MinimalTuple allocated in caller's
505 : : * context, with extra bytes (maxaligned and zeroed) before the tuple for data
506 : : * the caller wishes to store along with the tuple (without requiring the
507 : : * caller to make an additional allocation).
508 : : */
509 : : static inline MinimalTuple
510 : 519335 : ExecCopySlotMinimalTupleExtra(TupleTableSlot *slot, Size extra)
511 : : {
512 : 519335 : return slot->tts_ops->copy_minimal_tuple(slot, extra);
513 : : }
514 : :
515 : : /*
516 : : * ExecCopySlot - copy one slot's contents into another.
517 : : *
518 : : * If a source's system attributes are supposed to be accessed in the target
519 : : * slot, the target slot and source slot types need to match.
520 : : *
521 : : * Currently, 'dstslot' and 'srcslot' must have the same number of attributes.
522 : : * Future work could see this relaxed to allow the source to contain
523 : : * additional attributes and have the code here only copy over the leading
524 : : * attributes.
525 : : */
526 : : static inline TupleTableSlot *
2676 andres@anarazel.de 527 : 7239629 : ExecCopySlot(TupleTableSlot *dstslot, TupleTableSlot *srcslot)
528 : : {
529 [ - + ]: 7239629 : Assert(!TTS_EMPTY(srcslot));
1234 peter@eisentraut.org 530 [ - + ]: 7239629 : Assert(srcslot != dstslot);
829 drowley@postgresql.o 531 [ - + ]: 7239629 : Assert(dstslot->tts_tupleDescriptor->natts ==
532 : : srcslot->tts_tupleDescriptor->natts);
533 : :
2676 andres@anarazel.de 534 : 7239629 : dstslot->tts_ops->copyslot(dstslot, srcslot);
535 : :
536 : 7239629 : return dstslot;
537 : : }
538 : :
539 : : #endif /* FRONTEND */
540 : :
541 : : #endif /* TUPTABLE_H */
|