PostgreSQL Source Code git master
Loading...
Searching...
No Matches
tuptable.h File Reference
#include "access/htup.h"
#include "access/sysattr.h"
#include "access/tupdesc.h"
#include "storage/buf.h"
Include dependency graph for tuptable.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  TupleTableSlot
 
struct  TupleTableSlotOps
 
struct  VirtualTupleTableSlot
 
struct  HeapTupleTableSlot
 
struct  BufferHeapTupleTableSlot
 
struct  MinimalTupleTableSlot
 

Macros

#define TTS_FLAG_EMPTY   (1 << 1)
 
#define TTS_EMPTY(slot)   (((slot)->tts_flags & TTS_FLAG_EMPTY) != 0)
 
#define TTS_FLAG_SHOULDFREE   (1 << 2)
 
#define TTS_SHOULDFREE(slot)   (((slot)->tts_flags & TTS_FLAG_SHOULDFREE) != 0)
 
#define TTS_FLAG_SLOW   (1 << 3)
 
#define TTS_SLOW(slot)   (((slot)->tts_flags & TTS_FLAG_SLOW) != 0)
 
#define TTS_FLAG_FIXED   (1 << 4)
 
#define TTS_FIXED(slot)   (((slot)->tts_flags & TTS_FLAG_FIXED) != 0)
 
#define FIELDNO_TUPLETABLESLOT_FLAGS   1
 
#define FIELDNO_TUPLETABLESLOT_NVALID   2
 
#define FIELDNO_TUPLETABLESLOT_TUPLEDESCRIPTOR   4
 
#define FIELDNO_TUPLETABLESLOT_VALUES   5
 
#define FIELDNO_TUPLETABLESLOT_ISNULL   6
 
#define TTS_IS_VIRTUAL(slot)   ((slot)->tts_ops == &TTSOpsVirtual)
 
#define TTS_IS_HEAPTUPLE(slot)   ((slot)->tts_ops == &TTSOpsHeapTuple)
 
#define TTS_IS_MINIMALTUPLE(slot)   ((slot)->tts_ops == &TTSOpsMinimalTuple)
 
#define TTS_IS_BUFFERTUPLE(slot)   ((slot)->tts_ops == &TTSOpsBufferHeapTuple)
 
#define FIELDNO_HEAPTUPLETABLESLOT_TUPLE   1
 
#define FIELDNO_HEAPTUPLETABLESLOT_OFF   2
 
#define FIELDNO_MINIMALTUPLETABLESLOT_TUPLE   1
 
#define FIELDNO_MINIMALTUPLETABLESLOT_OFF   4
 
#define TupIsNull(slot)    ((slot) == NULL || TTS_EMPTY(slot))
 

Typedefs

typedef struct TupleTableSlotOps TupleTableSlotOps
 
typedef struct TupleTableSlot TupleTableSlot
 
typedef struct VirtualTupleTableSlot VirtualTupleTableSlot
 
typedef struct HeapTupleTableSlot HeapTupleTableSlot
 
typedef struct BufferHeapTupleTableSlot BufferHeapTupleTableSlot
 
typedef struct MinimalTupleTableSlot MinimalTupleTableSlot
 

Functions

TupleTableSlotMakeTupleTableSlot (TupleDesc tupleDesc, const TupleTableSlotOps *tts_ops)
 
TupleTableSlotExecAllocTableSlot (List **tupleTable, TupleDesc desc, const TupleTableSlotOps *tts_ops)
 
void ExecResetTupleTable (List *tupleTable, bool shouldFree)
 
TupleTableSlotMakeSingleTupleTableSlot (TupleDesc tupdesc, const TupleTableSlotOps *tts_ops)
 
void ExecDropSingleTupleTableSlot (TupleTableSlot *slot)
 
void ExecSetSlotDescriptor (TupleTableSlot *slot, TupleDesc tupdesc)
 
TupleTableSlotExecStoreHeapTuple (HeapTuple tuple, TupleTableSlot *slot, bool shouldFree)
 
void ExecForceStoreHeapTuple (HeapTuple tuple, TupleTableSlot *slot, bool shouldFree)
 
TupleTableSlotExecStoreBufferHeapTuple (HeapTuple tuple, TupleTableSlot *slot, Buffer buffer)
 
TupleTableSlotExecStorePinnedBufferHeapTuple (HeapTuple tuple, TupleTableSlot *slot, Buffer buffer)
 
TupleTableSlotExecStoreMinimalTuple (MinimalTuple mtup, TupleTableSlot *slot, bool shouldFree)
 
void ExecForceStoreMinimalTuple (MinimalTuple mtup, TupleTableSlot *slot, bool shouldFree)
 
TupleTableSlotExecStoreVirtualTuple (TupleTableSlot *slot)
 
TupleTableSlotExecStoreAllNullTuple (TupleTableSlot *slot)
 
void ExecStoreHeapTupleDatum (Datum data, TupleTableSlot *slot)
 
HeapTuple ExecFetchSlotHeapTuple (TupleTableSlot *slot, bool materialize, bool *shouldFree)
 
MinimalTuple ExecFetchSlotMinimalTuple (TupleTableSlot *slot, bool *shouldFree)
 
Datum ExecFetchSlotHeapTupleDatum (TupleTableSlot *slot)
 
void slot_getmissingattrs (TupleTableSlot *slot, int startAttNum, int lastAttNum)
 
void slot_getsomeattrs_int (TupleTableSlot *slot, int attnum)
 
static void slot_getsomeattrs (TupleTableSlot *slot, int attnum)
 
static void slot_getallattrs (TupleTableSlot *slot)
 
static bool slot_attisnull (TupleTableSlot *slot, int attnum)
 
static Datum slot_getattr (TupleTableSlot *slot, int attnum, bool *isnull)
 
static Datum slot_getsysattr (TupleTableSlot *slot, int attnum, bool *isnull)
 
static bool slot_is_current_xact_tuple (TupleTableSlot *slot)
 
static TupleTableSlotExecClearTuple (TupleTableSlot *slot)
 
static void ExecMaterializeSlot (TupleTableSlot *slot)
 
static HeapTuple ExecCopySlotHeapTuple (TupleTableSlot *slot)
 
static MinimalTuple ExecCopySlotMinimalTuple (TupleTableSlot *slot)
 
static MinimalTuple ExecCopySlotMinimalTupleExtra (TupleTableSlot *slot, Size extra)
 
static TupleTableSlotExecCopySlot (TupleTableSlot *dstslot, TupleTableSlot *srcslot)
 

Variables

PGDLLIMPORT const TupleTableSlotOps TTSOpsVirtual
 
PGDLLIMPORT const TupleTableSlotOps TTSOpsHeapTuple
 
PGDLLIMPORT const TupleTableSlotOps TTSOpsMinimalTuple
 
PGDLLIMPORT const TupleTableSlotOps TTSOpsBufferHeapTuple
 

