PostgreSQL Source Code  git master
tuptable.h File Reference
#include "access/htup.h"
#include "access/htup_details.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 TupleTableSlotExecClearTuple (TupleTableSlot *slot)
 
static void ExecMaterializeSlot (TupleTableSlot *slot)
 
static HeapTuple ExecCopySlotHeapTuple (TupleTableSlot *slot)
 
static MinimalTuple ExecCopySlotMinimalTuple (TupleTableSlot *slot)
 
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 251 of file tuptable.h.

Referenced by slot_compile_deform().

◆ FIELDNO_HEAPTUPLETABLESLOT_TUPLE

#define FIELDNO_HEAPTUPLETABLESLOT_TUPLE   1

Definition at line 249 of file tuptable.h.

Referenced by slot_compile_deform().

◆ FIELDNO_MINIMALTUPLETABLESLOT_OFF

#define FIELDNO_MINIMALTUPLETABLESLOT_OFF   4

Definition at line 285 of file tuptable.h.

Referenced by slot_compile_deform().

◆ FIELDNO_MINIMALTUPLETABLESLOT_TUPLE

#define FIELDNO_MINIMALTUPLETABLESLOT_TUPLE   1

Definition at line 281 of file tuptable.h.

Referenced by slot_compile_deform().

◆ FIELDNO_TUPLETABLESLOT_FLAGS

#define FIELDNO_TUPLETABLESLOT_FLAGS   1

Definition at line 118 of file tuptable.h.

Referenced by slot_compile_deform().

◆ FIELDNO_TUPLETABLESLOT_ISNULL

#define FIELDNO_TUPLETABLESLOT_ISNULL   6

Definition at line 127 of file tuptable.h.

Referenced by llvm_compile_expr(), and slot_compile_deform().

◆ FIELDNO_TUPLETABLESLOT_NVALID

#define FIELDNO_TUPLETABLESLOT_NVALID   2

Definition at line 120 of file tuptable.h.

Referenced by llvm_compile_expr(), and slot_compile_deform().

◆ FIELDNO_TUPLETABLESLOT_TUPLEDESCRIPTOR

#define FIELDNO_TUPLETABLESLOT_TUPLEDESCRIPTOR   4

Definition at line 123 of file tuptable.h.

◆ FIELDNO_TUPLETABLESLOT_VALUES

#define FIELDNO_TUPLETABLESLOT_VALUES   5

Definition at line 125 of file tuptable.h.

Referenced by llvm_compile_expr(), and slot_compile_deform().

◆ TTS_EMPTY

◆ TTS_FIXED

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

◆ TTS_FLAG_EMPTY

◆ TTS_FLAG_FIXED

#define TTS_FLAG_FIXED   (1 << 4)

Definition at line 108 of file tuptable.h.

Referenced by MakeTupleTableSlot().

◆ TTS_FLAG_SHOULDFREE

◆ TTS_FLAG_SLOW

#define TTS_FLAG_SLOW   (1 << 3)

Definition at line 104 of file tuptable.h.

Referenced by slot_compile_deform(), and slot_deform_heap_tuple().

◆ TTS_IS_BUFFERTUPLE

◆ TTS_IS_HEAPTUPLE

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

Definition at line 229 of file tuptable.h.

Referenced by ExecForceStoreHeapTuple(), and ExecStoreHeapTuple().

◆ TTS_IS_MINIMALTUPLE

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

Definition at line 230 of file tuptable.h.

Referenced by ExecForceStoreMinimalTuple(), and ExecStoreMinimalTuple().

◆ TTS_IS_VIRTUAL

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

Definition at line 228 of file tuptable.h.

Referenced by ExecJustAssignVarVirtImpl(), and ExecJustVarVirtImpl().

◆ TTS_SHOULDFREE

◆ TTS_SLOW

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

Definition at line 105 of file tuptable.h.

Referenced by slot_deform_heap_tuple().

◆ TupIsNull

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

Definition at line 292 of file tuptable.h.

Referenced by AfterTriggerSaveEvent(), agg_fill_hash_table(), agg_retrieve_direct(), begin_partition(), buildSubPlanHash(), check_constant_qual(), complete_pending_request(), CteScanNext(), eval_windowaggregates(), EvalPlanQual(), EvalPlanQualFetchRowMark(), ExecAgg(), ExecAppend(), ExecAsyncAppendResponse(), ExecAsyncNotify(), ExecAsyncRequest(), ExecCrossPartitionUpdate(), execCurrentOf(), ExecDelete(), ExecGather(), ExecGatherMerge(), ExecGroup(), ExecHashJoinImpl(), ExecHashJoinOuterGetTuple(), ExecIncrementalSort(), ExecLimit(), ExecLockRows(), ExecMaterial(), ExecMemoize(), ExecMergeAppend(), ExecMergeJoin(), ExecModifyTable(), ExecNestLoop(), ExecParallelHashJoinOuterGetTuple(), ExecParallelHashJoinPartitionOuter(), ExecPostprocessPlan(), ExecProcNodeInstr(), ExecProjectSet(), ExecRecursiveUnion(), ExecResult(), ExecScan(), ExecScanFetch(), ExecScanSubPlan(), ExecSetParamPlan(), ExecSort(), ExecUnique(), ExecUpdate(), ExecutePlan(), fetch_input_tuple(), ForeignNext(), FunctionNext(), gather_getnext(), gather_merge_init(), gather_merge_readnext(), GetTupleForTrigger(), heap_compare_slots(), hypothetical_dense_rank_final(), MJEvalInnerValues(), MJEvalOuterValues(), MultiExecParallelHash(), MultiExecPrivateHash(), postgresRecheckForeignScan(), print_slot(), produce_tuple_asynchronously(), setop_fill_hash_table(), setop_retrieve_direct(), spool_tuples(), switchToPresortedPrefixMode(), update_frameheadpos(), and update_frametailpos().

Typedef Documentation

◆ BufferHeapTupleTableSlot

◆ HeapTupleTableSlot

◆ MinimalTupleTableSlot

◆ TupleTableSlot

◆ TupleTableSlotOps

Definition at line 112 of file tuptable.h.

◆ VirtualTupleTableSlot

Function Documentation

◆ ExecAllocTableSlot()

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

Definition at line 1171 of file execTuples.c.

References lappend(), and MakeTupleTableSlot().

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