Macro Definition Documentation

◆ FIELDNO_HEAPTUPLETABLESLOT_OFF

#define FIELDNO_HEAPTUPLETABLESLOT_OFF   2

Definition at line 264 of file tuptable.h.

◆ FIELDNO_HEAPTUPLETABLESLOT_TUPLE

#define FIELDNO_HEAPTUPLETABLESLOT_TUPLE   1

Definition at line 262 of file tuptable.h.

◆ FIELDNO_MINIMALTUPLETABLESLOT_OFF

#define FIELDNO_MINIMALTUPLETABLESLOT_OFF   4

Definition at line 302 of file tuptable.h.

◆ FIELDNO_MINIMALTUPLETABLESLOT_TUPLE

#define FIELDNO_MINIMALTUPLETABLESLOT_TUPLE   1

Definition at line 298 of file tuptable.h.

◆ FIELDNO_TUPLETABLESLOT_FLAGS

#define FIELDNO_TUPLETABLESLOT_FLAGS   1

Definition at line 116 of file tuptable.h.

◆ FIELDNO_TUPLETABLESLOT_ISNULL

#define FIELDNO_TUPLETABLESLOT_ISNULL   6

Definition at line 125 of file tuptable.h.

◆ FIELDNO_TUPLETABLESLOT_NVALID

#define FIELDNO_TUPLETABLESLOT_NVALID   2

Definition at line 118 of file tuptable.h.

◆ FIELDNO_TUPLETABLESLOT_TUPLEDESCRIPTOR

#define FIELDNO_TUPLETABLESLOT_TUPLEDESCRIPTOR   4

Definition at line 121 of file tuptable.h.

◆ FIELDNO_TUPLETABLESLOT_VALUES

#define FIELDNO_TUPLETABLESLOT_VALUES   5

Definition at line 123 of file tuptable.h.

◆ TTS_EMPTY

#define TTS_EMPTY (   slot)    (((slot)->tts_flags & TTS_FLAG_EMPTY) != 0)

Definition at line 95 of file tuptable.h.

◆ TTS_FIXED

#define TTS_FIXED (   slot)    (((slot)->tts_flags & TTS_FLAG_FIXED) != 0)

Definition at line 107 of file tuptable.h.

◆ TTS_FLAG_EMPTY

#define TTS_FLAG_EMPTY   (1 << 1)

Definition at line 94 of file tuptable.h.

◆ TTS_FLAG_FIXED

#define TTS_FLAG_FIXED   (1 << 4)

Definition at line 106 of file tuptable.h.

◆ TTS_FLAG_SHOULDFREE

#define TTS_FLAG_SHOULDFREE   (1 << 2)

Definition at line 98 of file tuptable.h.

◆ TTS_FLAG_SLOW

#define TTS_FLAG_SLOW   (1 << 3)

Definition at line 102 of file tuptable.h.

◆ TTS_IS_BUFFERTUPLE

#define TTS_IS_BUFFERTUPLE (   slot)    ((slot)->tts_ops == &TTSOpsBufferHeapTuple)

Definition at line 240 of file tuptable.h.

◆ TTS_IS_HEAPTUPLE

#define TTS_IS_HEAPTUPLE (   slot)    ((slot)->tts_ops == &TTSOpsHeapTuple)

Definition at line 238 of file tuptable.h.

◆ TTS_IS_MINIMALTUPLE

#define TTS_IS_MINIMALTUPLE (   slot)    ((slot)->tts_ops == &TTSOpsMinimalTuple)

Definition at line 239 of file tuptable.h.

◆ TTS_IS_VIRTUAL

#define TTS_IS_VIRTUAL (   slot)    ((slot)->tts_ops == &TTSOpsVirtual)

Definition at line 237 of file tuptable.h.

◆ TTS_SHOULDFREE

#define TTS_SHOULDFREE (   slot)    (((slot)->tts_flags & TTS_FLAG_SHOULDFREE) != 0)

Definition at line 99 of file tuptable.h.

◆ TTS_SLOW

#define TTS_SLOW (   slot)    (((slot)->tts_flags & TTS_FLAG_SLOW) != 0)

Definition at line 103 of file tuptable.h.

◆ TupIsNull

#define TupIsNull (   slot)     ((slot) == NULL || TTS_EMPTY(slot))

Definition at line 309 of file tuptable.h.

358{
359 if (slot->tts_nvalid < attnum)
361}
362
363/*
364 * slot_getallattrs
365 * This function forces all the entries of the slot's Datum/isnull
366 * arrays to be valid. The caller may then extract data directly
367 * from those arrays instead of using slot_getattr.
368 */
369static inline void
371{
373}
374
375
376/*
377 * slot_attisnull
378 *
379 * Detect whether an attribute of the slot is null, without actually fetching
380 * it.
381 */
382static inline bool
384{
385 Assert(attnum > 0);
386
387 if (attnum > slot->tts_nvalid)
389
390 return slot->tts_isnull[attnum - 1];
391}
392
393/*
394 * slot_getattr - fetch one attribute of the slot's contents.
395 */
396static inline Datum
398 bool *isnull)
399{
400 Assert(attnum > 0);
401
402 if (attnum > slot->tts_nvalid)
404
405 *isnull = slot->tts_isnull[attnum - 1];
406
407 return slot->tts_values[attnum - 1];
408}
409
410/*
411 * slot_getsysattr - fetch a system attribute of the slot's current tuple.
412 *
413 * If the slot type does not contain system attributes, this will throw an
414 * error. Hence before calling this function, callers should make sure that
415 * the slot type is the one that supports system attributes.
416 */
417static inline Datum
418slot_getsysattr(TupleTableSlot *slot, int attnum, bool *isnull)
419{
420 Assert(attnum < 0); /* caller error */
421
423 {
424 *isnull = false;
425 return ObjectIdGetDatum(slot->tts_tableOid);
426 }
428 {
429 *isnull = false;
430 return PointerGetDatum(&slot->tts_tid);
431 }
432
433 /* Fetch the system attribute from the underlying tuple. */
434 return slot->tts_ops->getsysattr(slot, attnum, isnull);
435}
436
437/*
438 * slot_is_current_xact_tuple - check if the slot's current tuple is created
439 * by the current transaction.
440 *
441 * If the slot does not contain a storage tuple, this will throw an error.
442 * Hence before calling this function, callers should make sure that the
443 * slot type supports storage tuples and that there is currently one inside
444 * the slot.
445 */
446static inline bool
448{
449 return slot->tts_ops->is_current_xact_tuple(slot);
450}
451
452/*
453 * ExecClearTuple - clear the slot's contents
454 */
455static inline TupleTableSlot *
457{
458 slot->tts_ops->clear(slot);
459
460 return slot;
461}
462
463/* ExecMaterializeSlot - force a slot into the "materialized" state.
464 *
465 * This causes the slot's tuple to be a local copy not dependent on any
466 * external storage (i.e. pointing into a Buffer, or having allocations in
467 * another memory context).
468 *
469 * A typical use for this operation is to prepare a computed tuple for being
470 * stored on disk. The original data may or may not be virtual, but in any
471 * case we need a private copy for heap_insert to scribble on.
472 */
473static inline void
475{
476 slot->tts_ops->materialize(slot);
477}
478
479/*
480 * ExecCopySlotHeapTuple - return HeapTuple allocated in caller's context
481 */
482static inline HeapTuple
484{
485 Assert(!TTS_EMPTY(slot));
486
487 return slot->tts_ops->copy_heap_tuple(slot);
488}
489
490/*
491 * ExecCopySlotMinimalTuple - return MinimalTuple allocated in caller's context
492 */
493static inline MinimalTuple
495{
496 return slot->tts_ops->copy_minimal_tuple(slot, 0);
497}
498
499/*
500 * ExecCopySlotMinimalTupleExtra - return MinimalTuple allocated in caller's
501 * context, with extra bytes (maxaligned and zeroed) before the tuple for data
502 * the caller wishes to store along with the tuple (without requiring the
503 * caller to make an additional allocation).
504 */
505static inline MinimalTuple
507{
508 return slot->tts_ops->copy_minimal_tuple(slot, extra);
509}
510
511/*
512 * ExecCopySlot - copy one slot's contents into another.
513 *
514 * If a source's system attributes are supposed to be accessed in the target
515 * slot, the target slot and source slot types need to match.
516 *
517 * Currently, 'dstslot' and 'srcslot' must have the same number of attributes.
518 * Future work could see this relaxed to allow the source to contain
519 * additional attributes and have the code here only copy over the leading
520 * attributes.
521 */
522static inline TupleTableSlot *
524{
526 Assert(srcslot != dstslot);
527 Assert(dstslot->tts_tupleDescriptor->natts ==
528 srcslot->tts_tupleDescriptor->natts);
529
530 dstslot->tts_ops->copyslot(dstslot, srcslot);
531
532 return dstslot;
533}
534
535#endif /* FRONTEND */
536
537#endif /* TUPTABLE_H */
#define Assert(condition)
Definition c.h:873
size_t Size
Definition c.h:619
int16 attnum
static Datum PointerGetDatum(const void *X)
Definition postgres.h:352
static Datum ObjectIdGetDatum(Oid X)
Definition postgres.h:262
uint64_t Datum
Definition postgres.h:70
static int fb(int x)
Datum(* getsysattr)(TupleTableSlot *slot, int attnum, bool *isnull)
Definition tuptable.h:166
bool(* is_current_xact_tuple)(TupleTableSlot *slot)
Definition tuptable.h:172
MinimalTuple(* copy_minimal_tuple)(TupleTableSlot *slot, Size extra)
Definition tuptable.h:225
void(* copyslot)(TupleTableSlot *dstslot, TupleTableSlot *srcslot)
Definition tuptable.h:185
HeapTuple(* copy_heap_tuple)(TupleTableSlot *slot)
Definition tuptable.h:211
void(* clear)(TupleTableSlot *slot)
Definition tuptable.h:150
void(* materialize)(TupleTableSlot *slot)
Definition tuptable.h:178
TupleDesc tts_tupleDescriptor
Definition tuptable.h:122
const TupleTableSlotOps *const tts_ops
Definition tuptable.h:120
AttrNumber tts_nvalid
Definition tuptable.h:119
bool * tts_isnull
Definition tuptable.h:126
ItemPointerData tts_tid
Definition tuptable.h:128
Datum * tts_values
Definition tuptable.h:124
#define TableOidAttributeNumber
Definition sysattr.h:26
#define SelfItemPointerAttributeNumber
Definition sysattr.h:21
static MinimalTuple ExecCopySlotMinimalTuple(TupleTableSlot *slot)
Definition tuptable.h:495
#define TTS_EMPTY(slot)
Definition tuptable.h:95
static void slot_getsomeattrs(TupleTableSlot *slot, int attnum)
Definition tuptable.h:358
static HeapTuple ExecCopySlotHeapTuple(TupleTableSlot *slot)
Definition tuptable.h:484
static Datum slot_getsysattr(TupleTableSlot *slot, int attnum, bool *isnull)
Definition tuptable.h:419
static Datum slot_getattr(TupleTableSlot *slot, int attnum, bool *isnull)
Definition tuptable.h:398
static bool slot_is_current_xact_tuple(TupleTableSlot *slot)
Definition tuptable.h:448
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition tuptable.h:457
static MinimalTuple ExecCopySlotMinimalTupleExtra(TupleTableSlot *slot, Size extra)
Definition tuptable.h:507
static void slot_getallattrs(TupleTableSlot *slot)
Definition tuptable.h:371
void slot_getsomeattrs_int(TupleTableSlot *slot, int attnum)
static TupleTableSlot * ExecCopySlot(TupleTableSlot *dstslot, TupleTableSlot *srcslot)
Definition tuptable.h:524
static void ExecMaterializeSlot(TupleTableSlot *slot)
Definition tuptable.h:475
static bool slot_attisnull(TupleTableSlot *slot, int attnum)
Definition tuptable.h:384

Typedef Documentation

◆ BufferHeapTupleTableSlot

◆ HeapTupleTableSlot

◆ MinimalTupleTableSlot

◆ TupleTableSlot

◆ TupleTableSlotOps

◆ VirtualTupleTableSlot

Function Documentation

◆ ExecAllocTableSlot()

TupleTableSlot * ExecAllocTableSlot ( List **  tupleTable,
TupleDesc  desc,
const TupleTableSlotOps tts_ops 
)
extern

Definition at line 1360 of file execTuples.c.

1362{
1363 TupleTableSlot *slot = MakeTupleTableSlot(desc, tts_ops);
1364
1365 *tupleTable = lappend(*tupleTable, slot);
1366
1367 return slot;
1368}
TupleTableSlot * MakeTupleTableSlot(TupleDesc tupleDesc, const TupleTableSlotOps *tts_ops)
List * lappend(List *list, void *datum)
Definition list.c:339

References fb(), lappend(), and MakeTupleTableSlot().

Referenced by ExecInitExtraTupleSlot(), ExecInitIndexOnlyScan(), ExecInitResultSlot(), ExecInitScanTupleSlot(), and find_hash_columns().

◆ ExecClearTuple()

static TupleTableSlot * ExecClearTuple ( TupleTableSlot slot)
inlinestatic

Definition at line 457 of file tuptable.h.

458{
459 slot->tts_ops->clear(slot);
460
461 return slot;
462}

References TupleTableSlotOps::clear, and TupleTableSlot::tts_ops.