1173 {
1174  TupleTableSlot *slot = MakeTupleTableSlot(desc, tts_ops);
1175 
1176  *tupleTable = lappend(*tupleTable, slot);
1177 
1178  return slot;
1179 }
List * lappend(List *list, void *datum)
Definition: list.c:336
TupleTableSlot * MakeTupleTableSlot(TupleDesc tupleDesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1112

◆ ExecClearTuple()

static TupleTableSlot* ExecClearTuple ( TupleTableSlot slot)
inlinestatic

Definition at line 425 of file tuptable.h.

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

Referenced by AfterTriggerExecute(), agg_retrieve_hash_table_in_memory(), apply_handle_update_internal(), apply_returning_filter(), ATRewriteTable(), begin_partition(), BitmapHeapNext(), buildSubPlanHash(), CopyFrom(), CopyMultiInsertBufferFlush(), copyTemplateDependencies(), CteScanNext(), do_tup_output(), eval_windowaggregates(), EvalPlanQual(), ExecAppend(), ExecAppendAsyncGetNext(), ExecARUpdateTriggers(), ExecCheckTIDVisible(), ExecComputeStoredGenerated(), ExecDelete(), ExecDropSingleTupleTableSlot(), ExecEndAgg(), ExecEndBitmapHeapScan(), ExecEndCteScan(), ExecEndCustomScan(), ExecEndForeignScan(), ExecEndFunctionScan(), ExecEndGather(), ExecEndGatherMerge(), ExecEndGroup(), ExecEndHashJoin(), ExecEndIncrementalSort(), ExecEndIndexOnlyScan(), ExecEndIndexScan(), ExecEndMaterial(), ExecEndMemoize(), ExecEndMergeJoin(), ExecEndModifyTable(), ExecEndNamedTuplestoreScan(), ExecEndNestLoop(), ExecEndProjectSet(), ExecEndResult(), ExecEndSampleScan(), ExecEndSeqScan(), ExecEndSetOp(), ExecEndSort(), ExecEndSubqueryScan(), ExecEndTableFuncScan(), ExecEndTidRangeScan(), ExecEndTidScan(), ExecEndUnique(), ExecEndValuesScan(), ExecEndWindowAgg(), ExecEndWorkTableScan(), ExecEvalAggOrderedTransTuple(), ExecFilterJunk(), ExecFindPartition(), ExecForceStoreHeapTuple(), ExecForceStoreMinimalTuple(), ExecHashJoinGetSavedTuple(), ExecHashSubPlan(), ExecIncrementalSort(), ExecLockRows(), ExecMaterial(), ExecMergeAppend(), ExecOnConflictUpdate(), ExecParallelHashJoinOuterGetTuple(), ExecProject(), ExecProjectSRF(), ExecReScanAgg(), ExecReScanCteScan(), ExecReScanFunctionScan(), ExecReScanGroup(), ExecReScanIncrementalSort(), ExecReScanMaterial(), ExecReScanMergeJoin(), ExecReScanNamedTuplestoreScan(), ExecReScanSetOp(), ExecReScanSort(), ExecReScanTableFuncScan(), ExecReScanUnique(), ExecReScanValuesScan(), ExecReScanWindowAgg(), ExecReScanWorkTableScan(), ExecResetTupleTable(), ExecScan(), ExecScanFetch(), ExecScanReScan(), ExecSetSlotDescriptor(), ExecSort(), ExecStoreAllNullTuple(), ExecStoreHeapTupleDatum(), ExecUnique(), execute_attr_map_slot(), ExecWindowAgg(), fetch_remote_table_info(), fetch_table_list(), fileIterateForeignScan(), 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(), ordered_set_shutdown(), ordered_set_transition_multi(), postgresIterateDirectModify(), postgresIterateForeignScan(), prepare_hash_slot(), prepare_probe_slot(), process_ordered_aggregate_multi(), recordMultipleDependencies(), RunFromStore(), setop_retrieve_direct(), setop_retrieve_hash_table(), ShutdownSetExpr(), slot_modify_data(), slot_store_data(), StoreIndexTuple(), switchToPresortedPrefixMode(), tablesample_getnext(), tfuncLoadRows(), TidNext(), TidRangeNext(), tts_buffer_heap_copyslot(), tuplesort_gettupleslot(), tuplestore_gettupleslot(), update_frameheadpos(), update_frametailpos(), update_grouptailpos(), ValuesNext(), and WinRowsArePeers().

426 {
427  slot->tts_ops->clear(slot);
428 
429  return slot;
430 }
const TupleTableSlotOps *const tts_ops
Definition: tuptable.h:122
void(* clear)(TupleTableSlot *slot)
Definition: tuptable.h:152

◆ ExecCopySlot()

static TupleTableSlot* ExecCopySlot ( TupleTableSlot dstslot,
TupleTableSlot srcslot 
)
inlinestatic

Definition at line 475 of file tuptable.h.

References Assert, AssertArg, TupleTableSlotOps::copyslot, TTS_EMPTY, and TupleTableSlot::tts_ops.

Referenced by apply_handle_tuple_routing(), begin_partition(), CopyFrom(), CteScanNext(), EvalPlanQual(), ExecBRUpdateTriggers(), ExecGetInsertNewTuple(), ExecGroup(), ExecIncrementalSort(), ExecInsert(), ExecLimit(), ExecMaterial(), ExecMemoize(), ExecUnique(), ExecWindowAgg(), postgresRecheckForeignScan(), RelationFindReplTupleSeq(), spool_tuples(), switchToPresortedPrefixMode(), update_frameheadpos(), and update_frametailpos().

476 {
477  Assert(!TTS_EMPTY(srcslot));
478  AssertArg(srcslot != dstslot);
479 
480  dstslot->tts_ops->copyslot(dstslot, srcslot);
481 
482  return dstslot;
483 }
#define TTS_EMPTY(slot)
Definition: tuptable.h:97
const TupleTableSlotOps *const tts_ops
Definition: tuptable.h:122
#define AssertArg(condition)
Definition: c.h:806
#define Assert(condition)
Definition: c.h:804
void(* copyslot)(TupleTableSlot *dstslot, TupleTableSlot *srcslot)
Definition: tuptable.h:180

◆ ExecCopySlotHeapTuple()

static HeapTuple ExecCopySlotHeapTuple ( TupleTableSlot slot)
inlinestatic

Definition at line 452 of file tuptable.h.

References Assert, TupleTableSlotOps::copy_heap_tuple, TTS_EMPTY, and TupleTableSlot::tts_ops.

Referenced by acquire_sample_rows(), agg_retrieve_direct(), ExecScanSubPlan(), ExecSetParamPlan(), reorderqueue_push(), setop_retrieve_direct(), spi_printtup(), tts_buffer_heap_copyslot(), and tts_heap_copyslot().

453 {
454  Assert(!TTS_EMPTY(slot));
455 
456  return slot->tts_ops->copy_heap_tuple(slot);
457 }
HeapTuple(* copy_heap_tuple)(TupleTableSlot *slot)
Definition: tuptable.h:206
#define TTS_EMPTY(slot)
Definition: tuptable.h:97
const TupleTableSlotOps *const tts_ops
Definition: tuptable.h:122
#define Assert(condition)
Definition: c.h:804

◆ ExecCopySlotMinimalTuple()

static MinimalTuple ExecCopySlotMinimalTuple ( TupleTableSlot slot)
inlinestatic

Definition at line 463 of file tuptable.h.

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

Referenced by cache_lookup(), cache_store_tuple(), copytup_heap(), LookupTupleHashEntry_internal(), tts_minimal_copyslot(), and tuplestore_puttupleslot().

464 {
465  return slot->tts_ops->copy_minimal_tuple(slot);
466 }
const TupleTableSlotOps *const tts_ops
Definition: tuptable.h:122
MinimalTuple(* copy_minimal_tuple)(TupleTableSlot *slot)
Definition: tuptable.h:216

◆ ExecDropSingleTupleTableSlot()

void ExecDropSingleTupleTableSlot ( TupleTableSlot slot)

Definition at line 1254 of file execTuples.c.

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(), AlterDomainNotNull(), ATRewriteTable(), CatalogIndexInsert(), check_default_partition_contents(), check_exclusion_or_unique_constraint(), compute_expr_stats(), compute_index_stats(), CopyMultiInsertBufferCleanup(), copyTemplateDependencies(), DefineQueryRewrite(), DoCopyTo(), end_tup_output(), ExecCleanupTupleRouting(), ExecEndIncrementalSort(), ExecEndModifyTable(), fetch_remote_table_info(), fetch_table_list(), get_actual_variable_range(), heapam_index_build_range_scan(), heapam_index_validate_scan(), heapam_relation_copy_for_cluster(), hypothetical_dense_rank_final(), IndexCheckExclusion(), InsertPgAttributeTuples(), make_build_data(), recordMultipleDependencies(), RelationFindReplTupleSeq(), RI_Initial_Check(), RunFromStore(), systable_endscan(), systable_endscan_ordered(), table_index_fetch_tuple_check(), tstoreShutdownReceiver(), tuplesort_free(), unique_key_recheck(), validateDomainConstraint(), and validateForeignKeyConstraint().

1255 {
1256  /* This should match ExecResetTupleTable's processing of one slot */
1257  Assert(IsA(slot, TupleTableSlot));
1258  ExecClearTuple(slot);
1259  slot->tts_ops->release(slot);
1260  if (slot->tts_tupleDescriptor)
1262  if (!TTS_FIXED(slot))
1263  {
1264  if (slot->tts_values)
1265  pfree(slot->tts_values);
1266  if (slot->tts_isnull)
1267  pfree(slot->tts_isnull);
1268  }
1269  pfree(slot);
1270 }
#define TTS_FIXED(slot)
Definition: tuptable.h:109
#define IsA(nodeptr, _type_)
Definition: nodes.h:587
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:425
const TupleTableSlotOps *const tts_ops
Definition: tuptable.h:122
void(* release)(TupleTableSlot *slot)
Definition: tuptable.h:144
Datum * tts_values
Definition: tuptable.h:126
void pfree(void *pointer)
Definition: mcxt.c:1169
bool * tts_isnull
Definition: tuptable.h:128
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
#define Assert(condition)
Definition: c.h:804
#define ReleaseTupleDesc(tupdesc)
Definition: tupdesc.h:122

◆ ExecFetchSlotHeapTuple()

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

Definition at line 1644 of file execTuples.c.

References Assert, TupleTableSlotOps::copy_heap_tuple, TupleTableSlotOps::get_heap_tuple, TupleTableSlotOps::materialize, TTS_EMPTY, and TupleTableSlot::tts_ops.

Referenced by AfterTriggerExecute(), apply_returning_filter(), CatalogTuplesMultiInsertWithInfo(), ExecBRDeleteTriggers(), ExecBRInsertTriggers(), ExecBRUpdateTriggers(), ExecFetchSlotHeapTupleDatum(), ExecIRInsertTriggers(), ExecIRUpdateTriggers(), heap_multi_insert(), heapam_relation_copy_for_cluster(), heapam_tuple_complete_speculative(), heapam_tuple_insert(), heapam_tuple_insert_speculative(), heapam_tuple_update(), systable_getnext(), systable_getnext_ordered(), systable_recheck_tuple(), and validateForeignKeyConstraint().

1645 {
1646  /*
1647  * sanity checks
1648  */
1649  Assert(slot != NULL);
1650  Assert(!TTS_EMPTY(slot));
1651 
1652  /* Materialize the tuple so that the slot "owns" it, if requested. */
1653  if (materialize)
1654  slot->tts_ops->materialize(slot);
1655 
1656  if (slot->tts_ops->get_heap_tuple == NULL)
1657  {
1658  if (shouldFree)
1659  *shouldFree = true;
1660  return slot->tts_ops->copy_heap_tuple(slot);
1661  }
1662  else
1663  {
1664  if (shouldFree)
1665  *shouldFree = false;
1666  return slot->tts_ops->get_heap_tuple(slot);
1667  }
1668 }
HeapTuple(* copy_heap_tuple)(TupleTableSlot *slot)
Definition: tuptable.h:206
#define TTS_EMPTY(slot)
Definition: tuptable.h:97
const TupleTableSlotOps *const tts_ops
Definition: tuptable.h:122
HeapTuple(* get_heap_tuple)(TupleTableSlot *slot)
Definition: tuptable.h:188
#define Assert(condition)
Definition: c.h:804
void(* materialize)(TupleTableSlot *slot)
Definition: tuptable.h:174

◆ ExecFetchSlotHeapTupleDatum()

Datum ExecFetchSlotHeapTupleDatum ( TupleTableSlot slot)

Definition at line 1723 of file execTuples.c.

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

Referenced by ExecMakeFunctionResultSet(), and postquel_get_single_result().

1724 {
1725  HeapTuple tup;
1726  TupleDesc tupdesc;
1727  bool shouldFree;
1728  Datum ret;
1729 
1730  /* Fetch slot's contents in regular-physical-tuple form */
1731  tup = ExecFetchSlotHeapTuple(slot, false, &shouldFree);
1732  tupdesc = slot->tts_tupleDescriptor;
1733 
1734  /* Convert to Datum form */
1735  ret = heap_copy_tuple_as_datum(tup, tupdesc);
1736 
1737  if (shouldFree)
1738  pfree(tup);
1739 
1740  return ret;
1741 }
void pfree(void *pointer)
Definition: mcxt.c:1169
HeapTuple ExecFetchSlotHeapTuple(TupleTableSlot *slot, bool materialize, bool *shouldFree)
Definition: execTuples.c:1644
Datum heap_copy_tuple_as_datum(HeapTuple tuple, TupleDesc tupleDesc)
Definition: heaptuple.c:984
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
uintptr_t Datum
Definition: postgres.h:411

◆ ExecFetchSlotMinimalTuple()

MinimalTuple ExecFetchSlotMinimalTuple ( TupleTableSlot slot,
bool shouldFree 
)

Definition at line 1692 of file execTuples.c.

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

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

1694 {
1695  /*
1696  * sanity checks
1697  */
1698  Assert(slot != NULL);
1699  Assert(!TTS_EMPTY(slot));
1700 
1701  if (slot->tts_ops->get_minimal_tuple)
1702  {
1703  if (shouldFree)
1704  *shouldFree = false;
1705  return slot->tts_ops->get_minimal_tuple(slot);
1706  }
1707  else
1708  {
1709  if (shouldFree)
1710  *shouldFree = true;
1711  return slot->tts_ops->copy_minimal_tuple(slot);
1712  }
1713 }
#define TTS_EMPTY(slot)
Definition: tuptable.h:97
const TupleTableSlotOps *const tts_ops
Definition: tuptable.h:122
MinimalTuple(* get_minimal_tuple)(TupleTableSlot *slot)
Definition: tuptable.h:196
MinimalTuple(* copy_minimal_tuple)(TupleTableSlot *slot)
Definition: tuptable.h:216
#define Assert(condition)
Definition: c.h:804

◆ ExecForceStoreHeapTuple()

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

Definition at line 1469 of file execTuples.c.

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

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

1472 {
1473  if (TTS_IS_HEAPTUPLE(slot))
1474  {
1475  ExecStoreHeapTuple(tuple, slot, shouldFree);
1476  }
1477  else if (TTS_IS_BUFFERTUPLE(slot))
1478  {
1479  MemoryContext oldContext;
1481 
1482  ExecClearTuple(slot);
1483  slot->tts_flags &= ~TTS_FLAG_EMPTY;
1484  oldContext = MemoryContextSwitchTo(slot->tts_mcxt);
1485  bslot->base.tuple = heap_copytuple(tuple);
1486  slot->tts_flags |= TTS_FLAG_SHOULDFREE;
1487  MemoryContextSwitchTo(oldContext);
1488 
1489  if (shouldFree)
1490  pfree(tuple);
1491  }
1492  else
1493  {
1494  ExecClearTuple(slot);
1496  slot->tts_values, slot->tts_isnull);
1497  ExecStoreVirtualTuple(slot);
1498 
1499  if (shouldFree)
1500  {
1501  ExecMaterializeSlot(slot);
1502  pfree(tuple);
1503  }
1504  }
1505 }
HeapTuple heap_copytuple(HeapTuple tuple)
Definition: heaptuple.c:680
#define TTS_FLAG_EMPTY
Definition: tuptable.h:96
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:425
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
#define TTS_FLAG_SHOULDFREE
Definition: tuptable.h:100
HeapTuple tuple
Definition: tuptable.h:250
MemoryContext tts_mcxt
Definition: tuptable.h:129
Datum * tts_values
Definition: tuptable.h:126
uint16 tts_flags
Definition: tuptable.h:119
void pfree(void *pointer)
Definition: mcxt.c:1169
bool * tts_isnull
Definition: tuptable.h:128
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
#define TTS_IS_BUFFERTUPLE(slot)
Definition: tuptable.h:231
static void ExecMaterializeSlot(TupleTableSlot *slot)
Definition: tuptable.h:443
#define TTS_IS_HEAPTUPLE(slot)
Definition: tuptable.h:229
void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull)
Definition: heaptuple.c:1249
HeapTupleTableSlot base
Definition: tuptable.h:259
TupleTableSlot * ExecStoreHeapTuple(HeapTuple tuple, TupleTableSlot *slot, bool shouldFree)
Definition: execTuples.c:1352
TupleTableSlot * ExecStoreVirtualTuple(TupleTableSlot *slot)
Definition: execTuples.c:1552