Referenced by AfterTriggerExecute(), agg_retrieve_hash_table_in_memory(), apply_returning_filter(), ATRewriteTable(), begin_partition(), BitmapHeapNext(), buildSubPlanHash(), check_publications(), check_publications_origin_sequences(), check_publications_origin_tables(), CopyFrom(), CopyMultiInsertBufferFlush(), copyTemplateDependencies(), CteScanNext(), DefineTSConfiguration(), do_tup_output(), EnumValuesCreate(), eval_windowaggregates(), EvalPlanQual(), ExecAppend(), ExecAppendAsyncGetNext(), ExecARUpdateTriggers(), ExecBatchInsert(), ExecCheckTIDVisible(), ExecComputeStoredGenerated(), ExecDelete(), ExecDropSingleTupleTableSlot(), ExecEvalAggOrderedTransTuple(), ExecEvalPreOrderedDistinctMulti(), ExecFilterJunk(), ExecFindPartition(), ExecForceStoreHeapTuple(), ExecForceStoreMinimalTuple(), ExecHashJoinGetSavedTuple(), ExecHashSubPlan(), ExecIncrementalSort(), ExecInsert(), ExecLockRows(), ExecMaterial(), ExecMergeAppend(), ExecOnConflictUpdate(), ExecParallelHashJoinOuterGetTuple(), ExecProject(), ExecProjectSRF(), ExecReScanAgg(), ExecReScanCteScan(), ExecReScanFunctionScan(), ExecReScanGroup(), ExecReScanIncrementalSort(), ExecReScanMaterial(), ExecReScanMergeJoin(), ExecReScanNamedTuplestoreScan(), ExecReScanSetOp(), ExecReScanSort(), ExecReScanTableFuncScan(), ExecReScanUnique(), ExecReScanValuesScan(), ExecReScanWindowAgg(), ExecReScanWorkTableScan(), ExecResetTupleTable(), ExecScanExtended(), ExecScanFetch(), ExecScanReScan(), ExecSetSlotDescriptor(), ExecSort(), ExecStoreAllNullTuple(), ExecStoreHeapTupleDatum(), ExecUnique(), execute_attr_map_slot(), ExecWindowAgg(), fetch_relation_list(), fetch_remote_slots(), fetch_remote_table_info(), fileIterateForeignScan(), finalize_aggregates(), FunctionNext(), gather_getnext(), gather_merge_clear_tuples(), gather_merge_init(), get_actual_variable_endpoint(), get_returning_data(), hashagg_spill_tuple(), heap_getnextslot(), heap_getnextslot_tidrange(), heapam_scan_analyze_next_tuple(), heapam_scan_sample_next_tuple(), hypothetical_dense_rank_final(), hypothetical_rank_common(), IndexNext(), IndexNextWithReorder(), IndexOnlyNext(), InsertPgAttributeTuples(), MakeConfigurationMapping(), MergePartitionsMoveRows(), ordered_set_shutdown(), ordered_set_transition_multi(), pgoutput_row_filter(), postgresIterateDirectModify(), postgresIterateForeignScan(), postquel_get_single_result(), postquel_start(), prepare_hash_slot(), prepare_probe_slot(), process_ordered_aggregate_multi(), recordMultipleDependencies(), RunFromStore(), setop_load_group(), setop_retrieve_hash_table(), setop_retrieve_sorted(), ShutdownSetExpr(), slot_modify_data(), slot_store_data(), SplitPartitionMoveRows(), StoreIndexTuple(), switchToPresortedPrefixMode(), tablesample_getnext(), tfuncLoadRows(), TidNext(), TidRangeNext(), tts_buffer_heap_copyslot(), tuplesort_gettupleslot(), tuplestore_gettupleslot(), update_frameheadpos(), update_frametailpos(), update_grouptailpos(), validate_remote_info(), ValuesNext(), and WinRowsArePeers().

◆ ExecCopySlot()

◆ ExecCopySlotHeapTuple()

◆ ExecCopySlotMinimalTuple()

static MinimalTuple ExecCopySlotMinimalTuple ( TupleTableSlot slot)
inlinestatic

◆ ExecCopySlotMinimalTupleExtra()

static MinimalTuple ExecCopySlotMinimalTupleExtra ( TupleTableSlot slot,
Size  extra 
)
inlinestatic

Definition at line 507 of file tuptable.h.

508{
509 return slot->tts_ops->copy_minimal_tuple(slot, extra);
510}

References TupleTableSlotOps::copy_minimal_tuple, and TupleTableSlot::tts_ops.

Referenced by LookupTupleHashEntry_internal().

◆ ExecDropSingleTupleTableSlot()

void ExecDropSingleTupleTableSlot ( TupleTableSlot slot)
extern

Definition at line 1443 of file execTuples.c.

1444{
1445 /* This should match ExecResetTupleTable's processing of one slot */
1446 Assert(IsA(slot, TupleTableSlot));
1447 ExecClearTuple(slot);
1448 slot->tts_ops->release(slot);
1449 if (slot->tts_tupleDescriptor)
1451 if (!TTS_FIXED(slot))
1452 {
1453 if (slot->tts_values)
1454 pfree(slot->tts_values);
1455 if (slot->tts_isnull)
1456 pfree(slot->tts_isnull);
1457 }
1458 pfree(slot);
1459}
void pfree(void *pointer)
Definition mcxt.c:1616
#define IsA(nodeptr, _type_)
Definition nodes.h:164
void(* release)(TupleTableSlot *slot)
Definition tuptable.h:142
#define ReleaseTupleDesc(tupdesc)
Definition tupdesc.h:219
#define TTS_FIXED(slot)
Definition tuptable.h:107

References Assert, ExecClearTuple(), IsA, pfree(), TupleTableSlotOps::release, ReleaseTupleDesc, TTS_FIXED, TupleTableSlot::tts_isnull, TupleTableSlot::tts_ops, TupleTableSlot::tts_tupleDescriptor, and TupleTableSlot::tts_values.

Referenced by acquire_sample_rows(), AfterTriggerFreeQuery(), afterTriggerInvokeEvents(), ATRewriteTable(), CatalogIndexInsert(), check_default_partition_contents(), check_exclusion_or_unique_constraint(), check_pub_dead_tuple_retention(), check_publications(), check_publications_origin_sequences(), check_publications_origin_tables(), compute_expr_stats(), compute_index_stats(), copy_sequences(), CopyMultiInsertBufferCleanup(), CopyRelationTo(), copyTemplateDependencies(), DefineTSConfiguration(), deleteSplitPartitionContext(), end_tup_output(), EnumValuesCreate(), ExecCleanupTupleRouting(), ExecEndIncrementalSort(), ExecEndModifyTable(), fetch_relation_list(), fetch_remote_table_info(), FindConflictTuple(), freestate_cluster(), get_actual_variable_range(), get_rel_sync_entry(), heap_entry_is_visible(), heapam_index_build_range_scan(), heapam_index_validate_scan(), heapam_relation_copy_for_cluster(), hypothetical_dense_rank_final(), IndexCheckExclusion(), InsertPgAttributeTuples(), make_build_data(), MakeConfigurationMapping(), MergePartitionsMoveRows(), pgoutput_change(), recordMultipleDependencies(), RelationFindDeletedTupleInfoByIndex(), RelationFindDeletedTupleInfoSeq(), RelationFindReplTupleSeq(), RI_Initial_Check(), RunFromStore(), SplitPartitionMoveRows(), systable_endscan(), systable_endscan_ordered(), table_index_fetch_tuple_check(), tstoreShutdownReceiver(), unique_key_recheck(), validateDomainCheckConstraint(), validateDomainNotNullConstraint(), and validateForeignKeyConstraint().