◆ ExecForceStoreMinimalTuple()

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

Definition at line 1512 of file execTuples.c.

References ExecClearTuple(), ExecMaterializeSlot(), ExecStoreVirtualTuple(), heap_deform_tuple(), MINIMAL_TUPLE_OFFSET, pfree(), HeapTupleData::t_data, HeapTupleData::t_len, MinimalTupleData::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().

1515 {
1516  if (TTS_IS_MINIMALTUPLE(slot))
1517  {
1518  tts_minimal_store_tuple(slot, mtup, shouldFree);
1519  }
1520  else
1521  {
1522  HeapTupleData htup;
1523 
1524  ExecClearTuple(slot);
1525 
1526  htup.t_len = mtup->t_len + MINIMAL_TUPLE_OFFSET;
1527  htup.t_data = (HeapTupleHeader) ((char *) mtup - MINIMAL_TUPLE_OFFSET);
1529  slot->tts_values, slot->tts_isnull);
1530  ExecStoreVirtualTuple(slot);
1531 
1532  if (shouldFree)
1533  {
1534  ExecMaterializeSlot(slot);
1535  pfree(mtup);
1536  }
1537  }
1538 }
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:425
HeapTupleHeaderData * HeapTupleHeader
Definition: htup.h:23
#define TTS_IS_MINIMALTUPLE(slot)
Definition: tuptable.h:230
Datum * tts_values
Definition: tuptable.h:126
HeapTupleHeader t_data
Definition: htup.h:68
void pfree(void *pointer)
Definition: mcxt.c:1169
uint32 t_len
Definition: htup.h:64
bool * tts_isnull
Definition: tuptable.h:128
static void tts_minimal_store_tuple(TupleTableSlot *slot, MinimalTuple mtup, bool shouldFree)
Definition: execTuples.c:620
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
static void ExecMaterializeSlot(TupleTableSlot *slot)
Definition: tuptable.h:443
#define MINIMAL_TUPLE_OFFSET
Definition: htup_details.h:618
void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull)
Definition: heaptuple.c:1249
TupleTableSlot * ExecStoreVirtualTuple(TupleTableSlot *slot)
Definition: execTuples.c:1552

◆ ExecMaterializeSlot()

static void ExecMaterializeSlot ( TupleTableSlot slot)
inlinestatic

◆ ExecResetTupleTable()

void ExecResetTupleTable ( List tupleTable,
bool  shouldFree 
)

Definition at line 1191 of file execTuples.c.

References ExecClearTuple(), 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().

1193 {
1194  ListCell *lc;
1195 
1196  foreach(lc, tupleTable)
1197  {
1199 
1200  /* Always release resources and reset the slot to empty */
1201  ExecClearTuple(slot);
1202  slot->tts_ops->release(slot);
1203  if (slot->tts_tupleDescriptor)
1204  {
1206  slot->tts_tupleDescriptor = NULL;
1207  }
1208 
1209  /* If shouldFree, release memory occupied by the slot itself */
1210  if (shouldFree)
1211  {
1212  if (!TTS_FIXED(slot))
1213  {
1214  if (slot->tts_values)
1215  pfree(slot->tts_values);
1216  if (slot->tts_isnull)
1217  pfree(slot->tts_isnull);
1218  }
1219  pfree(slot);
1220  }
1221  }
1222 
1223  /* If shouldFree, release the list structure */
1224  if (shouldFree)
1225  list_free(tupleTable);
1226 }
#define TTS_FIXED(slot)
Definition: tuptable.h:109
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:425
const TupleTableSlotOps *const tts_ops
Definition: tuptable.h:122
void(* release)(TupleTableSlot *slot)
Definition: tuptable.h:144
Datum * tts_values
Definition: tuptable.h:126
void pfree(void *pointer)
Definition: mcxt.c:1169
#define lfirst_node(type, lc)
Definition: pg_list.h:172
bool * tts_isnull
Definition: tuptable.h:128
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
void list_free(List *list)
Definition: list.c:1391
#define ReleaseTupleDesc(tupdesc)
Definition: tupdesc.h:122