◆ ExecFetchSlotHeapTuple()

HeapTuple ExecFetchSlotHeapTuple ( TupleTableSlot slot,
bool  materialize,
bool shouldFree 
)
extern

◆ ExecFetchSlotHeapTupleDatum()

Datum ExecFetchSlotHeapTupleDatum ( TupleTableSlot slot)
extern

Definition at line 1912 of file execTuples.c.

1913{
1914 HeapTuple tup;
1915 TupleDesc tupdesc;
1916 bool shouldFree;
1917 Datum ret;
1918
1919 /* Fetch slot's contents in regular-physical-tuple form */
1920 tup = ExecFetchSlotHeapTuple(slot, false, &shouldFree);
1921 tupdesc = slot->tts_tupleDescriptor;
1922
1923 /* Convert to Datum form */
1924 ret = heap_copy_tuple_as_datum(tup, tupdesc);
1925
1926 if (shouldFree)
1927 pfree(tup);
1928
1929 return ret;
1930}
HeapTuple ExecFetchSlotHeapTuple(TupleTableSlot *slot, bool materialize, bool *shouldFree)
Datum heap_copy_tuple_as_datum(HeapTuple tuple, TupleDesc tupleDesc)
Definition heaptuple.c:1081

References ExecFetchSlotHeapTuple(), fb(), heap_copy_tuple_as_datum(), pfree(), and TupleTableSlot::tts_tupleDescriptor.

Referenced by ExecMakeFunctionResultSet(), and postquel_get_single_result().

◆ ExecFetchSlotMinimalTuple()

MinimalTuple ExecFetchSlotMinimalTuple ( TupleTableSlot slot,
bool shouldFree 
)
extern

Definition at line 1881 of file execTuples.c.

1883{
1884 /*
1885 * sanity checks
1886 */
1887 Assert(slot != NULL);
1888 Assert(!TTS_EMPTY(slot));
1889
1890 if (slot->tts_ops->get_minimal_tuple)
1891 {
1892 if (shouldFree)
1893 *shouldFree = false;
1894 return slot->tts_ops->get_minimal_tuple(slot);
1895 }
1896 else
1897 {
1898 if (shouldFree)
1899 *shouldFree = true;
1900 return slot->tts_ops->copy_minimal_tuple(slot, 0);
1901 }
1902}
MinimalTuple(* get_minimal_tuple)(TupleTableSlot *slot)
Definition tuptable.h:201

References Assert, TupleTableSlotOps::copy_minimal_tuple, fb(), TupleTableSlotOps::get_minimal_tuple, TTS_EMPTY, and TupleTableSlot::tts_ops.

Referenced by ExecHashJoinImpl(), ExecHashSkewTableInsert(), ExecHashTableInsert(), ExecParallelHashJoinPartitionOuter(), ExecParallelHashTableInsert(), ExecParallelHashTableInsertCurrentBatch(), hashagg_spill_tuple(), and tqueueReceiveSlot().

◆ ExecForceStoreHeapTuple()

void ExecForceStoreHeapTuple ( HeapTuple  tuple,
TupleTableSlot slot,
bool  shouldFree 
)
extern

Definition at line 1658 of file execTuples.c.

1661{
1662 if (TTS_IS_HEAPTUPLE(slot))
1663 {
1664 ExecStoreHeapTuple(tuple, slot, shouldFree);
1665 }
1666 else if (TTS_IS_BUFFERTUPLE(slot))
1667 {
1670
1671 ExecClearTuple(slot);
1672 slot->tts_flags &= ~TTS_FLAG_EMPTY;
1674 bslot->base.tuple = heap_copytuple(tuple);
1677
1678 if (shouldFree)
1679 pfree(tuple);
1680 }
1681 else
1682 {
1683 ExecClearTuple(slot);
1685 slot->tts_values, slot->tts_isnull);
1687
1688 if (shouldFree)
1689 {
1690 ExecMaterializeSlot(slot);
1691 pfree(tuple);
1692 }
1693 }
1694}
TupleTableSlot * ExecStoreVirtualTuple(TupleTableSlot *slot)
TupleTableSlot * ExecStoreHeapTuple(HeapTuple tuple, TupleTableSlot *slot, bool shouldFree)
HeapTuple heap_copytuple(HeapTuple tuple)
Definition heaptuple.c:778
void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull)
Definition heaptuple.c:1346
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition palloc.h:124
MemoryContext tts_mcxt
Definition tuptable.h:127
uint16 tts_flags
Definition tuptable.h:117
#define TTS_FLAG_SHOULDFREE
Definition tuptable.h:98
#define TTS_IS_BUFFERTUPLE(slot)
Definition tuptable.h:240
#define TTS_IS_HEAPTUPLE(slot)
Definition tuptable.h:238

References ExecClearTuple(), ExecMaterializeSlot(), ExecStoreHeapTuple(), ExecStoreVirtualTuple(), fb(), heap_copytuple(), heap_deform_tuple(), MemoryContextSwitchTo(), pfree(), TTS_FLAG_SHOULDFREE, TupleTableSlot::tts_flags, TTS_IS_BUFFERTUPLE, TTS_IS_HEAPTUPLE, TupleTableSlot::tts_isnull, TupleTableSlot::tts_mcxt, TupleTableSlot::tts_tupleDescriptor, and TupleTableSlot::tts_values.

Referenced by agg_retrieve_direct(), ExecARDeleteTriggers(), ExecARUpdateTriggers(), ExecBRDeleteTriggers(), ExecBRInsertTriggers(), ExecBRUpdateTriggers(), ExecDelete(), ExecIRDeleteTriggers(), ExecIRInsertTriggers(), ExecIRUpdateTriggers(), ExecMergeMatched(), ExecModifyTable(), IndexNextWithReorder(), IndexOnlyNext(), and store_returning_result().

◆ ExecForceStoreMinimalTuple()

void ExecForceStoreMinimalTuple ( MinimalTuple  mtup,
TupleTableSlot slot,
bool  shouldFree 
)
extern

Definition at line 1701 of file execTuples.c.