◆ ExecSetSlotDescriptor()

void ExecSetSlotDescriptor ( TupleTableSlot slot,
TupleDesc  tupdesc 
)

Definition at line 1289 of file execTuples.c.

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().

1291 {
1292  Assert(!TTS_FIXED(slot));
1293 
1294  /* For safety, make sure slot is empty before changing it */
1295  ExecClearTuple(slot);
1296 
1297  /*
1298  * Release any old descriptor. Also release old Datum/isnull arrays if
1299  * present (we don't bother to check if they could be re-used).
1300  */
1301  if (slot->tts_tupleDescriptor)
1303 
1304  if (slot->tts_values)
1305  pfree(slot->tts_values);
1306  if (slot->tts_isnull)
1307  pfree(slot->tts_isnull);
1308 
1309  /*
1310  * Install the new descriptor; if it's refcounted, bump its refcount.
1311  */
1312  slot->tts_tupleDescriptor = tupdesc;
1313  PinTupleDesc(tupdesc);
1314 
1315  /*
1316  * Allocate Datum/isnull arrays of the appropriate size. These must have
1317  * the same lifetime as the slot, so allocate in the slot's own context.
1318  */
1319  slot->tts_values = (Datum *)
1320  MemoryContextAlloc(slot->tts_mcxt, tupdesc->natts * sizeof(Datum));
1321  slot->tts_isnull = (bool *)
1322  MemoryContextAlloc(slot->tts_mcxt, tupdesc->natts * sizeof(bool));
1323 }
#define TTS_FIXED(slot)
Definition: tuptable.h:109
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:425
MemoryContext tts_mcxt
Definition: tuptable.h:129
Datum * tts_values
Definition: tuptable.h:126
void pfree(void *pointer)
Definition: mcxt.c:1169
bool * tts_isnull
Definition: tuptable.h:128
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
uintptr_t Datum
Definition: postgres.h:411
#define Assert(condition)
Definition: c.h:804
#define PinTupleDesc(tupdesc)
Definition: tupdesc.h:116
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition: mcxt.c:863
#define ReleaseTupleDesc(tupdesc)
Definition: tupdesc.h:122

◆ ExecStoreAllNullTuple()

TupleTableSlot* ExecStoreAllNullTuple ( TupleTableSlot slot)

Definition at line 1576 of file execTuples.c.

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

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

1577 {
1578  /*
1579  * sanity checks
1580  */
1581  Assert(slot != NULL);
1582  Assert(slot->tts_tupleDescriptor != NULL);
1583 
1584  /* Clear any old contents */
1585  ExecClearTuple(slot);
1586 
1587  /*
1588  * Fill all the columns of the virtual tuple with nulls
1589  */
1590  MemSet(slot->tts_values, 0,
1591  slot->tts_tupleDescriptor->natts * sizeof(Datum));
1592  memset(slot->tts_isnull, true,
1593  slot->tts_tupleDescriptor->natts * sizeof(bool));
1594 
1595  return ExecStoreVirtualTuple(slot);
1596 }
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:425
#define MemSet(start, val, len)
Definition: c.h:1008
Datum * tts_values
Definition: tuptable.h:126
bool * tts_isnull
Definition: tuptable.h:128
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
uintptr_t Datum
Definition: postgres.h:411
#define Assert(condition)
Definition: c.h:804
TupleTableSlot * ExecStoreVirtualTuple(TupleTableSlot *slot)
Definition: execTuples.c:1552

◆ ExecStoreBufferHeapTuple()

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

Definition at line 1392 of file execTuples.c.

References Assert, BufferIsValid, elog, ERROR, 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().

1395 {
1396  /*
1397  * sanity checks
1398  */
1399  Assert(tuple != NULL);
1400  Assert(slot != NULL);
1401  Assert(slot->tts_tupleDescriptor != NULL);
1402  Assert(BufferIsValid(buffer));
1403 
1404  if (unlikely(!TTS_IS_BUFFERTUPLE(slot)))
1405  elog(ERROR, "trying to store an on-disk heap tuple into wrong type of slot");
1406  tts_buffer_heap_store_tuple(slot, tuple, buffer, false);
1407 
1408  slot->tts_tableOid = tuple->t_tableOid;
1409 
1410  return slot;
1411 }
Oid tts_tableOid
Definition: tuptable.h:131
static void tts_buffer_heap_store_tuple(TupleTableSlot *slot, HeapTuple tuple, Buffer buffer, bool transfer_pin)
Definition: execTuples.c:859
#define ERROR
Definition: elog.h:46
Oid t_tableOid
Definition: htup.h:66
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
#define TTS_IS_BUFFERTUPLE(slot)
Definition: tuptable.h:231
#define Assert(condition)
Definition: c.h:804
#define BufferIsValid(bufnum)
Definition: bufmgr.h:123
#define elog(elevel,...)
Definition: elog.h:232
#define unlikely(x)
Definition: c.h:273

◆ ExecStoreHeapTuple()

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

Definition at line 1352 of file execTuples.c.

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

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

1355 {
1356  /*
1357  * sanity checks
1358  */
1359  Assert(tuple != NULL);
1360  Assert(slot != NULL);
1361  Assert(slot->tts_tupleDescriptor != NULL);
1362 
1363  if (unlikely(!TTS_IS_HEAPTUPLE(slot)))
1364  elog(ERROR, "trying to store a heap tuple into wrong type of slot");
1365  tts_heap_store_tuple(slot, tuple, shouldFree);
1366 
1367  slot->tts_tableOid = tuple->t_tableOid;
1368 
1369  return slot;
1370 }
Oid tts_tableOid
Definition: tuptable.h:131
#define ERROR
Definition: elog.h:46
Oid t_tableOid
Definition: htup.h:66
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
#define TTS_IS_HEAPTUPLE(slot)
Definition: tuptable.h:229
#define Assert(condition)
Definition: c.h:804
#define elog(elevel,...)
Definition: elog.h:232
static void tts_heap_store_tuple(TupleTableSlot *slot, HeapTuple tuple, bool shouldFree)
Definition: execTuples.c:448
#define unlikely(x)
Definition: c.h:273

◆ ExecStoreHeapTupleDatum()

void ExecStoreHeapTupleDatum ( Datum  data,
TupleTableSlot slot 
)

Definition at line 1606 of file execTuples.c.

References 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().

1607 {
1608  HeapTupleData tuple = {0};
1609  HeapTupleHeader td;
1610 
1611  td = DatumGetHeapTupleHeader(data);
1612 
1614  tuple.t_self = td->t_ctid;
1615  tuple.t_data = td;
1616 
1617  ExecClearTuple(slot);
1618 
1619  heap_deform_tuple(&tuple, slot->tts_tupleDescriptor,
1620  slot->tts_values, slot->tts_isnull);
1621  ExecStoreVirtualTuple(slot);
1622 }
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:425
Datum * tts_values
Definition: tuptable.h:126
#define DatumGetHeapTupleHeader(X)
Definition: fmgr.h:295
HeapTupleHeader t_data
Definition: htup.h:68
ItemPointerData t_ctid
Definition: htup_details.h:160
ItemPointerData t_self
Definition: htup.h:65
uint32 t_len
Definition: htup.h:64
bool * tts_isnull
Definition: tuptable.h:128
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull)
Definition: heaptuple.c:1249
TupleTableSlot * ExecStoreVirtualTuple(TupleTableSlot *slot)
Definition: execTuples.c:1552
#define HeapTupleHeaderGetDatumLength(tup)
Definition: htup_details.h:451

◆ ExecStoreMinimalTuple()

TupleTableSlot* ExecStoreMinimalTuple ( MinimalTuple  mtup,
TupleTableSlot slot,
bool  shouldFree 
)

Definition at line 1446 of file execTuples.c.

References Assert, elog, ERROR, TTS_IS_MINIMALTUPLE, tts_minimal_store_tuple(), TupleTableSlot::tts_tupleDescriptor, and unlikely.

Referenced by agg_refill_hash_table(), agg_retrieve_hash_table_in_memory(), ExecMemoize(), ExecParallelScanHashBucket(), ExecScanHashBucket(), ExecScanHashTableForUnmatched(), findPartialMatch(), gather_getnext(), gather_merge_readnext(), MemoizeHash_equal(), prepare_probe_slot(), setop_retrieve_hash_table(), tts_minimal_copyslot(), TupleHashTableHash_internal(), TupleHashTableMatch(), tuplesort_gettupleslot(), and tuplestore_gettupleslot().

1449 {
1450  /*
1451  * sanity checks
1452  */
1453  Assert(mtup != NULL);
1454  Assert(slot != NULL);
1455  Assert(slot->tts_tupleDescriptor != NULL);
1456 
1457  if (unlikely(!TTS_IS_MINIMALTUPLE(slot)))
1458  elog(ERROR, "trying to store a minimal tuple into wrong type of slot");
1459  tts_minimal_store_tuple(slot, mtup, shouldFree);
1460 
1461  return slot;
1462 }
#define TTS_IS_MINIMALTUPLE(slot)
Definition: tuptable.h:230
#define ERROR
Definition: elog.h:46
static void tts_minimal_store_tuple(TupleTableSlot *slot, MinimalTuple mtup, bool shouldFree)
Definition: execTuples.c:620
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
#define Assert(condition)
Definition: c.h:804
#define elog(elevel,...)
Definition: elog.h:232
#define unlikely(x)
Definition: c.h:273

◆ ExecStorePinnedBufferHeapTuple()

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

Definition at line 1418 of file execTuples.c.

References Assert, BufferIsValid, elog, ERROR, 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().

1421 {
1422  /*
1423  * sanity checks
1424  */
1425  Assert(tuple != NULL);
1426  Assert(slot != NULL);
1427  Assert(slot->tts_tupleDescriptor != NULL);
1428  Assert(BufferIsValid(buffer));
1429 
1430  if (unlikely(!TTS_IS_BUFFERTUPLE(slot)))
1431  elog(ERROR, "trying to store an on-disk heap tuple into wrong type of slot");
1432  tts_buffer_heap_store_tuple(slot, tuple, buffer, true);
1433 
1434  slot->tts_tableOid = tuple->t_tableOid;
1435 
1436  return slot;
1437 }
Oid tts_tableOid
Definition: tuptable.h:131
static void tts_buffer_heap_store_tuple(TupleTableSlot *slot, HeapTuple tuple, Buffer buffer, bool transfer_pin)
Definition: execTuples.c:859
#define ERROR
Definition: elog.h:46
Oid t_tableOid
Definition: htup.h:66
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
#define TTS_IS_BUFFERTUPLE(slot)
Definition: tuptable.h:231
#define Assert(condition)
Definition: c.h:804
#define BufferIsValid(bufnum)
Definition: bufmgr.h:123
#define elog(elevel,...)
Definition: elog.h:232
#define unlikely(x)
Definition: c.h:273