1704{
1705 if (TTS_IS_MINIMALTUPLE(slot))
1706 {
1708 }
1709 else
1710 {
1711 HeapTupleData htup;
1712
1713 ExecClearTuple(slot);
1714
1715 htup.t_len = mtup->t_len + MINIMAL_TUPLE_OFFSET;
1716 htup.t_data = (HeapTupleHeader) ((char *) mtup - MINIMAL_TUPLE_OFFSET);
1718 slot->tts_values, slot->tts_isnull);
1720
1721 if (shouldFree)
1722 {
1723 ExecMaterializeSlot(slot);
1724 pfree(mtup);
1725 }
1726 }
1727}
static void tts_minimal_store_tuple(TupleTableSlot *slot, MinimalTuple mtup, bool shouldFree)
Definition execTuples.c:682
HeapTupleHeaderData * HeapTupleHeader
Definition htup.h:23
#define MINIMAL_TUPLE_OFFSET
uint32 t_len
Definition htup.h:64
HeapTupleHeader t_data
Definition htup.h:68
#define TTS_IS_MINIMALTUPLE(slot)
Definition tuptable.h:239

References ExecClearTuple(), ExecMaterializeSlot(), ExecStoreVirtualTuple(), fb(), heap_deform_tuple(), MINIMAL_TUPLE_OFFSET, pfree(), HeapTupleData::t_data, HeapTupleData::t_len, TTS_IS_MINIMALTUPLE, TupleTableSlot::tts_isnull, tts_minimal_store_tuple(), TupleTableSlot::tts_tupleDescriptor, and TupleTableSlot::tts_values.

Referenced by ExecHashJoinGetSavedTuple(), ExecParallelHashJoinNewBatch(), and ExecParallelHashJoinOuterGetTuple().

◆ ExecMaterializeSlot()

◆ ExecResetTupleTable()

void ExecResetTupleTable ( List tupleTable,
bool  shouldFree 
)
extern

Definition at line 1380 of file execTuples.c.

1382{
1383 ListCell *lc;
1384
1385 foreach(lc, tupleTable)
1386 {
1388
1389 /* Always release resources and reset the slot to empty */
1390 ExecClearTuple(slot);
1391 slot->tts_ops->release(slot);
1392 if (slot->tts_tupleDescriptor)
1393 {
1395 slot->tts_tupleDescriptor = NULL;
1396 }
1397
1398 /* If shouldFree, release memory occupied by the slot itself */
1399 if (shouldFree)
1400 {
1401 if (!TTS_FIXED(slot))
1402 {
1403 if (slot->tts_values)
1404 pfree(slot->tts_values);
1405 if (slot->tts_isnull)
1406 pfree(slot->tts_isnull);
1407 }
1408 pfree(slot);
1409 }
1410 }
1411
1412 /* If shouldFree, release the list structure */
1413 if (shouldFree)
1415}
void list_free(List *list)
Definition list.c:1546
#define lfirst_node(type, lc)
Definition pg_list.h:176

References ExecClearTuple(), fb(), lfirst_node, list_free(), pfree(), TupleTableSlotOps::release, ReleaseTupleDesc, TTS_FIXED, TupleTableSlot::tts_isnull, TupleTableSlot::tts_ops, TupleTableSlot::tts_tupleDescriptor, and TupleTableSlot::tts_values.

Referenced by afterTriggerInvokeEvents(), CopyFrom(), EvalPlanQualEnd(), ExecEndPlan(), and finish_edata().

◆ ExecSetSlotDescriptor()

void ExecSetSlotDescriptor ( TupleTableSlot slot,
TupleDesc  tupdesc 
)
extern

Definition at line 1478 of file execTuples.c.

1480{
1481 Assert(!TTS_FIXED(slot));
1482
1483 /* For safety, make sure slot is empty before changing it */
1484 ExecClearTuple(slot);
1485
1486 /*
1487 * Release any old descriptor. Also release old Datum/isnull arrays if
1488 * present (we don't bother to check if they could be re-used).
1489 */
1490 if (slot->tts_tupleDescriptor)
1492
1493 if (slot->tts_values)
1494 pfree(slot->tts_values);
1495 if (slot->tts_isnull)
1496 pfree(slot->tts_isnull);
1497
1498 /*
1499 * Install the new descriptor; if it's refcounted, bump its refcount.
1500 */
1501 slot->tts_tupleDescriptor = tupdesc;
1502 PinTupleDesc(tupdesc);
1503
1504 /*
1505 * Allocate Datum/isnull arrays of the appropriate size. These must have
1506 * the same lifetime as the slot, so allocate in the slot's own context.
1507 */
1508 slot->tts_values = (Datum *)
1509 MemoryContextAlloc(slot->tts_mcxt, tupdesc->natts * sizeof(Datum));
1510 slot->tts_isnull = (bool *)
1511 MemoryContextAlloc(slot->tts_mcxt, tupdesc->natts * sizeof(bool));
1512}
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition mcxt.c:1232
#define PinTupleDesc(tupdesc)
Definition tupdesc.h:213

References Assert, ExecClearTuple(), MemoryContextAlloc(), TupleDescData::natts, pfree(), PinTupleDesc, ReleaseTupleDesc, TTS_FIXED, TupleTableSlot::tts_isnull, TupleTableSlot::tts_mcxt, TupleTableSlot::tts_tupleDescriptor, and TupleTableSlot::tts_values.

Referenced by ExecAssignScanType(), ExecInitJunkFilter(), and ExecInitJunkFilterConversion().

◆ ExecStoreAllNullTuple()

TupleTableSlot * ExecStoreAllNullTuple ( TupleTableSlot slot)
extern

Definition at line 1765 of file execTuples.c.

1766{
1767 /*
1768 * sanity checks
1769 */
1770 Assert(slot != NULL);
1772
1773 /* Clear any old contents */
1774 ExecClearTuple(slot);
1775
1776 /*
1777 * Fill all the columns of the virtual tuple with nulls
1778 */
1779 MemSet(slot->tts_values, 0,
1780 slot->tts_tupleDescriptor->natts * sizeof(Datum));
1781 memset(slot->tts_isnull, true,
1782 slot->tts_tupleDescriptor->natts * sizeof(bool));
1783
1784 return ExecStoreVirtualTuple(slot);
1785}
#define MemSet(start, val, len)
Definition c.h:1013

References Assert, ExecClearTuple(), ExecStoreVirtualTuple(), fb(), MemSet, TupleDescData::natts, TupleTableSlot::tts_isnull, TupleTableSlot::tts_tupleDescriptor, and TupleTableSlot::tts_values.

Referenced by ATRewriteTable(), ExecDelete(), ExecGetAllNullSlot(), ExecInitNullTupleSlot(), get_returning_data(), and prepare_projection_slot().

◆ ExecStoreBufferHeapTuple()

TupleTableSlot * ExecStoreBufferHeapTuple ( HeapTuple  tuple,
TupleTableSlot slot,
Buffer  buffer 
)
extern

Definition at line 1581 of file execTuples.c.