◆ ExecStoreVirtualTuple()

TupleTableSlot* ExecStoreVirtualTuple ( TupleTableSlot slot)

Definition at line 1552 of file execTuples.c.

References Assert, TupleDescData::natts, TTS_EMPTY, TTS_FLAG_EMPTY, TupleTableSlot::tts_flags, TupleTableSlot::tts_nvalid, and TupleTableSlot::tts_tupleDescriptor.

Referenced by agg_retrieve_hash_table_in_memory(), apply_returning_filter(), ATRewriteTable(), CopyFrom(), copyTemplateDependencies(), do_tup_output(), ExecComputeStoredGenerated(), ExecEvalAggOrderedTransTuple(), ExecFilterJunk(), ExecForceStoreHeapTuple(), ExecForceStoreMinimalTuple(), ExecProjectSRF(), ExecSort(), ExecStoreAllNullTuple(), ExecStoreHeapTupleDatum(), execute_attr_map_slot(), fileIterateForeignScan(), FunctionNext(), hashagg_spill_tuple(), hypothetical_dense_rank_final(), hypothetical_rank_common(), InsertPgAttributeTuples(), ordered_set_transition_multi(), prepare_hash_slot(), prepare_probe_slot(), recordMultipleDependencies(), RI_Initial_Check(), RI_PartitionRemove_Check(), slot_modify_data(), slot_store_data(), StoreIndexTuple(), and ValuesNext().

1553 {
1554  /*
1555  * sanity checks
1556  */
1557  Assert(slot != NULL);
1558  Assert(slot->tts_tupleDescriptor != NULL);
1559  Assert(TTS_EMPTY(slot));
1560 
1561  slot->tts_flags &= ~TTS_FLAG_EMPTY;
1562  slot->tts_nvalid = slot->tts_tupleDescriptor->natts;
1563 
1564  return slot;
1565 }
#define TTS_FLAG_EMPTY
Definition: tuptable.h:96
#define TTS_EMPTY(slot)
Definition: tuptable.h:97
uint16 tts_flags
Definition: tuptable.h:119
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
#define Assert(condition)
Definition: c.h:804
AttrNumber tts_nvalid
Definition: tuptable.h:121

◆ MakeSingleTupleTableSlot()

◆ MakeTupleTableSlot()

TupleTableSlot* MakeTupleTableSlot ( TupleDesc  tupleDesc,
const TupleTableSlotOps tts_ops 
)

Definition at line 1112 of file execTuples.c.

References TupleTableSlotOps::base_slot_size, CurrentMemoryContext, TupleTableSlotOps::init, MAXALIGN, TupleDescData::natts, palloc0(), PinTupleDesc, T_TupleTableSlot, 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(), and MakeSingleTupleTableSlot().

1114 {
1115  Size basesz,
1116  allocsz;
1117  TupleTableSlot *slot;
1118 
1119  basesz = tts_ops->base_slot_size;
1120 
1121  /*
1122  * When a fixed descriptor is specified, we can reduce overhead by
1123  * allocating the entire slot in one go.
1124  */
1125  if (tupleDesc)
1126  allocsz = MAXALIGN(basesz) +
1127  MAXALIGN(tupleDesc->natts * sizeof(Datum)) +
1128  MAXALIGN(tupleDesc->natts * sizeof(bool));
1129  else
1130  allocsz = basesz;
1131 
1132  slot = palloc0(allocsz);
1133  /* const for optimization purposes, OK to modify at allocation time */
1134  *((const TupleTableSlotOps **) &slot->tts_ops) = tts_ops;
1135  slot->type = T_TupleTableSlot;
1136  slot->tts_flags |= TTS_FLAG_EMPTY;
1137  if (tupleDesc != NULL)
1138  slot->tts_flags |= TTS_FLAG_FIXED;
1139  slot->tts_tupleDescriptor = tupleDesc;
1141  slot->tts_nvalid = 0;
1142 
1143  if (tupleDesc != NULL)
1144  {
1145  slot->tts_values = (Datum *)
1146  (((char *) slot)
1147  + MAXALIGN(basesz));
1148  slot->tts_isnull = (bool *)
1149  (((char *) slot)
1150  + MAXALIGN(basesz)
1151  + MAXALIGN(tupleDesc->natts * sizeof(Datum)));
1152 
1153  PinTupleDesc(tupleDesc);
1154  }
1155 
1156  /*
1157  * And allow slot type specific initialization.
1158  */
1159  slot->tts_ops->init(slot);
1160 
1161  return slot;
1162 }
#define TTS_FLAG_EMPTY
Definition: tuptable.h:96
const TupleTableSlotOps *const tts_ops
Definition: tuptable.h:122
MemoryContext tts_mcxt
Definition: tuptable.h:129
Datum * tts_values
Definition: tuptable.h:126
NodeTag type
Definition: tuptable.h:117
uint16 tts_flags
Definition: tuptable.h:119
void(* init)(TupleTableSlot *slot)
Definition: tuptable.h:141
bool * tts_isnull
Definition: tuptable.h:128
MemoryContext CurrentMemoryContext
Definition: mcxt.c:42
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
void * palloc0(Size size)
Definition: mcxt.c:1093
uintptr_t Datum
Definition: postgres.h:411
#define TTS_FLAG_FIXED
Definition: tuptable.h:108
size_t Size
Definition: c.h:540
#define MAXALIGN(LEN)
Definition: c.h:757
#define PinTupleDesc(tupdesc)
Definition: tupdesc.h:116
AttrNumber tts_nvalid
Definition: tuptable.h:121
size_t base_slot_size
Definition: tuptable.h:138

◆ slot_attisnull()

static bool slot_attisnull ( TupleTableSlot slot,
int  attnum 
)
inlinestatic

Definition at line 367 of file tuptable.h.

References AssertArg, slot_getsomeattrs(), TupleTableSlot::tts_isnull, and TupleTableSlot::tts_nvalid.

Referenced by AlterDomainNotNull(), ATRewriteTable(), ExecConstraints(), ri_NullCheck(), slotAllNulls(), and slotNoNulls().