1584{
1585 /*
1586 * sanity checks
1587 */
1588 Assert(tuple != NULL);
1589 Assert(slot != NULL);
1591 Assert(BufferIsValid(buffer));
1592
1593 if (unlikely(!TTS_IS_BUFFERTUPLE(slot)))
1594 elog(ERROR, "trying to store an on-disk heap tuple into wrong type of slot");
1595 tts_buffer_heap_store_tuple(slot, tuple, buffer, false);
1596
1597 slot->tts_tableOid = tuple->t_tableOid;
1598
1599 return slot;
1600}
static bool BufferIsValid(Buffer bufnum)
Definition bufmgr.h:417
#define unlikely(x)
Definition c.h:412
#define ERROR
Definition elog.h:39
#define elog(elevel,...)
Definition elog.h:226
static void tts_buffer_heap_store_tuple(TupleTableSlot *slot, HeapTuple tuple, Buffer buffer, bool transfer_pin)
Definition execTuples.c:944
Oid t_tableOid
Definition htup.h:66

References Assert, BufferIsValid(), elog, ERROR, fb(), HeapTupleData::t_tableOid, tts_buffer_heap_store_tuple(), TTS_IS_BUFFERTUPLE, TupleTableSlot::tts_tableOid, TupleTableSlot::tts_tupleDescriptor, and unlikely.

Referenced by heap_getnextslot(), heap_getnextslot_tidrange(), heapam_index_build_range_scan(), heapam_index_fetch_tuple(), heapam_scan_analyze_next_tuple(), heapam_scan_bitmap_next_tuple(), and heapam_scan_sample_next_tuple().

◆ ExecStoreHeapTuple()

TupleTableSlot * ExecStoreHeapTuple ( HeapTuple  tuple,
TupleTableSlot slot,
bool  shouldFree 
)
extern

Definition at line 1541 of file execTuples.c.

1544{
1545 /*
1546 * sanity checks
1547 */
1548 Assert(tuple != NULL);
1549 Assert(slot != NULL);
1551
1552 if (unlikely(!TTS_IS_HEAPTUPLE(slot)))
1553 elog(ERROR, "trying to store a heap tuple into wrong type of slot");
1554 tts_heap_store_tuple(slot, tuple, shouldFree);
1555
1556 slot->tts_tableOid = tuple->t_tableOid;
1557
1558 return slot;
1559}
static void tts_heap_store_tuple(TupleTableSlot *slot, HeapTuple tuple, bool shouldFree)
Definition execTuples.c:487

References Assert, elog, ERROR, fb(), HeapTupleData::t_tableOid, tts_heap_store_tuple(), TTS_IS_HEAPTUPLE, TupleTableSlot::tts_tableOid, TupleTableSlot::tts_tupleDescriptor, and unlikely.

Referenced by CatalogIndexInsert(), comparetup_cluster_tiebreak(), compute_expr_stats(), compute_index_stats(), ExecForceStoreHeapTuple(), ExecuteCallStmt(), get_returning_data(), heapam_index_validate_scan(), make_build_data(), pgoutput_change(), postgresIterateForeignScan(), and tts_heap_copyslot().

◆ ExecStoreHeapTupleDatum()

void ExecStoreHeapTupleDatum ( Datum  data,
TupleTableSlot slot 
)
extern

Definition at line 1795 of file execTuples.c.

1796{
1797 HeapTupleData tuple = {0};
1798 HeapTupleHeader td;
1799
1801
1803 tuple.t_self = td->t_ctid;
1804 tuple.t_data = td;
1805
1806 ExecClearTuple(slot);
1807
1809 slot->tts_values, slot->tts_isnull);
1811}
#define DatumGetHeapTupleHeader(X)
Definition fmgr.h:296
static uint32 HeapTupleHeaderGetDatumLength(const HeapTupleHeaderData *tup)
const void * data
ItemPointerData t_self
Definition htup.h:65
ItemPointerData t_ctid

References data, DatumGetHeapTupleHeader, ExecClearTuple(), ExecStoreVirtualTuple(), heap_deform_tuple(), HeapTupleHeaderGetDatumLength(), HeapTupleHeaderData::t_ctid, HeapTupleData::t_data, HeapTupleData::t_len, HeapTupleData::t_self, TupleTableSlot::tts_isnull, TupleTableSlot::tts_tupleDescriptor, and TupleTableSlot::tts_values.

Referenced by EvalPlanQualFetchRowMark().

◆ ExecStoreMinimalTuple()

◆ ExecStorePinnedBufferHeapTuple()

TupleTableSlot * ExecStorePinnedBufferHeapTuple ( HeapTuple  tuple,
TupleTableSlot slot,
Buffer  buffer 
)
extern

Definition at line 1607 of file execTuples.c.

1610{
1611 /*
1612 * sanity checks
1613 */
1614 Assert(tuple != NULL);
1615 Assert(slot != NULL);
1617 Assert(BufferIsValid(buffer));
1618
1619 if (unlikely(!TTS_IS_BUFFERTUPLE(slot)))
1620 elog(ERROR, "trying to store an on-disk heap tuple into wrong type of slot");
1621 tts_buffer_heap_store_tuple(slot, tuple, buffer, true);
1622
1623 slot->tts_tableOid = tuple->t_tableOid;
1624
1625 return slot;
1626}

References Assert, BufferIsValid(), elog, ERROR, fb(), HeapTupleData::t_tableOid, tts_buffer_heap_store_tuple(), TTS_IS_BUFFERTUPLE, TupleTableSlot::tts_tableOid, TupleTableSlot::tts_tupleDescriptor, and unlikely.

Referenced by heapam_fetch_row_version(), and heapam_tuple_lock().

◆ ExecStoreVirtualTuple()

TupleTableSlot * ExecStoreVirtualTuple ( TupleTableSlot slot)
extern

◆ MakeSingleTupleTableSlot()

◆ MakeTupleTableSlot()

TupleTableSlot * MakeTupleTableSlot ( TupleDesc  tupleDesc,
const TupleTableSlotOps tts_ops 
)
extern

Definition at line 1301 of file execTuples.c.

1303{
1304 Size basesz,
1305 allocsz;
1306 TupleTableSlot *slot;
1307
1308 basesz = tts_ops->base_slot_size;
1309
1310 /*
1311 * When a fixed descriptor is specified, we can reduce overhead by
1312 * allocating the entire slot in one go.
1313 */
1314 if (tupleDesc)
1316 MAXALIGN(tupleDesc->natts * sizeof(Datum)) +
1317 MAXALIGN(tupleDesc->natts * sizeof(bool));
1318 else
1319 allocsz = basesz;
1320
1321 slot = palloc0(allocsz);
1322 /* const for optimization purposes, OK to modify at allocation time */
1323 *((const TupleTableSlotOps **) &slot->tts_ops) = tts_ops;
1324 slot->type = T_TupleTableSlot;
1325 slot->tts_flags |= TTS_FLAG_EMPTY;
1326 if (tupleDesc != NULL)
1327 slot->tts_flags |= TTS_FLAG_FIXED;
1330 slot->tts_nvalid = 0;
1331
1332 if (tupleDesc != NULL)
1333 {
1334 slot->tts_values = (Datum *)
1335 (((char *) slot)
1336 + MAXALIGN(basesz));
1337 slot->tts_isnull = (bool *)
1338 (((char *) slot)
1339 + MAXALIGN(basesz)
1340 + MAXALIGN(tupleDesc->natts * sizeof(Datum)));
1341
1343 }
1344
1345 /*
1346 * And allow slot type specific initialization.
1347 */
1348 slot->tts_ops->init(slot);
1349
1350 return slot;
1351}
#define MAXALIGN(LEN)
Definition c.h:826
void * palloc0(Size size)
Definition mcxt.c:1417
MemoryContext CurrentMemoryContext
Definition mcxt.c:160
size_t base_slot_size
Definition tuptable.h:136
void(* init)(TupleTableSlot *slot)
Definition tuptable.h:139
NodeTag type
Definition tuptable.h:115
#define TTS_FLAG_EMPTY
Definition tuptable.h:94
#define TTS_FLAG_FIXED
Definition tuptable.h:106

References TupleTableSlotOps::base_slot_size, CurrentMemoryContext, fb(), TupleTableSlotOps::init, MAXALIGN, palloc0(), PinTupleDesc, TTS_FLAG_EMPTY, TTS_FLAG_FIXED, TupleTableSlot::tts_flags, TupleTableSlot::tts_isnull, TupleTableSlot::tts_mcxt, TupleTableSlot::tts_nvalid, TupleTableSlot::tts_ops, TupleTableSlot::tts_tupleDescriptor, TupleTableSlot::tts_values, and TupleTableSlot::type.

Referenced by ExecAllocTableSlot(), ExecConstraints(), ExecPartitionCheckEmitError(), ExecWithCheckOptions(), MakeSingleTupleTableSlot(), pgoutput_change(), and ReportNotNullViolationError().

◆ slot_attisnull()

static bool slot_attisnull ( TupleTableSlot slot,
int  attnum 
)
inlinestatic

◆ slot_getallattrs()

◆ slot_getattr()

◆ slot_getmissingattrs()

void slot_getmissingattrs ( TupleTableSlot slot,
int  startAttNum,
int  lastAttNum 
)
extern

Definition at line 2057 of file execTuples.c.

2058{
2060
2061 if (slot->tts_tupleDescriptor->constr)
2063
2064 if (!attrmiss)
2065 {
2066 /* no missing values array at all, so just fill everything in as NULL */
2067 memset(slot->tts_values + startAttNum, 0,
2068 (lastAttNum - startAttNum) * sizeof(Datum));
2069 memset(slot->tts_isnull + startAttNum, 1,
2070 (lastAttNum - startAttNum) * sizeof(bool));
2071 }
2072 else
2073 {
2074 int missattnum;
2075
2076 /* if there is a missing values array we must process them one by one */
2077 for (missattnum = startAttNum;
2079 missattnum++)
2080 {
2081 slot->tts_values[missattnum] = attrmiss[missattnum].am_value;
2082 slot->tts_isnull[missattnum] = !attrmiss[missattnum].am_present;
2083 }
2084 }
2085}
struct AttrMissing * missing
Definition tupdesc.h:42
TupleConstr * constr
Definition tupdesc.h:141

References TupleDescData::constr, fb(), TupleConstr::missing, TupleTableSlot::tts_isnull, TupleTableSlot::tts_tupleDescriptor, and TupleTableSlot::tts_values.

Referenced by slot_getsomeattrs_int().

◆ slot_getsomeattrs()

◆ slot_getsomeattrs_int()

void slot_getsomeattrs_int ( TupleTableSlot slot,
int  attnum 
)
extern

Definition at line 2091 of file execTuples.c.

2092{
2093 /* Check for caller errors */
2094 Assert(slot->tts_nvalid < attnum); /* checked in slot_getsomeattrs */
2095 Assert(attnum > 0);
2096
2098 elog(ERROR, "invalid attribute number %d", attnum);
2099
2100 /* Fetch as many attributes as possible from the underlying tuple. */
2101 slot->tts_ops->getsomeattrs(slot, attnum);
2102
2103 /*
2104 * If the underlying tuple doesn't have enough attributes, tuple
2105 * descriptor must have the missing attributes.
2106 */
2107 if (unlikely(slot->tts_nvalid < attnum))
2108 {
2110 slot->tts_nvalid = attnum;
2111 }
2112}
void slot_getmissingattrs(TupleTableSlot *slot, int startAttNum, int lastAttNum)
void(* getsomeattrs)(TupleTableSlot *slot, int natts)
Definition tuptable.h:159

References Assert, attnum, elog, ERROR, TupleTableSlotOps::getsomeattrs, TupleDescData::natts, slot_getmissingattrs(), TupleTableSlot::tts_nvalid, TupleTableSlot::tts_ops, TupleTableSlot::tts_tupleDescriptor, and unlikely.

Referenced by slot_getsomeattrs().

◆ slot_getsysattr()

static Datum slot_getsysattr ( TupleTableSlot slot,
int  attnum,
bool isnull 
)
inlinestatic

Definition at line 419 of file tuptable.h.

420{
421 Assert(attnum < 0); /* caller error */
422
424 {
425 *isnull = false;
426 return ObjectIdGetDatum(slot->tts_tableOid);
427 }
429 {
430 *isnull = false;
431 return PointerGetDatum(&slot->tts_tid);
432 }
433
434 /* Fetch the system attribute from the underlying tuple. */
435 return slot->tts_ops->getsysattr(slot, attnum, isnull);
436}

References Assert, attnum, TupleTableSlotOps::getsysattr, ObjectIdGetDatum(), PointerGetDatum(), SelfItemPointerAttributeNumber, TableOidAttributeNumber, TupleTableSlot::tts_ops, TupleTableSlot::tts_tableOid, and TupleTableSlot::tts_tid.

Referenced by ExecCheckTupleVisible(), execCurrentOf(), ExecEvalSysVar(), ExecOnConflictUpdate(), FormIndexDatum(), and GetTupleTransactionInfo().

◆ slot_is_current_xact_tuple()

static bool slot_is_current_xact_tuple ( TupleTableSlot slot)
inlinestatic

Definition at line 448 of file tuptable.h.

449{
450 return slot->tts_ops->is_current_xact_tuple(slot);
451}

References TupleTableSlotOps::is_current_xact_tuple, and TupleTableSlot::tts_ops.

Referenced by RI_FKey_fk_upd_check_required().

Variable Documentation

◆ TTSOpsBufferHeapTuple

PGDLLIMPORT const TupleTableSlotOps TTSOpsBufferHeapTuple
extern

◆ TTSOpsHeapTuple

◆ TTSOpsMinimalTuple

◆ TTSOpsVirtual