368 {
369  AssertArg(attnum > 0);
370 
371  if (attnum > slot->tts_nvalid)
372  slot_getsomeattrs(slot, attnum);
373 
374  return slot->tts_isnull[attnum - 1];
375 }
static void slot_getsomeattrs(TupleTableSlot *slot, int attnum)
Definition: tuptable.h:341
bool * tts_isnull
Definition: tuptable.h:128
#define AssertArg(condition)
Definition: c.h:806
int16 attnum
Definition: pg_attribute.h:83
AttrNumber tts_nvalid
Definition: tuptable.h:121

◆ slot_getallattrs()

◆ slot_getattr()

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

◆ slot_getmissingattrs()

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

Definition at line 1868 of file execTuples.c.

References AttrMissing::am_present, AttrMissing::am_value, TupleDescData::constr, TupleConstr::missing, TupleTableSlot::tts_isnull, TupleTableSlot::tts_tupleDescriptor, and TupleTableSlot::tts_values.

Referenced by slot_getsomeattrs_int().

1869 {
1870  AttrMissing *attrmiss = NULL;
1871 
1872  if (slot->tts_tupleDescriptor->constr)
1873  attrmiss = slot->tts_tupleDescriptor->constr->missing;
1874 
1875  if (!attrmiss)
1876  {
1877  /* no missing values array at all, so just fill everything in as NULL */
1878  memset(slot->tts_values + startAttNum, 0,
1879  (lastAttNum - startAttNum) * sizeof(Datum));
1880  memset(slot->tts_isnull + startAttNum, 1,
1881  (lastAttNum - startAttNum) * sizeof(bool));
1882  }
1883  else
1884  {
1885  int missattnum;
1886 
1887  /* if there is a missing values array we must process them one by one */
1888  for (missattnum = startAttNum;
1889  missattnum < lastAttNum;
1890  missattnum++)
1891  {
1892  slot->tts_values[missattnum] = attrmiss[missattnum].am_value;
1893  slot->tts_isnull[missattnum] = !attrmiss[missattnum].am_present;
1894  }
1895  }
1896 }
Datum * tts_values
Definition: tuptable.h:126
bool * tts_isnull
Definition: tuptable.h:128
TupleConstr * constr
Definition: tupdesc.h:85
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
uintptr_t Datum
Definition: postgres.h:411
struct AttrMissing * missing
Definition: tupdesc.h:41

◆ slot_getsomeattrs()

static void slot_getsomeattrs ( TupleTableSlot slot,
int  attnum 
)
inlinestatic

Definition at line 341 of file tuptable.h.

References slot_getsomeattrs_int(), and TupleTableSlot::tts_nvalid.

Referenced by ExecInterpExpr(), ExecSort(), hashagg_spill_tuple(), prepare_hash_slot(), prepare_projection_slot(), process_ordered_aggregate_multi(), slot_attisnull(), slot_getallattrs(), and slot_getattr().

342 {
343  if (slot->tts_nvalid < attnum)
345 }
int16 attnum
Definition: pg_attribute.h:83
void slot_getsomeattrs_int(TupleTableSlot *slot, int attnum)
Definition: execTuples.c:1902
AttrNumber tts_nvalid
Definition: tuptable.h:121

◆ slot_getsomeattrs_int()

void slot_getsomeattrs_int ( TupleTableSlot slot,
int  attnum 
)

Definition at line 1902 of file execTuples.c.

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().

1903 {
1904  /* Check for caller errors */
1905  Assert(slot->tts_nvalid < attnum); /* checked in slot_getsomeattrs */
1906  Assert(attnum > 0);
1907 
1908  if (unlikely(attnum > slot->tts_tupleDescriptor->natts))
1909  elog(ERROR, "invalid attribute number %d", attnum);
1910 
1911  /* Fetch as many attributes as possible from the underlying tuple. */
1912  slot->tts_ops->getsomeattrs(slot, attnum);
1913 
1914  /*
1915  * If the underlying tuple doesn't have enough attributes, tuple
1916  * descriptor must have the missing attributes.
1917  */
1918  if (unlikely(slot->tts_nvalid < attnum))
1919  {
1920  slot_getmissingattrs(slot, slot->tts_nvalid, attnum);
1921  slot->tts_nvalid = attnum;
1922  }
1923 }
const TupleTableSlotOps *const tts_ops
Definition: tuptable.h:122
#define ERROR
Definition: elog.h:46
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
int16 attnum
Definition: pg_attribute.h:83
#define Assert(condition)
Definition: c.h:804
void(* getsomeattrs)(TupleTableSlot *slot, int natts)
Definition: tuptable.h:161
void slot_getmissingattrs(TupleTableSlot *slot, int startAttNum, int lastAttNum)
Definition: execTuples.c:1868
#define elog(elevel,...)
Definition: elog.h:232
#define unlikely(x)
Definition: c.h:273
AttrNumber tts_nvalid
Definition: tuptable.h:121

◆ slot_getsysattr()

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

Definition at line 402 of file tuptable.h.

References AssertArg, TupleTableSlotOps::getsysattr, ObjectIdGetDatum, PointerGetDatum, SelfItemPointerAttributeNumber, TableOidAttributeNumber, TupleTableSlot::tts_ops, TupleTableSlot::tts_tableOid, and TupleTableSlot::tts_tid.

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

403 {
404  AssertArg(attnum < 0); /* caller error */
405 
407  {
408  *isnull = false;
409  return ObjectIdGetDatum(slot->tts_tableOid);
410  }
412  {
413  *isnull = false;
414  return PointerGetDatum(&slot->tts_tid);
415  }
416 
417  /* Fetch the system attribute from the underlying tuple. */
418  return slot->tts_ops->getsysattr(slot, attnum, isnull);
419 }
Oid tts_tableOid
Definition: tuptable.h:131
Datum(* getsysattr)(TupleTableSlot *slot, int attnum, bool *isnull)
Definition: tuptable.h:168
#define PointerGetDatum(X)
Definition: postgres.h:600
const TupleTableSlotOps *const tts_ops
Definition: tuptable.h:122
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define TableOidAttributeNumber
Definition: sysattr.h:26
#define AssertArg(condition)
Definition: c.h:806
int16 attnum
Definition: pg_attribute.h:83
#define SelfItemPointerAttributeNumber
Definition: sysattr.h:21
ItemPointerData tts_tid
Definition: tuptable.h:130

Variable Documentation

◆ TTSOpsBufferHeapTuple

PGDLLIMPORT const TupleTableSlotOps TTSOpsBufferHeapTuple

◆ TTSOpsHeapTuple

◆ TTSOpsMinimalTuple

◆ TTSOpsVirtual