PostgreSQL Source Code  git master
execTuples.c File Reference
#include "postgres.h"
#include "access/htup_details.h"
#include "access/tupdesc_details.h"
#include "access/tuptoaster.h"
#include "funcapi.h"
#include "catalog/pg_type.h"
#include "nodes/nodeFuncs.h"
#include "storage/bufmgr.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
#include "utils/typcache.h"
Include dependency graph for execTuples.c:

Go to the source code of this file.

Functions

static TupleDesc ExecTypeFromTLInternal (List *targetList, bool skipjunk)
 
static pg_attribute_always_inline void slot_deform_heap_tuple (TupleTableSlot *slot, HeapTuple tuple, uint32 *offp, int natts)
 
static void tts_buffer_heap_store_tuple (TupleTableSlot *slot, HeapTuple tuple, Buffer buffer, bool transfer_pin)
 
static void tts_heap_store_tuple (TupleTableSlot *slot, HeapTuple tuple, bool shouldFree)
 
static void tts_virtual_init (TupleTableSlot *slot)
 
static void tts_virtual_release (TupleTableSlot *slot)
 
static void tts_virtual_clear (TupleTableSlot *slot)
 
static void tts_virtual_getsomeattrs (TupleTableSlot *slot, int natts)
 
static Datum tts_virtual_getsysattr (TupleTableSlot *slot, int attnum, bool *isnull)
 
static void tts_virtual_materialize (TupleTableSlot *slot)
 
static void tts_virtual_copyslot (TupleTableSlot *dstslot, TupleTableSlot *srcslot)
 
static HeapTuple tts_virtual_copy_heap_tuple (TupleTableSlot *slot)
 
static MinimalTuple tts_virtual_copy_minimal_tuple (TupleTableSlot *slot)
 
static void tts_heap_init (TupleTableSlot *slot)
 
static void tts_heap_release (TupleTableSlot *slot)
 
static void tts_heap_clear (TupleTableSlot *slot)
 
static void tts_heap_getsomeattrs (TupleTableSlot *slot, int natts)
 
static Datum tts_heap_getsysattr (TupleTableSlot *slot, int attnum, bool *isnull)
 
static void tts_heap_materialize (TupleTableSlot *slot)
 
static void tts_heap_copyslot (TupleTableSlot *dstslot, TupleTableSlot *srcslot)
 
static HeapTuple tts_heap_get_heap_tuple (TupleTableSlot *slot)
 
static HeapTuple tts_heap_copy_heap_tuple (TupleTableSlot *slot)
 
static MinimalTuple tts_heap_copy_minimal_tuple (TupleTableSlot *slot)
 
static void tts_minimal_init (TupleTableSlot *slot)
 
static void tts_minimal_release (TupleTableSlot *slot)
 
static void tts_minimal_clear (TupleTableSlot *slot)
 
static void tts_minimal_getsomeattrs (TupleTableSlot *slot, int natts)
 
static Datum tts_minimal_getsysattr (TupleTableSlot *slot, int attnum, bool *isnull)
 
static void tts_minimal_materialize (TupleTableSlot *slot)
 
static void tts_minimal_copyslot (TupleTableSlot *dstslot, TupleTableSlot *srcslot)
 
static MinimalTuple tts_minimal_get_minimal_tuple (TupleTableSlot *slot)
 
static HeapTuple tts_minimal_copy_heap_tuple (TupleTableSlot *slot)
 
static MinimalTuple tts_minimal_copy_minimal_tuple (TupleTableSlot *slot)
 
static void tts_minimal_store_tuple (TupleTableSlot *slot, MinimalTuple mtup, bool shouldFree)
 
static void tts_buffer_heap_init (TupleTableSlot *slot)
 
static void tts_buffer_heap_release (TupleTableSlot *slot)
 
static void tts_buffer_heap_clear (TupleTableSlot *slot)
 
static void tts_buffer_heap_getsomeattrs (TupleTableSlot *slot, int natts)
 
static Datum tts_buffer_heap_getsysattr (TupleTableSlot *slot, int attnum, bool *isnull)
 
static void tts_buffer_heap_materialize (TupleTableSlot *slot)
 
static void tts_buffer_heap_copyslot (TupleTableSlot *dstslot, TupleTableSlot *srcslot)
 
static HeapTuple tts_buffer_heap_get_heap_tuple (TupleTableSlot *slot)
 
static HeapTuple tts_buffer_heap_copy_heap_tuple (TupleTableSlot *slot)
 
static MinimalTuple tts_buffer_heap_copy_minimal_tuple (TupleTableSlot *slot)
 
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)
 
TupleTableSlotExecStoreBufferHeapTuple (HeapTuple tuple, TupleTableSlot *slot, Buffer buffer)
 
TupleTableSlotExecStorePinnedBufferHeapTuple (HeapTuple tuple, TupleTableSlot *slot, Buffer buffer)
 
TupleTableSlotExecStoreMinimalTuple (MinimalTuple mtup, TupleTableSlot *slot, bool shouldFree)
 
void ExecForceStoreHeapTuple (HeapTuple tuple, 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 ExecInitResultTypeTL (PlanState *planstate)
 
void ExecInitResultSlot (PlanState *planstate, const TupleTableSlotOps *tts_ops)
 
void ExecInitResultTupleSlotTL (PlanState *planstate, const TupleTableSlotOps *tts_ops)
 
void ExecInitScanTupleSlot (EState *estate, ScanState *scanstate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
 
TupleTableSlotExecInitExtraTupleSlot (EState *estate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
 
TupleTableSlotExecInitNullTupleSlot (EState *estate, TupleDesc tupType, const TupleTableSlotOps *tts_ops)
 
void slot_getmissingattrs (TupleTableSlot *slot, int startAttNum, int lastAttNum)
 
void slot_getsomeattrs_int (TupleTableSlot *slot, int attnum)
 
TupleDesc ExecTypeFromTL (List *targetList)
 
TupleDesc ExecCleanTypeFromTL (List *targetList)
 
TupleDesc ExecTypeFromExprList (List *exprList)
 
void ExecTypeSetColNames (TupleDesc typeInfo, List *namesList)
 
TupleDesc BlessTupleDesc (TupleDesc tupdesc)
 
AttInMetadataTupleDescGetAttInMetadata (TupleDesc tupdesc)
 
HeapTuple BuildTupleFromCStrings (AttInMetadata *attinmeta, char **values)
 
Datum HeapTupleHeaderGetDatum (HeapTupleHeader tuple)
 
TupOutputStatebegin_tup_output_tupdesc (DestReceiver *dest, TupleDesc tupdesc, const TupleTableSlotOps *tts_ops)
 
void do_tup_output (TupOutputState *tstate, Datum *values, bool *isnull)
 
void do_text_output_multiline (TupOutputState *tstate, const char *txt)
 
void end_tup_output (TupOutputState *tstate)
 

Variables

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

Function Documentation

◆ begin_tup_output_tupdesc()

TupOutputState* begin_tup_output_tupdesc ( DestReceiver dest,
TupleDesc  tupdesc,
const TupleTableSlotOps tts_ops 
)

Definition at line 2231 of file execTuples.c.

References CMD_SELECT, generate_unaccent_rules::dest, TupOutputState::dest, MakeSingleTupleTableSlot(), palloc(), _DestReceiver::rStartup, and TupOutputState::slot.

Referenced by CreateReplicationSlot(), ExecuteCallStmt(), ExplainQuery(), IdentifySystem(), ShowAllGUCConfig(), ShowGUCConfigOption(), and StartReplication().

2234 {
2235  TupOutputState *tstate;
2236 
2237  tstate = (TupOutputState *) palloc(sizeof(TupOutputState));
2238 
2239  tstate->slot = MakeSingleTupleTableSlot(tupdesc, tts_ops);
2240  tstate->dest = dest;
2241 
2242  tstate->dest->rStartup(tstate->dest, (int) CMD_SELECT, tupdesc);
2243 
2244  return tstate;
2245 }
TupleTableSlot * MakeSingleTupleTableSlot(TupleDesc tupdesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1202
TupleTableSlot * slot
Definition: executor.h:457
void(* rStartup)(DestReceiver *self, int operation, TupleDesc typeinfo)
Definition: dest.h:121
void * palloc(Size size)
Definition: mcxt.c:924
DestReceiver * dest
Definition: executor.h:458

◆ BlessTupleDesc()

TupleDesc BlessTupleDesc ( TupleDesc  tupdesc)

Definition at line 2047 of file execTuples.c.

References assign_record_type_typmod(), TupleDescData::tdtypeid, and TupleDescData::tdtypmod.

Referenced by aclexplode(), brin_metapage_info(), each_worker(), each_worker_jsonb(), elements_worker(), elements_worker_jsonb(), exec_eval_datum(), ExecEvalWholeRowVar(), ExecInitExprRec(), ExecInitFunctionScan(), hash_bitmap_info(), hash_metapage_info(), hash_page_items(), hash_page_stats(), init_sql_fcache(), pg_buffercache_pages(), pg_control_checkpoint(), pg_control_init(), pg_control_recovery(), pg_control_system(), pg_get_object_address(), pg_identify_object(), pg_identify_object_as_address(), pg_last_committed_xact(), pg_lock_status(), pg_ls_dir_files(), pg_partition_tree(), pg_prepared_xact(), pg_sequence_parameters(), pg_stat_file(), pg_stat_get_archiver(), pg_stats_ext_mcvlist_items(), pg_timezone_abbrevs(), pg_timezone_names(), pg_visibility_map_summary(), pg_visibility_tupdesc(), pg_walfile_name_offset(), pgstathashindex(), PLy_output_setup_record(), setup_firstcall(), ssl_extension_info(), test_predtest(), ts_setup_firstcall(), tsvector_unnest(), and TupleDescGetAttInMetadata().

2048 {
2049  if (tupdesc->tdtypeid == RECORDOID &&
2050  tupdesc->tdtypmod < 0)
2051  assign_record_type_typmod(tupdesc);
2052 
2053  return tupdesc; /* just for notational convenience */
2054 }
void assign_record_type_typmod(TupleDesc tupDesc)
Definition: typcache.c:1772
int32 tdtypmod
Definition: tupdesc.h:83
Oid tdtypeid
Definition: tupdesc.h:82

◆ BuildTupleFromCStrings()

HeapTuple BuildTupleFromCStrings ( AttInMetadata attinmeta,
char **  values 
)

Definition at line 2111 of file execTuples.c.

References AttInMetadata::attinfuncs, AttInMetadata::attioparams, AttInMetadata::atttypmods, heap_form_tuple(), i, InputFunctionCall(), TupleDescData::natts, palloc(), pfree(), AttInMetadata::tupdesc, and TupleDescAttr.

Referenced by bt_metap(), bt_page_print_tuples(), bt_page_stats(), build_pgstattuple_type(), build_tuplestore_recursively(), crosstab(), dblink_get_pkey(), get_crosstab_tuplestore(), libpqrcv_processTuples(), materializeResult(), pg_config(), pg_get_keywords(), pg_get_multixact_members(), pg_logdir_ls_internal(), pgp_armor_headers(), pgrowlocks(), pgstatindex_impl(), pltcl_build_tuple_result(), prs_process_call(), show_all_settings(), storeRow(), ts_process_call(), tt_process_call(), and xpath_table().

2112 {
2113  TupleDesc tupdesc = attinmeta->tupdesc;
2114  int natts = tupdesc->natts;
2115  Datum *dvalues;
2116  bool *nulls;
2117  int i;
2118  HeapTuple tuple;
2119 
2120  dvalues = (Datum *) palloc(natts * sizeof(Datum));
2121  nulls = (bool *) palloc(natts * sizeof(bool));
2122 
2123  /*
2124  * Call the "in" function for each non-dropped attribute, even for nulls,
2125  * to support domains.
2126  */
2127  for (i = 0; i < natts; i++)
2128  {
2129  if (!TupleDescAttr(tupdesc, i)->attisdropped)
2130  {
2131  /* Non-dropped attributes */
2132  dvalues[i] = InputFunctionCall(&attinmeta->attinfuncs[i],
2133  values[i],
2134  attinmeta->attioparams[i],
2135  attinmeta->atttypmods[i]);
2136  if (values[i] != NULL)
2137  nulls[i] = false;
2138  else
2139  nulls[i] = true;
2140  }
2141  else
2142  {
2143  /* Handle dropped attributes by setting to NULL */
2144  dvalues[i] = (Datum) 0;
2145  nulls[i] = true;
2146  }
2147  }
2148 
2149  /*
2150  * Form a tuple
2151  */
2152  tuple = heap_form_tuple(tupdesc, dvalues, nulls);
2153 
2154  /*
2155  * Release locally palloc'd space. XXX would probably be good to pfree
2156  * values of pass-by-reference datums, as well.
2157  */
2158  pfree(dvalues);
2159  pfree(nulls);
2160 
2161  return tuple;
2162 }
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:92
int32 * atttypmods
Definition: funcapi.h:48
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
Definition: heaptuple.c:1020
Oid * attioparams
Definition: funcapi.h:45
void pfree(void *pointer)
Definition: mcxt.c:1031
TupleDesc tupdesc
Definition: funcapi.h:39
uintptr_t Datum
Definition: postgres.h:367
Datum InputFunctionCall(FmgrInfo *flinfo, char *str, Oid typioparam, int32 typmod)
Definition: fmgr.c:1531
static Datum values[MAXATTR]
Definition: bootstrap.c:167
void * palloc(Size size)
Definition: mcxt.c:924
int i
FmgrInfo * attinfuncs
Definition: funcapi.h:42

◆ do_text_output_multiline()

void do_text_output_multiline ( TupOutputState tstate,
const char *  txt 
)

Definition at line 2279 of file execTuples.c.

References cstring_to_text_with_len(), DatumGetPointer, do_tup_output(), pfree(), PointerGetDatum, and values.

Referenced by ExplainQuery().

2280 {
2281  Datum values[1];
2282  bool isnull[1] = {false};
2283 
2284  while (*txt)
2285  {
2286  const char *eol;
2287  int len;
2288 
2289  eol = strchr(txt, '\n');
2290  if (eol)
2291  {
2292  len = eol - txt;
2293  eol++;
2294  }
2295  else
2296  {
2297  len = strlen(txt);
2298  eol = txt + len;
2299  }
2300 
2301  values[0] = PointerGetDatum(cstring_to_text_with_len(txt, len));
2302  do_tup_output(tstate, values, isnull);
2303  pfree(DatumGetPointer(values[0]));
2304  txt = eol;
2305  }
2306 }
#define PointerGetDatum(X)
Definition: postgres.h:556
void do_tup_output(TupOutputState *tstate, Datum *values, bool *isnull)
Definition: execTuples.c:2251
void pfree(void *pointer)
Definition: mcxt.c:1031
text * cstring_to_text_with_len(const char *s, int len)
Definition: varlena.c:183
uintptr_t Datum
Definition: postgres.h:367
#define DatumGetPointer(X)
Definition: postgres.h:549
static Datum values[MAXATTR]
Definition: bootstrap.c:167

◆ do_tup_output()

void do_tup_output ( TupOutputState tstate,
Datum values,
bool isnull 
)

Definition at line 2251 of file execTuples.c.

References TupOutputState::dest, ExecClearTuple(), ExecStoreVirtualTuple(), TupleDescData::natts, _DestReceiver::receiveSlot, TupOutputState::slot, TupleTableSlot::tts_isnull, TupleTableSlot::tts_tupleDescriptor, and TupleTableSlot::tts_values.

Referenced by CreateReplicationSlot(), do_text_output_multiline(), IdentifySystem(), ShowAllGUCConfig(), and StartReplication().

2252 {
2253  TupleTableSlot *slot = tstate->slot;
2254  int natts = slot->tts_tupleDescriptor->natts;
2255 
2256  /* make sure the slot is clear */
2257  ExecClearTuple(slot);
2258 
2259  /* insert data */
2260  memcpy(slot->tts_values, values, natts * sizeof(Datum));
2261  memcpy(slot->tts_isnull, isnull, natts * sizeof(bool));
2262 
2263  /* mark slot as containing a virtual tuple */
2264  ExecStoreVirtualTuple(slot);
2265 
2266  /* send the tuple to the receiver */
2267  (void) tstate->dest->receiveSlot(slot, tstate->dest);
2268 
2269  /* clean up */
2270  ExecClearTuple(slot);
2271 }
bool(* receiveSlot)(TupleTableSlot *slot, DestReceiver *self)
Definition: dest.h:118
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:426
Datum * tts_values
Definition: tuptable.h:126
TupleTableSlot * slot
Definition: executor.h:457
bool * tts_isnull
Definition: tuptable.h:128
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
uintptr_t Datum
Definition: postgres.h:367
static Datum values[MAXATTR]
Definition: bootstrap.c:167
DestReceiver * dest
Definition: executor.h:458
TupleTableSlot * ExecStoreVirtualTuple(TupleTableSlot *slot)
Definition: execTuples.c:1516

◆ end_tup_output()

void end_tup_output ( TupOutputState tstate)

Definition at line 2309 of file execTuples.c.

References TupOutputState::dest, ExecDropSingleTupleTableSlot(), pfree(), _DestReceiver::rShutdown, and TupOutputState::slot.

Referenced by CreateReplicationSlot(), ExecuteCallStmt(), ExplainQuery(), IdentifySystem(), ShowAllGUCConfig(), ShowGUCConfigOption(), and StartReplication().

2310 {
2311  tstate->dest->rShutdown(tstate->dest);
2312  /* note that destroying the dest is not ours to do */
2314  pfree(tstate);
2315 }
TupleTableSlot * slot
Definition: executor.h:457
void pfree(void *pointer)
Definition: mcxt.c:1031
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
Definition: execTuples.c:1218
void(* rShutdown)(DestReceiver *self)
Definition: dest.h:124
DestReceiver * dest
Definition: executor.h:458

◆ ExecAllocTableSlot()

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

Definition at line 1135 of file execTuples.c.

References lappend(), and MakeTupleTableSlot().

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

1137 {
1138  TupleTableSlot *slot = MakeTupleTableSlot(desc, tts_ops);
1139 
1140  *tupleTable = lappend(*tupleTable, slot);
1141 
1142  return slot;
1143 }
List * lappend(List *list, void *datum)
Definition: list.c:321
TupleTableSlot * MakeTupleTableSlot(TupleDesc tupleDesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1076

◆ ExecCleanTypeFromTL()

TupleDesc ExecCleanTypeFromTL ( List targetList)

Definition at line 1915 of file execTuples.c.

References ExecTypeFromTLInternal().

Referenced by ExecInitJunkFilter(), PlanCacheComputeResultDesc(), and PortalStart().

1916 {
1917  return ExecTypeFromTLInternal(targetList, true);
1918 }
static TupleDesc ExecTypeFromTLInternal(List *targetList, bool skipjunk)
Definition: execTuples.c:1921

◆ ExecDropSingleTupleTableSlot()

void ExecDropSingleTupleTableSlot ( TupleTableSlot slot)

Definition at line 1218 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(), afterTriggerInvokeEvents(), AlterDomainNotNull(), ATRewriteTable(), CatalogIndexInsert(), check_default_partition_contents(), check_exclusion_or_unique_constraint(), compute_index_stats(), CopyMultiInsertBufferCleanup(), CopyTo(), DefineQueryRewrite(), end_tup_output(), ExecCleanupTupleRouting(), 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(), RelationFindReplTupleSeq(), RI_Initial_Check(), RunFromStore(), systable_endscan(), systable_endscan_ordered(), table_index_fetch_tuple_check(), tuplesort_end(), unique_key_recheck(), validateCheckConstraint(), validateDomainConstraint(), and validateForeignKeyConstraint().

1219 {
1220  /* This should match ExecResetTupleTable's processing of one slot */
1221  Assert(IsA(slot, TupleTableSlot));
1222  ExecClearTuple(slot);
1223  slot->tts_ops->release(slot);
1224  if (slot->tts_tupleDescriptor)
1226  if (!TTS_FIXED(slot))
1227  {
1228  if (slot->tts_values)
1229  pfree(slot->tts_values);
1230  if (slot->tts_isnull)
1231  pfree(slot->tts_isnull);
1232  }
1233  pfree(slot);
1234 }
#define TTS_FIXED(slot)
Definition: tuptable.h:109
#define IsA(nodeptr, _type_)
Definition: nodes.h:575
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:426
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:1031
bool * tts_isnull
Definition: tuptable.h:128
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
#define Assert(condition)
Definition: c.h:732
#define ReleaseTupleDesc(tupdesc)
Definition: tupdesc.h:122

◆ ExecFetchSlotHeapTuple()

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

Definition at line 1608 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(), 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(), tqueueReceiveSlot(), and validateForeignKeyConstraint().

1609 {
1610  /*
1611  * sanity checks
1612  */
1613  Assert(slot != NULL);
1614  Assert(!TTS_EMPTY(slot));
1615 
1616  /* Materialize the tuple so that the slot "owns" it, if requested. */
1617  if (materialize)
1618  slot->tts_ops->materialize(slot);
1619 
1620  if (slot->tts_ops->get_heap_tuple == NULL)
1621  {
1622  if (shouldFree)
1623  *shouldFree = true;
1624  return slot->tts_ops->copy_heap_tuple(slot);
1625  }
1626  else
1627  {
1628  if (shouldFree)
1629  *shouldFree = false;
1630  return slot->tts_ops->get_heap_tuple(slot);
1631  }
1632 }
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:732
void(* materialize)(TupleTableSlot *slot)
Definition: tuptable.h:174

◆ ExecFetchSlotHeapTupleDatum()

Datum ExecFetchSlotHeapTupleDatum ( TupleTableSlot slot)

Definition at line 1687 of file execTuples.c.

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

Referenced by ExecMakeFunctionResultSet(), and postquel_get_single_result().

1688 {
1689  HeapTuple tup;
1690  TupleDesc tupdesc;
1691  bool shouldFree;
1692  Datum ret;
1693 
1694  /* Fetch slot's contents in regular-physical-tuple form */
1695  tup = ExecFetchSlotHeapTuple(slot, false, &shouldFree);
1696  tupdesc = slot->tts_tupleDescriptor;
1697 
1698  /* Convert to Datum form */
1699  ret = heap_copy_tuple_as_datum(tup, tupdesc);
1700 
1701  if (shouldFree)
1702  pfree(tup);
1703 
1704  return ret;
1705 }
void pfree(void *pointer)
Definition: mcxt.c:1031
HeapTuple ExecFetchSlotHeapTuple(TupleTableSlot *slot, bool materialize, bool *shouldFree)
Definition: execTuples.c:1608
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:367

◆ ExecFetchSlotMinimalTuple()

MinimalTuple ExecFetchSlotMinimalTuple ( TupleTableSlot slot,
bool shouldFree 
)

Definition at line 1656 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(), and ExecParallelHashTableInsertCurrentBatch().

1658 {
1659  /*
1660  * sanity checks
1661  */
1662  Assert(slot != NULL);
1663  Assert(!TTS_EMPTY(slot));
1664 
1665  if (slot->tts_ops->get_minimal_tuple)
1666  {
1667  if (shouldFree)
1668  *shouldFree = false;
1669  return slot->tts_ops->get_minimal_tuple(slot);
1670  }
1671  else
1672  {
1673  if (shouldFree)
1674  *shouldFree = true;
1675  return slot->tts_ops->copy_minimal_tuple(slot);
1676  }
1677 }
#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:732

◆ ExecForceStoreHeapTuple()

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

Definition at line 1433 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(), IndexNextWithReorder(), IndexOnlyNext(), and store_returning_result().

1436 {
1437  if (TTS_IS_HEAPTUPLE(slot))
1438  {
1439  ExecStoreHeapTuple(tuple, slot, shouldFree);
1440  }
1441  else if (TTS_IS_BUFFERTUPLE(slot))
1442  {
1443  MemoryContext oldContext;
1445 
1446  ExecClearTuple(slot);
1447  slot->tts_flags |= TTS_FLAG_SHOULDFREE;
1448  slot->tts_flags &= ~TTS_FLAG_EMPTY;
1449  oldContext = MemoryContextSwitchTo(slot->tts_mcxt);
1450  bslot->base.tuple = heap_copytuple(tuple);
1451  MemoryContextSwitchTo(oldContext);
1452 
1453  if (shouldFree)
1454  pfree(tuple);
1455  }
1456  else
1457  {
1458  ExecClearTuple(slot);
1460  slot->tts_values, slot->tts_isnull);
1461  ExecStoreVirtualTuple(slot);
1462 
1463  if (shouldFree)
1464  {
1465  ExecMaterializeSlot(slot);
1466  pfree(tuple);
1467  }
1468  }
1469 }
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:426
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:1031
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:444
#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:1316
TupleTableSlot * ExecStoreVirtualTuple(TupleTableSlot *slot)
Definition: execTuples.c:1516

◆ ExecForceStoreMinimalTuple()

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

Definition at line 1476 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().

1479 {
1480  if (TTS_IS_MINIMALTUPLE(slot))
1481  {
1482  tts_minimal_store_tuple(slot, mtup, shouldFree);
1483  }
1484  else
1485  {
1486  HeapTupleData htup;
1487 
1488  ExecClearTuple(slot);
1489 
1490  htup.t_len = mtup->t_len + MINIMAL_TUPLE_OFFSET;
1491  htup.t_data = (HeapTupleHeader) ((char *) mtup - MINIMAL_TUPLE_OFFSET);
1493  slot->tts_values, slot->tts_isnull);
1494  ExecStoreVirtualTuple(slot);
1495 
1496  if (shouldFree)
1497  {
1498  ExecMaterializeSlot(slot);
1499  pfree(mtup);
1500  }
1501  }
1502 }
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:426
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:1031
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:597
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
static void ExecMaterializeSlot(TupleTableSlot *slot)
Definition: tuptable.h:444
#define MINIMAL_TUPLE_OFFSET
Definition: htup_details.h:619
void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull)
Definition: heaptuple.c:1249
TupleTableSlot * ExecStoreVirtualTuple(TupleTableSlot *slot)
Definition: execTuples.c:1516

◆ ExecInitExtraTupleSlot()

◆ ExecInitNullTupleSlot()

TupleTableSlot* ExecInitNullTupleSlot ( EState estate,
TupleDesc  tupType,
const TupleTableSlotOps tts_ops 
)

Definition at line 1811 of file execTuples.c.

References ExecInitExtraTupleSlot(), and ExecStoreAllNullTuple().

Referenced by ExecInitHashJoin(), ExecInitMergeJoin(), and ExecInitNestLoop().

1813 {
1814  TupleTableSlot *slot = ExecInitExtraTupleSlot(estate, tupType, tts_ops);
1815 
1816  return ExecStoreAllNullTuple(slot);
1817 }
TupleTableSlot * ExecInitExtraTupleSlot(EState *estate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1795
TupleTableSlot * ExecStoreAllNullTuple(TupleTableSlot *slot)
Definition: execTuples.c:1540

◆ ExecInitResultSlot()

void ExecInitResultSlot ( PlanState planstate,
const TupleTableSlotOps tts_ops 
)

Definition at line 1743 of file execTuples.c.

References EState::es_tupleTable, ExecAllocTableSlot(), PlanState::ps_ResultTupleDesc, PlanState::ps_ResultTupleSlot, PlanState::resultops, PlanState::resultopsfixed, PlanState::resultopsset, and PlanState::state.

Referenced by ExecConditionalAssignProjectionInfo(), and ExecInitResultTupleSlotTL().

1744 {
1745  TupleTableSlot *slot;
1746 
1747  slot = ExecAllocTableSlot(&planstate->state->es_tupleTable,
1748  planstate->ps_ResultTupleDesc, tts_ops);
1749  planstate->ps_ResultTupleSlot = slot;
1750 
1751  planstate->resultopsfixed = planstate->ps_ResultTupleDesc != NULL;
1752  planstate->resultops = tts_ops;
1753  planstate->resultopsset = true;
1754 }
EState * state
Definition: execnodes.h:947
const TupleTableSlotOps * resultops
Definition: execnodes.h:1020
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:983
bool resultopsset
Definition: execnodes.h:1028
TupleTableSlot * ExecAllocTableSlot(List **tupleTable, TupleDesc desc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1135
TupleDesc ps_ResultTupleDesc
Definition: execnodes.h:982
List * es_tupleTable
Definition: execnodes.h:552
bool resultopsfixed
Definition: execnodes.h:1024

◆ ExecInitResultTupleSlotTL()

void ExecInitResultTupleSlotTL ( PlanState planstate,
const TupleTableSlotOps tts_ops 
)

Definition at line 1763 of file execTuples.c.

References ExecInitResultSlot(), and ExecInitResultTypeTL().

Referenced by ExecInitAgg(), ExecInitAppend(), ExecInitCustomScan(), ExecInitGroup(), ExecInitHash(), ExecInitHashJoin(), ExecInitMaterial(), ExecInitMergeAppend(), ExecInitMergeJoin(), ExecInitModifyTable(), ExecInitNestLoop(), ExecInitProjectSet(), ExecInitResult(), ExecInitSetOp(), ExecInitSort(), ExecInitUnique(), and ExecInitWindowAgg().

1765 {
1766  ExecInitResultTypeTL(planstate);
1767  ExecInitResultSlot(planstate, tts_ops);
1768 }
void ExecInitResultTypeTL(PlanState *planstate)
Definition: execTuples.c:1719
void ExecInitResultSlot(PlanState *planstate, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1743

◆ ExecInitResultTypeTL()

◆ ExecInitScanTupleSlot()

void ExecInitScanTupleSlot ( EState estate,
ScanState scanstate,
TupleDesc  tupledesc,
const TupleTableSlotOps tts_ops 
)

Definition at line 1775 of file execTuples.c.

References EState::es_tupleTable, ExecAllocTableSlot(), ScanState::ps, PlanState::scandesc, PlanState::scanops, PlanState::scanopsfixed, PlanState::scanopsset, and ScanState::ss_ScanTupleSlot.

Referenced by ExecCreateScanSlotFromOuterPlan(), ExecInitBitmapHeapScan(), ExecInitCteScan(), ExecInitCustomScan(), ExecInitForeignScan(), ExecInitFunctionScan(), ExecInitIndexOnlyScan(), ExecInitIndexScan(), ExecInitNamedTuplestoreScan(), ExecInitSampleScan(), ExecInitSeqScan(), ExecInitSubqueryScan(), ExecInitTableFuncScan(), ExecInitTidScan(), ExecInitValuesScan(), and ExecInitWorkTableScan().

1777 {
1778  scanstate->ss_ScanTupleSlot = ExecAllocTableSlot(&estate->es_tupleTable,
1779  tupledesc, tts_ops);
1780  scanstate->ps.scandesc = tupledesc;
1781  scanstate->ps.scanopsfixed = tupledesc != NULL;
1782  scanstate->ps.scanops = tts_ops;
1783  scanstate->ps.scanopsset = true;
1784 }
TupleTableSlot * ss_ScanTupleSlot
Definition: execnodes.h:1283
PlanState ps
Definition: execnodes.h:1280
const TupleTableSlotOps * scanops
Definition: execnodes.h:1017
TupleTableSlot * ExecAllocTableSlot(List **tupleTable, TupleDesc desc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1135
List * es_tupleTable
Definition: execnodes.h:552
TupleDesc scandesc
Definition: execnodes.h:992
bool scanopsfixed
Definition: execnodes.h:1021
bool scanopsset
Definition: execnodes.h:1025

◆ ExecResetTupleTable()

void ExecResetTupleTable ( List tupleTable,
bool  shouldFree 
)

Definition at line 1155 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(), apply_handle_delete(), apply_handle_insert(), apply_handle_update(), CopyFrom(), EvalPlanQualEnd(), and ExecEndPlan().

1157 {
1158  ListCell *lc;
1159 
1160  foreach(lc, tupleTable)
1161  {
1163 
1164  /* Always release resources and reset the slot to empty */
1165  ExecClearTuple(slot);
1166  slot->tts_ops->release(slot);
1167  if (slot->tts_tupleDescriptor)
1168  {
1170  slot->tts_tupleDescriptor = NULL;
1171  }
1172 
1173  /* If shouldFree, release memory occupied by the slot itself */
1174  if (shouldFree)
1175  {
1176  if (!TTS_FIXED(slot))
1177  {
1178  if (slot->tts_values)
1179  pfree(slot->tts_values);
1180  if (slot->tts_isnull)
1181  pfree(slot->tts_isnull);
1182  }
1183  pfree(slot);
1184  }
1185  }
1186 
1187  /* If shouldFree, release the list structure */
1188  if (shouldFree)
1189  list_free(tupleTable);
1190 }
#define TTS_FIXED(slot)
Definition: tuptable.h:109
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:426
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:1031
#define lfirst_node(type, lc)
Definition: pg_list.h:193
bool * tts_isnull
Definition: tuptable.h:128
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
void list_free(List *list)
Definition: list.c:1330
#define ReleaseTupleDesc(tupdesc)
Definition: tupdesc.h:122

◆ ExecSetSlotDescriptor()

void ExecSetSlotDescriptor ( TupleTableSlot slot,
TupleDesc  tupdesc 
)

Definition at line 1253 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().

1255 {
1256  Assert(!TTS_FIXED(slot));
1257 
1258  /* For safety, make sure slot is empty before changing it */
1259  ExecClearTuple(slot);
1260 
1261  /*
1262  * Release any old descriptor. Also release old Datum/isnull arrays if
1263  * present (we don't bother to check if they could be re-used).
1264  */
1265  if (slot->tts_tupleDescriptor)
1267 
1268  if (slot->tts_values)
1269  pfree(slot->tts_values);
1270  if (slot->tts_isnull)
1271  pfree(slot->tts_isnull);
1272 
1273  /*
1274  * Install the new descriptor; if it's refcounted, bump its refcount.
1275  */
1276  slot->tts_tupleDescriptor = tupdesc;
1277  PinTupleDesc(tupdesc);
1278 
1279  /*
1280  * Allocate Datum/isnull arrays of the appropriate size. These must have
1281  * the same lifetime as the slot, so allocate in the slot's own context.
1282  */
1283  slot->tts_values = (Datum *)
1284  MemoryContextAlloc(slot->tts_mcxt, tupdesc->natts * sizeof(Datum));
1285  slot->tts_isnull = (bool *)
1286  MemoryContextAlloc(slot->tts_mcxt, tupdesc->natts * sizeof(bool));
1287 }
#define TTS_FIXED(slot)
Definition: tuptable.h:109
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:426
MemoryContext tts_mcxt
Definition: tuptable.h:129
Datum * tts_values
Definition: tuptable.h:126
void pfree(void *pointer)
Definition: mcxt.c:1031
bool * tts_isnull
Definition: tuptable.h:128
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
uintptr_t Datum
Definition: postgres.h:367
#define Assert(condition)
Definition: c.h:732
#define PinTupleDesc(tupdesc)
Definition: tupdesc.h:116
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition: mcxt.c:771
#define ReleaseTupleDesc(tupdesc)
Definition: tupdesc.h:122

◆ ExecStoreAllNullTuple()

TupleTableSlot* ExecStoreAllNullTuple ( TupleTableSlot slot)

Definition at line 1540 of file execTuples.c.

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

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

1541 {
1542  /*
1543  * sanity checks
1544  */
1545  Assert(slot != NULL);
1546  Assert(slot->tts_tupleDescriptor != NULL);
1547 
1548  /* Clear any old contents */
1549  ExecClearTuple(slot);
1550 
1551  /*
1552  * Fill all the columns of the virtual tuple with nulls
1553  */
1554  MemSet(slot->tts_values, 0,
1555  slot->tts_tupleDescriptor->natts * sizeof(Datum));
1556  memset(slot->tts_isnull, true,
1557  slot->tts_tupleDescriptor->natts * sizeof(bool));
1558 
1559  return ExecStoreVirtualTuple(slot);
1560 }
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:426
#define MemSet(start, val, len)
Definition: c.h:941
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:367
#define Assert(condition)
Definition: c.h:732
TupleTableSlot * ExecStoreVirtualTuple(TupleTableSlot *slot)
Definition: execTuples.c:1516

◆ ExecStoreBufferHeapTuple()

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

Definition at line 1356 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(), 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().

1359 {
1360  /*
1361  * sanity checks
1362  */
1363  Assert(tuple != NULL);
1364  Assert(slot != NULL);
1365  Assert(slot->tts_tupleDescriptor != NULL);
1366  Assert(BufferIsValid(buffer));
1367 
1368  if (unlikely(!TTS_IS_BUFFERTUPLE(slot)))
1369  elog(ERROR, "trying to store an on-disk heap tuple into wrong type of slot");
1370  tts_buffer_heap_store_tuple(slot, tuple, buffer, false);
1371 
1372  slot->tts_tableOid = tuple->t_tableOid;
1373 
1374  return slot;
1375 }
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:823
#define ERROR
Definition: elog.h:43
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:732
#define BufferIsValid(bufnum)
Definition: bufmgr.h:113
#define elog(elevel,...)
Definition: elog.h:226
#define unlikely(x)
Definition: c.h:208

◆ ExecStoreHeapTuple()

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

Definition at line 1316 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_index_stats(), ExecForceStoreHeapTuple(), ExecuteCallStmt(), gather_getnext(), gather_merge_readnext(), get_returning_data(), heapam_index_validate_scan(), postgresIterateForeignScan(), setop_retrieve_direct(), and tts_heap_copyslot().

1319 {
1320  /*
1321  * sanity checks
1322  */
1323  Assert(tuple != NULL);
1324  Assert(slot != NULL);
1325  Assert(slot->tts_tupleDescriptor != NULL);
1326 
1327  if (unlikely(!TTS_IS_HEAPTUPLE(slot)))
1328  elog(ERROR, "trying to store a heap tuple into wrong type of slot");
1329  tts_heap_store_tuple(slot, tuple, shouldFree);
1330 
1331  slot->tts_tableOid = tuple->t_tableOid;
1332 
1333  return slot;
1334 }
Oid tts_tableOid
Definition: tuptable.h:131
#define ERROR
Definition: elog.h:43
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:732
#define elog(elevel,...)
Definition: elog.h:226
static void tts_heap_store_tuple(TupleTableSlot *slot, HeapTuple tuple, bool shouldFree)
Definition: execTuples.c:430
#define unlikely(x)
Definition: c.h:208

◆ ExecStoreHeapTupleDatum()

void ExecStoreHeapTupleDatum ( Datum  data,
TupleTableSlot slot 
)

Definition at line 1570 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 EvalPlanQualFetchRowMarks().

1571 {
1572  HeapTupleData tuple = {0};
1573  HeapTupleHeader td;
1574 
1575  td = DatumGetHeapTupleHeader(data);
1576 
1578  tuple.t_self = td->t_ctid;
1579  tuple.t_data = td;
1580 
1581  ExecClearTuple(slot);
1582 
1583  heap_deform_tuple(&tuple, slot->tts_tupleDescriptor,
1584  slot->tts_values, slot->tts_isnull);
1585  ExecStoreVirtualTuple(slot);
1586 }
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:426
Datum * tts_values
Definition: tuptable.h:126
#define DatumGetHeapTupleHeader(X)
Definition: fmgr.h:289
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:1516
#define HeapTupleHeaderGetDatumLength(tup)
Definition: htup_details.h:452

◆ ExecStoreMinimalTuple()

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

Definition at line 1410 of file execTuples.c.

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

Referenced by agg_retrieve_hash_table(), ExecParallelScanHashBucket(), ExecScanHashBucket(), ExecScanHashTableForUnmatched(), findPartialMatch(), setop_retrieve_hash_table(), tts_minimal_copyslot(), TupleHashTableHash(), TupleHashTableMatch(), tuplesort_gettupleslot(), and tuplestore_gettupleslot().

1413 {
1414  /*
1415  * sanity checks
1416  */
1417  Assert(mtup != NULL);
1418  Assert(slot != NULL);
1419  Assert(slot->tts_tupleDescriptor != NULL);
1420 
1421  if (unlikely(!TTS_IS_MINIMALTUPLE(slot)))
1422  elog(ERROR, "trying to store a minimal tuple into wrong type of slot");
1423  tts_minimal_store_tuple(slot, mtup, shouldFree);
1424 
1425  return slot;
1426 }
#define TTS_IS_MINIMALTUPLE(slot)
Definition: tuptable.h:230
#define ERROR
Definition: elog.h:43
static void tts_minimal_store_tuple(TupleTableSlot *slot, MinimalTuple mtup, bool shouldFree)
Definition: execTuples.c:597
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
#define Assert(condition)
Definition: c.h:732
#define elog(elevel,...)
Definition: elog.h:226
#define unlikely(x)
Definition: c.h:208

◆ ExecStorePinnedBufferHeapTuple()

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

Definition at line 1382 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().

1385 {
1386  /*
1387  * sanity checks
1388  */
1389  Assert(tuple != NULL);
1390  Assert(slot != NULL);
1391  Assert(slot->tts_tupleDescriptor != NULL);
1392  Assert(BufferIsValid(buffer));
1393 
1394  if (unlikely(!TTS_IS_BUFFERTUPLE(slot)))
1395  elog(ERROR, "trying to store an on-disk heap tuple into wrong type of slot");
1396  tts_buffer_heap_store_tuple(slot, tuple, buffer, true);
1397 
1398  slot->tts_tableOid = tuple->t_tableOid;
1399 
1400  return slot;
1401 }
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:823
#define ERROR
Definition: elog.h:43
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:732
#define BufferIsValid(bufnum)
Definition: bufmgr.h:113
#define elog(elevel,...)
Definition: elog.h:226
#define unlikely(x)
Definition: c.h:208

◆ ExecStoreVirtualTuple()

TupleTableSlot* ExecStoreVirtualTuple ( TupleTableSlot slot)

Definition at line 1516 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(), apply_returning_filter(), ATRewriteTable(), CopyFrom(), do_tup_output(), ExecComputeStoredGenerated(), ExecEvalAggOrderedTransTuple(), ExecFilterJunk(), ExecForceStoreHeapTuple(), ExecForceStoreMinimalTuple(), ExecProjectSRF(), ExecStoreAllNullTuple(), ExecStoreHeapTupleDatum(), execute_attr_map_slot(), fileIterateForeignScan(), FunctionNext(), hypothetical_dense_rank_final(), hypothetical_rank_common(), lookup_hash_entry(), ordered_set_transition_multi(), RI_Initial_Check(), RI_PartitionRemove_Check(), slot_modify_cstrings(), slot_store_cstrings(), StoreIndexTuple(), and ValuesNext().

1517 {
1518  /*
1519  * sanity checks
1520  */
1521  Assert(slot != NULL);
1522  Assert(slot->tts_tupleDescriptor != NULL);
1523  Assert(TTS_EMPTY(slot));
1524 
1525  slot->tts_flags &= ~TTS_FLAG_EMPTY;
1526  slot->tts_nvalid = slot->tts_tupleDescriptor->natts;
1527 
1528  return slot;
1529 }
#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:732
AttrNumber tts_nvalid
Definition: tuptable.h:121

◆ ExecTypeFromExprList()

TupleDesc ExecTypeFromExprList ( List exprList)

Definition at line 1962 of file execTuples.c.

References CreateTemplateTupleDesc(), exprCollation(), exprType(), exprTypmod(), lfirst, list_length(), TupleDescInitEntry(), and TupleDescInitEntryCollation().

Referenced by ExecInitExprRec(), and ExecInitValuesScan().

1963 {
1964  TupleDesc typeInfo;
1965  ListCell *lc;
1966  int cur_resno = 1;
1967 
1968  typeInfo = CreateTemplateTupleDesc(list_length(exprList));
1969 
1970  foreach(lc, exprList)
1971  {
1972  Node *e = lfirst(lc);
1973 
1974  TupleDescInitEntry(typeInfo,
1975  cur_resno,
1976  NULL,
1977  exprType(e),
1978  exprTypmod(e),
1979  0);
1980  TupleDescInitEntryCollation(typeInfo,
1981  cur_resno,
1982  exprCollation(e));
1983  cur_resno++;
1984  }
1985 
1986  return typeInfo;
1987 }
TupleDesc CreateTemplateTupleDesc(int natts)
Definition: tupdesc.c:44
int32 exprTypmod(const Node *expr)
Definition: nodeFuncs.c:276
Definition: nodes.h:524
void TupleDescInitEntryCollation(TupleDesc desc, AttrNumber attributeNumber, Oid collationid)
Definition: tupdesc.c:769
void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)
Definition: tupdesc.c:603
#define lfirst(lc)
Definition: pg_list.h:190
Oid exprType(const Node *expr)
Definition: nodeFuncs.c:42
static int list_length(const List *l)
Definition: pg_list.h:169
Oid exprCollation(const Node *expr)
Definition: nodeFuncs.c:720
e
Definition: preproc-init.c:82

◆ ExecTypeFromTL()

TupleDesc ExecTypeFromTL ( List targetList)

Definition at line 1903 of file execTuples.c.

References ExecTypeFromTLInternal().

Referenced by build_pertrans_for_aggref(), ExecInitCustomScan(), ExecInitForeignScan(), ExecInitIndexOnlyScan(), ExecInitModifyTable(), ExecInitPartitionInfo(), ExecInitResultTypeTL(), ExecInitSubPlan(), find_hash_columns(), and ordered_set_startup().

1904 {
1905  return ExecTypeFromTLInternal(targetList, false);
1906 }
static TupleDesc ExecTypeFromTLInternal(List *targetList, bool skipjunk)
Definition: execTuples.c:1921

◆ ExecTypeFromTLInternal()

static TupleDesc ExecTypeFromTLInternal ( List targetList,
bool  skipjunk 
)
static

Definition at line 1921 of file execTuples.c.

References CreateTemplateTupleDesc(), ExecCleanTargetListLength(), ExecTargetListLength(), TargetEntry::expr, exprCollation(), exprType(), exprTypmod(), lfirst, TargetEntry::resjunk, TargetEntry::resname, TupleDescInitEntry(), and TupleDescInitEntryCollation().

Referenced by ExecCleanTypeFromTL(), and ExecTypeFromTL().

1922 {
1923  TupleDesc typeInfo;
1924  ListCell *l;
1925  int len;
1926  int cur_resno = 1;
1927 
1928  if (skipjunk)
1929  len = ExecCleanTargetListLength(targetList);
1930  else
1931  len = ExecTargetListLength(targetList);
1932  typeInfo = CreateTemplateTupleDesc(len);
1933 
1934  foreach(l, targetList)
1935  {
1936  TargetEntry *tle = lfirst(l);
1937 
1938  if (skipjunk && tle->resjunk)
1939  continue;
1940  TupleDescInitEntry(typeInfo,
1941  cur_resno,
1942  tle->resname,
1943  exprType((Node *) tle->expr),
1944  exprTypmod((Node *) tle->expr),
1945  0);
1946  TupleDescInitEntryCollation(typeInfo,
1947  cur_resno,
1948  exprCollation((Node *) tle->expr));
1949  cur_resno++;
1950  }
1951 
1952  return typeInfo;
1953 }
int ExecTargetListLength(List *targetlist)
Definition: execUtils.c:1090
TupleDesc CreateTemplateTupleDesc(int natts)
Definition: tupdesc.c:44
int32 exprTypmod(const Node *expr)
Definition: nodeFuncs.c:276
Definition: nodes.h:524
char * resname
Definition: primnodes.h:1395
bool resjunk
Definition: primnodes.h:1400
void TupleDescInitEntryCollation(TupleDesc desc, AttrNumber attributeNumber, Oid collationid)
Definition: tupdesc.c:769
void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)
Definition: tupdesc.c:603
int ExecCleanTargetListLength(List *targetlist)
Definition: execUtils.c:1100
#define lfirst(lc)
Definition: pg_list.h:190
Expr * expr
Definition: primnodes.h:1393
Oid exprType(const Node *expr)
Definition: nodeFuncs.c:42
Oid exprCollation(const Node *expr)
Definition: nodeFuncs.c:720

◆ ExecTypeSetColNames()

void ExecTypeSetColNames ( TupleDesc  typeInfo,
List namesList 
)

Definition at line 2001 of file execTuples.c.

References lfirst, NameStr, namestrcpy(), TupleDescData::natts, strVal, TupleDescData::tdtypeid, TupleDescData::tdtypmod, and TupleDescAttr.

Referenced by ExecEvalWholeRowVar(), and ExecInitExprRec().

2002 {
2003  bool modified = false;
2004  int colno = 0;
2005  ListCell *lc;
2006 
2007  foreach(lc, namesList)
2008  {
2009  char *cname = strVal(lfirst(lc));
2010  Form_pg_attribute attr;
2011 
2012  /* Guard against too-long names list */
2013  if (colno >= typeInfo->natts)
2014  break;
2015  attr = TupleDescAttr(typeInfo, colno);
2016  colno++;
2017 
2018  /* Ignore empty aliases (these must be for dropped columns) */
2019  if (cname[0] == '\0')
2020  continue;
2021 
2022  /* Change tupdesc only if alias is actually different */
2023  if (strcmp(cname, NameStr(attr->attname)) != 0)
2024  {
2025  namestrcpy(&(attr->attname), cname);
2026  modified = true;
2027  }
2028  }
2029 
2030  /* If we modified the tupdesc, it's now a new record type */
2031  if (modified)
2032  {
2033  typeInfo->tdtypeid = RECORDOID;
2034  typeInfo->tdtypmod = -1;
2035  }
2036 }
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:92
#define strVal(v)
Definition: value.h:54
int namestrcpy(Name name, const char *str)
Definition: name.c:250
int32 tdtypmod
Definition: tupdesc.h:83
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:200
#define lfirst(lc)
Definition: pg_list.h:190
Oid tdtypeid
Definition: tupdesc.h:82
#define NameStr(name)
Definition: c.h:609

◆ HeapTupleHeaderGetDatum()

Datum HeapTupleHeaderGetDatum ( HeapTupleHeader  tuple)

Definition at line 2200 of file execTuples.c.

References HeapTupleHeaderGetDatumLength, HeapTupleHeaderGetTypeId, HeapTupleHeaderGetTypMod, HeapTupleHeaderHasExternal, lookup_rowtype_tupdesc(), PointerGetDatum, ReleaseTupleDesc, and toast_flatten_tuple_to_datum().

Referenced by populate_composite(), and populate_recordset_record().

2201 {
2202  Datum result;
2203  TupleDesc tupDesc;
2204 
2205  /* No work if there are no external TOAST pointers in the tuple */
2206  if (!HeapTupleHeaderHasExternal(tuple))
2207  return PointerGetDatum(tuple);
2208 
2209  /* Use the type data saved by heap_form_tuple to look up the rowtype */
2211  HeapTupleHeaderGetTypMod(tuple));
2212 
2213  /* And do the flattening */
2214  result = toast_flatten_tuple_to_datum(tuple,
2216  tupDesc);
2217 
2218  ReleaseTupleDesc(tupDesc);
2219 
2220  return result;
2221 }
TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod)
Definition: typcache.c:1652
#define PointerGetDatum(X)
Definition: postgres.h:556
#define HeapTupleHeaderGetTypMod(tup)
Definition: htup_details.h:468
Datum toast_flatten_tuple_to_datum(HeapTupleHeader tup, uint32 tup_len, TupleDesc tupleDesc)
Definition: tuptoaster.c:1182
uintptr_t Datum
Definition: postgres.h:367
#define HeapTupleHeaderGetTypeId(tup)
Definition: htup_details.h:458
#define HeapTupleHeaderHasExternal(tup)
Definition: htup_details.h:539
#define ReleaseTupleDesc(tupdesc)
Definition: tupdesc.h:122
#define HeapTupleHeaderGetDatumLength(tup)
Definition: htup_details.h:452

◆ MakeSingleTupleTableSlot()

◆ MakeTupleTableSlot()

TupleTableSlot* MakeTupleTableSlot ( TupleDesc  tupleDesc,
const TupleTableSlotOps tts_ops 
)

Definition at line 1076 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().

1078 {
1079  Size basesz,
1080  allocsz;
1081  TupleTableSlot *slot;
1082 
1083  basesz = tts_ops->base_slot_size;
1084 
1085  /*
1086  * When a fixed descriptor is specified, we can reduce overhead by
1087  * allocating the entire slot in one go.
1088  */
1089  if (tupleDesc)
1090  allocsz = MAXALIGN(basesz) +
1091  MAXALIGN(tupleDesc->natts * sizeof(Datum)) +
1092  MAXALIGN(tupleDesc->natts * sizeof(bool));
1093  else
1094  allocsz = basesz;
1095 
1096  slot = palloc0(allocsz);
1097  /* const for optimization purposes, OK to modify at allocation time */
1098  *((const TupleTableSlotOps **) &slot->tts_ops) = tts_ops;
1099  slot->type = T_TupleTableSlot;
1100  slot->tts_flags |= TTS_FLAG_EMPTY;
1101  if (tupleDesc != NULL)
1102  slot->tts_flags |= TTS_FLAG_FIXED;
1103  slot->tts_tupleDescriptor = tupleDesc;
1105  slot->tts_nvalid = 0;
1106 
1107  if (tupleDesc != NULL)
1108  {
1109  slot->tts_values = (Datum *)
1110  (((char *) slot)
1111  + MAXALIGN(basesz));
1112  slot->tts_isnull = (bool *)
1113  (((char *) slot)
1114  + MAXALIGN(basesz)
1115  + MAXALIGN(tupleDesc->natts * sizeof(Datum)));
1116 
1117  PinTupleDesc(tupleDesc);
1118  }
1119 
1120  /*
1121  * And allow slot type specific initialization.
1122  */
1123  slot->tts_ops->init(slot);
1124 
1125  return slot;
1126 }
#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:38
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
void * palloc0(Size size)
Definition: mcxt.c:955
uintptr_t Datum
Definition: postgres.h:367
#define TTS_FLAG_FIXED
Definition: tuptable.h:108
size_t Size
Definition: c.h:466
#define MAXALIGN(LEN)
Definition: c.h:685
#define PinTupleDesc(tupdesc)
Definition: tupdesc.h:116
AttrNumber tts_nvalid
Definition: tuptable.h:121
size_t base_slot_size
Definition: tuptable.h:138

◆ slot_deform_heap_tuple()

static pg_attribute_always_inline void slot_deform_heap_tuple ( TupleTableSlot slot,
HeapTuple  tuple,
uint32 offp,
int  natts 
)
static

Definition at line 889 of file execTuples.c.

References att_addlength_pointer, att_align_nominal, att_align_pointer, att_isnull, attnum, TupleTableSlotOps::base_slot_size, fetchatt, HeapTupleHasNulls, HeapTupleHeaderGetNatts, init, Min, HeapTupleHeaderData::t_bits, HeapTupleData::t_data, HeapTupleHeaderData::t_hoff, tts_buffer_heap_clear(), tts_buffer_heap_copy_heap_tuple(), tts_buffer_heap_copy_minimal_tuple(), tts_buffer_heap_copyslot(), tts_buffer_heap_get_heap_tuple(), tts_buffer_heap_getsomeattrs(), tts_buffer_heap_getsysattr(), tts_buffer_heap_init(), tts_buffer_heap_materialize(), tts_buffer_heap_release(), TTS_FLAG_SLOW, tts_heap_clear(), tts_heap_copy_heap_tuple(), tts_heap_copy_minimal_tuple(), tts_heap_copyslot(), tts_heap_get_heap_tuple(), tts_heap_getsomeattrs(), tts_heap_getsysattr(), tts_heap_init(), tts_heap_materialize(), tts_heap_release(), TupleTableSlot::tts_isnull, tts_minimal_clear(), tts_minimal_copy_heap_tuple(), tts_minimal_copy_minimal_tuple(), tts_minimal_copyslot(), tts_minimal_get_minimal_tuple(), tts_minimal_getsomeattrs(), tts_minimal_getsysattr(), tts_minimal_init(), tts_minimal_materialize(), tts_minimal_release(), TupleTableSlot::tts_nvalid, TTS_SLOW, TupleTableSlot::tts_tupleDescriptor, TupleTableSlot::tts_values, tts_virtual_clear(), tts_virtual_copy_heap_tuple(), tts_virtual_copy_minimal_tuple(), tts_virtual_copyslot(), tts_virtual_getsomeattrs(), tts_virtual_getsysattr(), tts_virtual_init(), tts_virtual_materialize(), tts_virtual_release(), TupleDescAttr, and values.

Referenced by tts_buffer_heap_getsomeattrs(), tts_heap_getsomeattrs(), and tts_minimal_getsomeattrs().

891 {
892  TupleDesc tupleDesc = slot->tts_tupleDescriptor;
893  Datum *values = slot->tts_values;
894  bool *isnull = slot->tts_isnull;
895  HeapTupleHeader tup = tuple->t_data;
896  bool hasnulls = HeapTupleHasNulls(tuple);
897  int attnum;
898  char *tp; /* ptr to tuple data */
899  uint32 off; /* offset in tuple data */
900  bits8 *bp = tup->t_bits; /* ptr to null bitmap in tuple */
901  bool slow; /* can we use/set attcacheoff? */
902 
903  /* We can only fetch as many attributes as the tuple has. */
904  natts = Min(HeapTupleHeaderGetNatts(tuple->t_data), natts);
905 
906  /*
907  * Check whether the first call for this tuple, and initialize or restore
908  * loop state.
909  */
910  attnum = slot->tts_nvalid;
911  if (attnum == 0)
912  {
913  /* Start from the first attribute */
914  off = 0;
915  slow = false;
916  }
917  else
918  {
919  /* Restore state from previous execution */
920  off = *offp;
921  slow = TTS_SLOW(slot);
922  }
923 
924  tp = (char *) tup + tup->t_hoff;
925 
926  for (; attnum < natts; attnum++)
927  {
928  Form_pg_attribute thisatt = TupleDescAttr(tupleDesc, attnum);
929 
930  if (hasnulls && att_isnull(attnum, bp))
931  {
932  values[attnum] = (Datum) 0;
933  isnull[attnum] = true;
934  slow = true; /* can't use attcacheoff anymore */
935  continue;
936  }
937 
938  isnull[attnum] = false;
939 
940  if (!slow && thisatt->attcacheoff >= 0)
941  off = thisatt->attcacheoff;
942  else if (thisatt->attlen == -1)
943  {
944  /*
945  * We can only cache the offset for a varlena attribute if the
946  * offset is already suitably aligned, so that there would be no
947  * pad bytes in any case: then the offset will be valid for either
948  * an aligned or unaligned value.
949  */
950  if (!slow &&
951  off == att_align_nominal(off, thisatt->attalign))
952  thisatt->attcacheoff = off;
953  else
954  {
955  off = att_align_pointer(off, thisatt->attalign, -1,
956  tp + off);
957  slow = true;
958  }
959  }
960  else
961  {
962  /* not varlena, so safe to use att_align_nominal */
963  off = att_align_nominal(off, thisatt->attalign);
964 
965  if (!slow)
966  thisatt->attcacheoff = off;
967  }
968 
969  values[attnum] = fetchatt(thisatt, tp + off);
970 
971  off = att_addlength_pointer(off, thisatt->attlen, tp + off);
972 
973  if (thisatt->attlen <= 0)
974  slow = true; /* can't use attcacheoff anymore */
975  }
976 
977  /*
978  * Save state for next execution
979  */
980  slot->tts_nvalid = attnum;
981  *offp = off;
982  if (slow)
983  slot->tts_flags |= TTS_FLAG_SLOW;
984  else
985  slot->tts_flags &= ~TTS_FLAG_SLOW;
986 }
#define att_align_nominal(cur_offset, attalign)
Definition: tupmacs.h:146
bits8 t_bits[FLEXIBLE_ARRAY_MEMBER]
Definition: htup_details.h:177
#define att_isnull(ATT, BITS)
Definition: tupmacs.h:23
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:92
#define Min(x, y)
Definition: c.h:890
Datum * tts_values
Definition: tuptable.h:126
#define fetchatt(A, T)
Definition: tupmacs.h:39
HeapTupleHeader t_data
Definition: htup.h:68
uint16 tts_flags
Definition: tuptable.h:119
#define HeapTupleHeaderGetNatts(tup)
Definition: htup_details.h:531
#define HeapTupleHasNulls(tuple)
Definition: htup_details.h:661
bool * tts_isnull
Definition: tuptable.h:128
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:200
unsigned int uint32
Definition: c.h:358
#define att_addlength_pointer(cur_offset, attlen, attptr)
Definition: tupmacs.h:174
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
uint8 bits8
Definition: c.h:365
uintptr_t Datum
Definition: postgres.h:367
#define att_align_pointer(cur_offset, attalign, attlen, attptr)
Definition: tupmacs.h:124
int16 attnum
Definition: pg_attribute.h:79
static Datum values[MAXATTR]
Definition: bootstrap.c:167
#define TTS_SLOW(slot)
Definition: tuptable.h:105
AttrNumber tts_nvalid
Definition: tuptable.h:121
#define TTS_FLAG_SLOW
Definition: tuptable.h:104

◆ slot_getmissingattrs()

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

Definition at line 1832 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().

1833 {
1834  AttrMissing *attrmiss = NULL;
1835 
1836  if (slot->tts_tupleDescriptor->constr)
1837  attrmiss = slot->tts_tupleDescriptor->constr->missing;
1838 
1839  if (!attrmiss)
1840  {
1841  /* no missing values array at all, so just fill everything in as NULL */
1842  memset(slot->tts_values + startAttNum, 0,
1843  (lastAttNum - startAttNum) * sizeof(Datum));
1844  memset(slot->tts_isnull + startAttNum, 1,
1845  (lastAttNum - startAttNum) * sizeof(bool));
1846  }
1847  else
1848  {
1849  int missattnum;
1850 
1851  /* if there is a missing values array we must process them one by one */
1852  for (missattnum = startAttNum;
1853  missattnum < lastAttNum;
1854  missattnum++)
1855  {
1856  slot->tts_values[missattnum] = attrmiss[missattnum].am_value;
1857  slot->tts_isnull[missattnum] = !attrmiss[missattnum].am_present;
1858  }
1859 
1860  }
1861 }
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:367
struct AttrMissing * missing
Definition: tupdesc.h:41

◆ slot_getsomeattrs_int()

void slot_getsomeattrs_int ( TupleTableSlot slot,
int  attnum 
)

Definition at line 1867 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().

1868 {
1869  /* Check for caller errors */
1870  Assert(slot->tts_nvalid < attnum); /* checked in slot_getsomeattrs */
1871  Assert(attnum > 0);
1872 
1873  if (unlikely(attnum > slot->tts_tupleDescriptor->natts))
1874  elog(ERROR, "invalid attribute number %d", attnum);
1875 
1876  /* Fetch as many attributes as possible from the underlying tuple. */
1877  slot->tts_ops->getsomeattrs(slot, attnum);
1878 
1879  /*
1880  * If the underlying tuple doesn't have enough attributes, tuple
1881  * descriptor must have the missing attributes.
1882  */
1883  if (unlikely(slot->tts_nvalid < attnum))
1884  {
1885  slot_getmissingattrs(slot, slot->tts_nvalid, attnum);
1886  slot->tts_nvalid = attnum;
1887  }
1888 }
const TupleTableSlotOps *const tts_ops
Definition: tuptable.h:122
#define ERROR
Definition: elog.h:43
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
int16 attnum
Definition: pg_attribute.h:79
#define Assert(condition)
Definition: c.h:732
void(* getsomeattrs)(TupleTableSlot *slot, int natts)
Definition: tuptable.h:161
void slot_getmissingattrs(TupleTableSlot *slot, int startAttNum, int lastAttNum)
Definition: execTuples.c:1832
#define elog(elevel,...)
Definition: elog.h:226
#define unlikely(x)
Definition: c.h:208
AttrNumber tts_nvalid
Definition: tuptable.h:121

◆ tts_buffer_heap_clear()

static void tts_buffer_heap_clear ( TupleTableSlot slot)
static

Definition at line 638 of file execTuples.c.

References Assert, BufferHeapTupleTableSlot::base, BufferHeapTupleTableSlot::buffer, BufferIsValid, heap_freetuple(), InvalidBuffer, ItemPointerSetInvalid, HeapTupleTableSlot::off, ReleaseBuffer(), TTS_FLAG_EMPTY, TTS_FLAG_SHOULDFREE, TupleTableSlot::tts_flags, TupleTableSlot::tts_nvalid, TTS_SHOULDFREE, TupleTableSlot::tts_tid, and HeapTupleTableSlot::tuple.

Referenced by slot_deform_heap_tuple().

639 {
641 
642  /*
643  * Free the memory for heap tuple if allowed. A tuple coming from buffer
644  * can never be freed. But we may have materialized a tuple from buffer.
645  * Such a tuple can be freed.
646  */
647  if (TTS_SHOULDFREE(slot))
648  {
649  /* We should have unpinned the buffer while materializing the tuple. */
650  Assert(!BufferIsValid(bslot->buffer));
651 
652  heap_freetuple(bslot->base.tuple);
653  slot->tts_flags &= ~TTS_FLAG_SHOULDFREE;
654 
655  Assert(!BufferIsValid(bslot->buffer));
656  }
657 
658  if (BufferIsValid(bslot->buffer))
659  ReleaseBuffer(bslot->buffer);
660 
661  slot->tts_nvalid = 0;
662  slot->tts_flags |= TTS_FLAG_EMPTY;
664  bslot->base.tuple = NULL;
665  bslot->base.off = 0;
666  bslot->buffer = InvalidBuffer;
667 }
#define TTS_FLAG_EMPTY
Definition: tuptable.h:96
#define TTS_SHOULDFREE(slot)
Definition: tuptable.h:101
#define TTS_FLAG_SHOULDFREE
Definition: tuptable.h:100
#define InvalidBuffer
Definition: buf.h:25
HeapTuple tuple
Definition: tuptable.h:250
void ReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3353
void heap_freetuple(HeapTuple htup)
Definition: heaptuple.c:1338
uint16 tts_flags
Definition: tuptable.h:119
#define Assert(condition)
Definition: c.h:732
#define BufferIsValid(bufnum)
Definition: bufmgr.h:113
#define ItemPointerSetInvalid(pointer)
Definition: itemptr.h:172
AttrNumber tts_nvalid
Definition: tuptable.h:121
HeapTupleTableSlot base
Definition: tuptable.h:259
ItemPointerData tts_tid
Definition: tuptable.h:130

◆ tts_buffer_heap_copy_heap_tuple()

static HeapTuple tts_buffer_heap_copy_heap_tuple ( TupleTableSlot slot)
static

Definition at line 797 of file execTuples.c.

References Assert, BufferHeapTupleTableSlot::base, heap_copytuple(), tts_buffer_heap_materialize(), TTS_EMPTY, and HeapTupleTableSlot::tuple.

Referenced by slot_deform_heap_tuple().

798 {
800 
801  Assert(!TTS_EMPTY(slot));
802 
803  if (!bslot->base.tuple)
805 
806  return heap_copytuple(bslot->base.tuple);
807 }
HeapTuple heap_copytuple(HeapTuple tuple)
Definition: heaptuple.c:680
#define TTS_EMPTY(slot)
Definition: tuptable.h:97
HeapTuple tuple
Definition: tuptable.h:250
#define Assert(condition)
Definition: c.h:732
static void tts_buffer_heap_materialize(TupleTableSlot *slot)
Definition: execTuples.c:689
HeapTupleTableSlot base
Definition: tuptable.h:259

◆ tts_buffer_heap_copy_minimal_tuple()

static MinimalTuple tts_buffer_heap_copy_minimal_tuple ( TupleTableSlot slot)
static

Definition at line 810 of file execTuples.c.

References Assert, BufferHeapTupleTableSlot::base, minimal_tuple_from_heap_tuple(), tts_buffer_heap_materialize(), TTS_EMPTY, and HeapTupleTableSlot::tuple.

Referenced by slot_deform_heap_tuple().

811 {
813 
814  Assert(!TTS_EMPTY(slot));
815 
816  if (!bslot->base.tuple)
818 
820 }
#define TTS_EMPTY(slot)
Definition: tuptable.h:97
HeapTuple tuple
Definition: tuptable.h:250
#define Assert(condition)
Definition: c.h:732
static void tts_buffer_heap_materialize(TupleTableSlot *slot)
Definition: execTuples.c:689
MinimalTuple minimal_tuple_from_heap_tuple(HeapTuple htup)
Definition: heaptuple.c:1480
HeapTupleTableSlot base
Definition: tuptable.h:259

◆ tts_buffer_heap_copyslot()

static void tts_buffer_heap_copyslot ( TupleTableSlot dstslot,
TupleTableSlot srcslot 
)
static

Definition at line 742 of file execTuples.c.

References Assert, BufferHeapTupleTableSlot::base, BufferHeapTupleTableSlot::buffer, BufferIsValid, ExecClearTuple(), ExecCopySlotHeapTuple(), MemoryContextSwitchTo(), tts_buffer_heap_store_tuple(), TTS_FLAG_EMPTY, TTS_FLAG_SHOULDFREE, TupleTableSlot::tts_flags, TupleTableSlot::tts_mcxt, TupleTableSlot::tts_ops, TTS_SHOULDFREE, HeapTupleTableSlot::tupdata, and HeapTupleTableSlot::tuple.

Referenced by slot_deform_heap_tuple().

743 {
744  BufferHeapTupleTableSlot *bsrcslot = (BufferHeapTupleTableSlot *) srcslot;
745  BufferHeapTupleTableSlot *bdstslot = (BufferHeapTupleTableSlot *) dstslot;
746 
747  /*
748  * If the source slot is of a different kind, or is a buffer slot that has
749  * been materialized / is virtual, make a new copy of the tuple. Otherwise
750  * make a new reference to the in-buffer tuple.
751  */
752  if (dstslot->tts_ops != srcslot->tts_ops ||
753  TTS_SHOULDFREE(srcslot) ||
754  !bsrcslot->base.tuple)
755  {
756  MemoryContext oldContext;
757 
758  ExecClearTuple(dstslot);
759  dstslot->tts_flags |= TTS_FLAG_SHOULDFREE;
760  dstslot->tts_flags &= ~TTS_FLAG_EMPTY;
761  oldContext = MemoryContextSwitchTo(dstslot->tts_mcxt);
762  bdstslot->base.tuple = ExecCopySlotHeapTuple(srcslot);
763  MemoryContextSwitchTo(oldContext);
764  }
765  else
766  {
767  Assert(BufferIsValid(bsrcslot->buffer));
768 
769  tts_buffer_heap_store_tuple(dstslot, bsrcslot->base.tuple,
770  bsrcslot->buffer, false);
771 
772  /*
773  * The HeapTupleData portion of the source tuple might be shorter
774  * lived than the destination slot. Therefore copy the HeapTuple into
775  * our slot's tupdata, which is guaranteed to live long enough (but
776  * will still point into the buffer).
777  */
778  memcpy(&bdstslot->base.tupdata, bdstslot->base.tuple, sizeof(HeapTupleData));
779  bdstslot->base.tuple = &bdstslot->base.tupdata;
780  }
781 }
static void tts_buffer_heap_store_tuple(TupleTableSlot *slot, HeapTuple tuple, Buffer buffer, bool transfer_pin)
Definition: execTuples.c:823
#define TTS_FLAG_EMPTY
Definition: tuptable.h:96
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:426
#define TTS_SHOULDFREE(slot)
Definition: tuptable.h:101
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
#define TTS_FLAG_SHOULDFREE
Definition: tuptable.h:100
const TupleTableSlotOps *const tts_ops
Definition: tuptable.h:122
HeapTuple tuple
Definition: tuptable.h:250
MemoryContext tts_mcxt
Definition: tuptable.h:129
uint16 tts_flags
Definition: tuptable.h:119
static HeapTuple ExecCopySlotHeapTuple(TupleTableSlot *slot)
Definition: tuptable.h:453
#define Assert(condition)
Definition: c.h:732
#define BufferIsValid(bufnum)
Definition: bufmgr.h:113
HeapTupleTableSlot base
Definition: tuptable.h:259
HeapTupleData tupdata
Definition: tuptable.h:253

◆ tts_buffer_heap_get_heap_tuple()

static HeapTuple tts_buffer_heap_get_heap_tuple ( TupleTableSlot slot)
static

Definition at line 784 of file execTuples.c.

References Assert, BufferHeapTupleTableSlot::base, tts_buffer_heap_materialize(), TTS_EMPTY, and HeapTupleTableSlot::tuple.

Referenced by slot_deform_heap_tuple().

785 {
787 
788  Assert(!TTS_EMPTY(slot));
789 
790  if (!bslot->base.tuple)
792 
793  return bslot->base.tuple;
794 }
#define TTS_EMPTY(slot)
Definition: tuptable.h:97
HeapTuple tuple
Definition: tuptable.h:250
#define Assert(condition)
Definition: c.h:732
static void tts_buffer_heap_materialize(TupleTableSlot *slot)
Definition: execTuples.c:689
HeapTupleTableSlot base
Definition: tuptable.h:259

◆ tts_buffer_heap_getsomeattrs()

static void tts_buffer_heap_getsomeattrs ( TupleTableSlot slot,
int  natts 
)
static

Definition at line 670 of file execTuples.c.

References Assert, BufferHeapTupleTableSlot::base, HeapTupleTableSlot::off, slot_deform_heap_tuple(), TTS_EMPTY, and HeapTupleTableSlot::tuple.

Referenced by slot_deform_heap_tuple().

671 {
673 
674  Assert(!TTS_EMPTY(slot));
675 
676  slot_deform_heap_tuple(slot, bslot->base.tuple, &bslot->base.off, natts);
677 }
#define TTS_EMPTY(slot)
Definition: tuptable.h:97
HeapTuple tuple
Definition: tuptable.h:250
static pg_attribute_always_inline void slot_deform_heap_tuple(TupleTableSlot *slot, HeapTuple tuple, uint32 *offp, int natts)
Definition: execTuples.c:889
#define Assert(condition)
Definition: c.h:732
HeapTupleTableSlot base
Definition: tuptable.h:259

◆ tts_buffer_heap_getsysattr()

static Datum tts_buffer_heap_getsysattr ( TupleTableSlot slot,
int  attnum,
bool isnull 
)
static

Definition at line 680 of file execTuples.c.

References BufferHeapTupleTableSlot::base, heap_getsysattr(), TupleTableSlot::tts_tupleDescriptor, and HeapTupleTableSlot::tuple.

Referenced by slot_deform_heap_tuple().

681 {
683 
684  return heap_getsysattr(bslot->base.tuple, attnum,
685  slot->tts_tupleDescriptor, isnull);
686 }
HeapTuple tuple
Definition: tuptable.h:250
Datum heap_getsysattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
Definition: heaptuple.c:627
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
int16 attnum
Definition: pg_attribute.h:79
HeapTupleTableSlot base
Definition: tuptable.h:259

◆ tts_buffer_heap_init()

static void tts_buffer_heap_init ( TupleTableSlot slot)
static

Definition at line 628 of file execTuples.c.

Referenced by slot_deform_heap_tuple().

629 {
630 }

◆ tts_buffer_heap_materialize()

static void tts_buffer_heap_materialize ( TupleTableSlot slot)
static

Definition at line 689 of file execTuples.c.

References Assert, BufferHeapTupleTableSlot::base, BufferHeapTupleTableSlot::buffer, BufferIsValid, heap_copytuple(), heap_form_tuple(), InvalidBuffer, likely, MemoryContextSwitchTo(), HeapTupleTableSlot::off, ReleaseBuffer(), TTS_EMPTY, TTS_FLAG_SHOULDFREE, TupleTableSlot::tts_flags, TupleTableSlot::tts_isnull, TupleTableSlot::tts_mcxt, TupleTableSlot::tts_nvalid, TTS_SHOULDFREE, TupleTableSlot::tts_tupleDescriptor, TupleTableSlot::tts_values, and HeapTupleTableSlot::tuple.

Referenced by slot_deform_heap_tuple(), tts_buffer_heap_copy_heap_tuple(), tts_buffer_heap_copy_minimal_tuple(), and tts_buffer_heap_get_heap_tuple().

690 {
692  MemoryContext oldContext;
693 
694  Assert(!TTS_EMPTY(slot));
695 
696  /* If already materialized nothing to do. */
697  if (TTS_SHOULDFREE(slot))
698  return;
699 
701 
702  oldContext = MemoryContextSwitchTo(slot->tts_mcxt);
703 
704  if (!bslot->base.tuple)
705  {
706  /*
707  * Normally BufferHeapTupleTableSlot should have a tuple + buffer
708  * associated with it, unless it's materialized (which would've
709  * returned above). But when it's useful to allow storing virtual
710  * tuples in a buffer slot, which then also needs to be
711  * materializable.
712  */
714  slot->tts_values,
715  slot->tts_isnull);
716 
717  }
718  else
719  {
720  bslot->base.tuple = heap_copytuple(bslot->base.tuple);
721 
722  /*
723  * A heap tuple stored in a BufferHeapTupleTableSlot should have a
724  * buffer associated with it, unless it's materialized or virtual.
725  */
726  Assert(BufferIsValid(bslot->buffer));
727  if (likely(BufferIsValid(bslot->buffer)))
728  ReleaseBuffer(bslot->buffer);
729  bslot->buffer = InvalidBuffer;
730  }
731  MemoryContextSwitchTo(oldContext);
732 
733  /*
734  * Have to deform from scratch, otherwise tts_values[] entries could point
735  * into the non-materialized tuple (which might be gone when accessed).
736  */
737  bslot->base.off = 0;
738  slot->tts_nvalid = 0;
739 }
HeapTuple heap_copytuple(HeapTuple tuple)
Definition: heaptuple.c:680
#define likely(x)
Definition: c.h:207
#define TTS_EMPTY(slot)
Definition: tuptable.h:97
#define TTS_SHOULDFREE(slot)
Definition: tuptable.h:101
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
#define TTS_FLAG_SHOULDFREE
Definition: tuptable.h:100
#define InvalidBuffer
Definition: buf.h:25
HeapTuple tuple
Definition: tuptable.h:250
MemoryContext tts_mcxt
Definition: tuptable.h:129
Datum * tts_values
Definition: tuptable.h:126
void ReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3353
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
Definition: heaptuple.c:1020
uint16 tts_flags
Definition: tuptable.h:119
bool * tts_isnull
Definition: tuptable.h:128
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
#define Assert(condition)
Definition: c.h:732
#define BufferIsValid(bufnum)
Definition: bufmgr.h:113
AttrNumber tts_nvalid
Definition: tuptable.h:121
HeapTupleTableSlot base
Definition: tuptable.h:259

◆ tts_buffer_heap_release()

static void tts_buffer_heap_release ( TupleTableSlot slot)
static

Definition at line 633 of file execTuples.c.

Referenced by slot_deform_heap_tuple().

634 {
635 }

◆ tts_buffer_heap_store_tuple()

static void tts_buffer_heap_store_tuple ( TupleTableSlot slot,
HeapTuple  tuple,
Buffer  buffer,
bool  transfer_pin 
)
inlinestatic

Definition at line 823 of file execTuples.c.

References Assert, BufferHeapTupleTableSlot::base, BufferHeapTupleTableSlot::buffer, BufferIsValid, heap_freetuple(), IncrBufferRefCount(), HeapTupleTableSlot::off, pg_attribute_always_inline, ReleaseBuffer(), HeapTupleData::t_self, TTS_FLAG_EMPTY, TTS_FLAG_SHOULDFREE, TupleTableSlot::tts_flags, TupleTableSlot::tts_nvalid, TTS_SHOULDFREE, TupleTableSlot::tts_tid, and HeapTupleTableSlot::tuple.

Referenced by ExecStoreBufferHeapTuple(), ExecStorePinnedBufferHeapTuple(), and tts_buffer_heap_copyslot().

825 {
827 
828  if (TTS_SHOULDFREE(slot))
829  {
830  /* materialized slot shouldn't have a buffer to release */
831  Assert(!BufferIsValid(bslot->buffer));
832 
833  heap_freetuple(bslot->base.tuple);
834  slot->tts_flags &= ~TTS_FLAG_SHOULDFREE;
835  }
836 
837  slot->tts_flags &= ~TTS_FLAG_EMPTY;
838  slot->tts_nvalid = 0;
839  bslot->base.tuple = tuple;
840  bslot->base.off = 0;
841  slot->tts_tid = tuple->t_self;
842 
843  /*
844  * If tuple is on a disk page, keep the page pinned as long as we hold a
845  * pointer into it. We assume the caller already has such a pin. If
846  * transfer_pin is true, we'll transfer that pin to this slot, if not
847  * we'll pin it again ourselves.
848  *
849  * This is coded to optimize the case where the slot previously held a
850  * tuple on the same disk page: in that case releasing and re-acquiring
851  * the pin is a waste of cycles. This is a common situation during
852  * seqscans, so it's worth troubling over.
853  */
854  if (bslot->buffer != buffer)
855  {
856  if (BufferIsValid(bslot->buffer))
857  ReleaseBuffer(bslot->buffer);
858 
859  bslot->buffer = buffer;
860 
861  if (!transfer_pin && BufferIsValid(buffer))
862  IncrBufferRefCount(buffer);
863  }
864  else if (transfer_pin && BufferIsValid(buffer))
865  {
866  /*
867  * In transfer_pin mode the caller won't know about the same-page
868  * optimization, so we gotta release its pin.
869  */
870  ReleaseBuffer(buffer);
871  }
872 }
#define TTS_FLAG_EMPTY
Definition: tuptable.h:96
#define TTS_SHOULDFREE(slot)
Definition: tuptable.h:101
#define TTS_FLAG_SHOULDFREE
Definition: tuptable.h:100
HeapTuple tuple
Definition: tuptable.h:250
void ReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3353
void heap_freetuple(HeapTuple htup)
Definition: heaptuple.c:1338
uint16 tts_flags
Definition: tuptable.h:119
ItemPointerData t_self
Definition: htup.h:65
#define Assert(condition)
Definition: c.h:732
#define BufferIsValid(bufnum)
Definition: bufmgr.h:113
AttrNumber tts_nvalid
Definition: tuptable.h:121
HeapTupleTableSlot base
Definition: tuptable.h:259
ItemPointerData tts_tid
Definition: tuptable.h:130
void IncrBufferRefCount(Buffer buffer)
Definition: bufmgr.c:3391

◆ tts_heap_clear()

static void tts_heap_clear ( TupleTableSlot slot)
static

Definition at line 304 of file execTuples.c.

References heap_freetuple(), ItemPointerSetInvalid, HeapTupleTableSlot::off, TTS_FLAG_EMPTY, TTS_FLAG_SHOULDFREE, TupleTableSlot::tts_flags, TupleTableSlot::tts_nvalid, TTS_SHOULDFREE, TupleTableSlot::tts_tid, and HeapTupleTableSlot::tuple.

Referenced by slot_deform_heap_tuple(), and tts_heap_store_tuple().

305 {
306  HeapTupleTableSlot *hslot = (HeapTupleTableSlot *) slot;
307 
308  /* Free the memory for the heap tuple if it's allowed. */
309  if (TTS_SHOULDFREE(slot))
310  {
311  heap_freetuple(hslot->tuple);
312  slot->tts_flags &= ~TTS_FLAG_SHOULDFREE;
313  }
314 
315  slot->tts_nvalid = 0;
316  slot->tts_flags |= TTS_FLAG_EMPTY;
318  hslot->off = 0;
319  hslot->tuple = NULL;
320 }
#define TTS_FLAG_EMPTY
Definition: tuptable.h:96
#define TTS_SHOULDFREE(slot)
Definition: tuptable.h:101
#define TTS_FLAG_SHOULDFREE
Definition: tuptable.h:100
HeapTuple tuple
Definition: tuptable.h:250
void heap_freetuple(HeapTuple htup)
Definition: heaptuple.c:1338
uint16 tts_flags
Definition: tuptable.h:119
#define ItemPointerSetInvalid(pointer)
Definition: itemptr.h:172
AttrNumber tts_nvalid
Definition: tuptable.h:121
ItemPointerData tts_tid
Definition: tuptable.h:130

◆ tts_heap_copy_heap_tuple()

static HeapTuple tts_heap_copy_heap_tuple ( TupleTableSlot slot)
static

Definition at line 407 of file execTuples.c.

References Assert, heap_copytuple(), TTS_EMPTY, tts_heap_materialize(), and HeapTupleTableSlot::tuple.

Referenced by slot_deform_heap_tuple().

408 {
409  HeapTupleTableSlot *hslot = (HeapTupleTableSlot *) slot;
410 
411  Assert(!TTS_EMPTY(slot));
412  if (!hslot->tuple)
413  tts_heap_materialize(slot);
414 
415  return heap_copytuple(hslot->tuple);
416 }
HeapTuple heap_copytuple(HeapTuple tuple)
Definition: heaptuple.c:680
static void tts_heap_materialize(TupleTableSlot *slot)
Definition: execTuples.c:342
#define TTS_EMPTY(slot)
Definition: tuptable.h:97
HeapTuple tuple
Definition: tuptable.h:250
#define Assert(condition)
Definition: c.h:732

◆ tts_heap_copy_minimal_tuple()

static MinimalTuple tts_heap_copy_minimal_tuple ( TupleTableSlot slot)
static

Definition at line 419 of file execTuples.c.

References minimal_tuple_from_heap_tuple(), tts_heap_materialize(), and HeapTupleTableSlot::tuple.

Referenced by slot_deform_heap_tuple().

420 {
421  HeapTupleTableSlot *hslot = (HeapTupleTableSlot *) slot;
422 
423  if (!hslot->tuple)
424  tts_heap_materialize(slot);
425 
426  return minimal_tuple_from_heap_tuple(hslot->tuple);
427 }
static void tts_heap_materialize(TupleTableSlot *slot)
Definition: execTuples.c:342
HeapTuple tuple
Definition: tuptable.h:250
MinimalTuple minimal_tuple_from_heap_tuple(HeapTuple htup)
Definition: heaptuple.c:1480

◆ tts_heap_copyslot()

static void tts_heap_copyslot ( TupleTableSlot dstslot,
TupleTableSlot srcslot 
)
static

Definition at line 382 of file execTuples.c.

References ExecCopySlotHeapTuple(), ExecStoreHeapTuple(), MemoryContextSwitchTo(), and TupleTableSlot::tts_mcxt.

Referenced by slot_deform_heap_tuple().

383 {
384  HeapTuple tuple;
385  MemoryContext oldcontext;
386 
387  oldcontext = MemoryContextSwitchTo(dstslot->tts_mcxt);
388  tuple = ExecCopySlotHeapTuple(srcslot);
389  MemoryContextSwitchTo(oldcontext);
390 
391  ExecStoreHeapTuple(tuple, dstslot, true);
392 }
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
MemoryContext tts_mcxt
Definition: tuptable.h:129
static HeapTuple ExecCopySlotHeapTuple(TupleTableSlot *slot)
Definition: tuptable.h:453
TupleTableSlot * ExecStoreHeapTuple(HeapTuple tuple, TupleTableSlot *slot, bool shouldFree)
Definition: execTuples.c:1316

◆ tts_heap_get_heap_tuple()

static HeapTuple tts_heap_get_heap_tuple ( TupleTableSlot slot)
static

Definition at line 395 of file execTuples.c.

References Assert, TTS_EMPTY, tts_heap_materialize(), and HeapTupleTableSlot::tuple.

Referenced by slot_deform_heap_tuple().

396 {
397  HeapTupleTableSlot *hslot = (HeapTupleTableSlot *) slot;
398 
399  Assert(!TTS_EMPTY(slot));
400  if (!hslot->tuple)
401  tts_heap_materialize(slot);
402 
403  return hslot->tuple;
404 }
static void tts_heap_materialize(TupleTableSlot *slot)
Definition: execTuples.c:342
#define TTS_EMPTY(slot)
Definition: tuptable.h:97
HeapTuple tuple
Definition: tuptable.h:250
#define Assert(condition)
Definition: c.h:732

◆ tts_heap_getsomeattrs()

static void tts_heap_getsomeattrs ( TupleTableSlot slot,
int  natts 
)
static

Definition at line 323 of file execTuples.c.

References Assert, HeapTupleTableSlot::off, slot_deform_heap_tuple(), TTS_EMPTY, and HeapTupleTableSlot::tuple.

Referenced by slot_deform_heap_tuple().

324 {
325  HeapTupleTableSlot *hslot = (HeapTupleTableSlot *) slot;
326 
327  Assert(!TTS_EMPTY(slot));
328 
329  slot_deform_heap_tuple(slot, hslot->tuple, &hslot->off, natts);
330 }
#define TTS_EMPTY(slot)
Definition: tuptable.h:97
HeapTuple tuple
Definition: tuptable.h:250
static pg_attribute_always_inline void slot_deform_heap_tuple(TupleTableSlot *slot, HeapTuple tuple, uint32 *offp, int natts)
Definition: execTuples.c:889
#define Assert(condition)
Definition: c.h:732

◆ tts_heap_getsysattr()

static Datum tts_heap_getsysattr ( TupleTableSlot slot,
int  attnum,
bool isnull 
)
static

Definition at line 333 of file execTuples.c.

References heap_getsysattr(), TupleTableSlot::tts_tupleDescriptor, and HeapTupleTableSlot::tuple.

Referenced by slot_deform_heap_tuple().

334 {
335  HeapTupleTableSlot *hslot = (HeapTupleTableSlot *) slot;
336 
337  return heap_getsysattr(hslot->tuple, attnum,
338  slot->tts_tupleDescriptor, isnull);
339 }
HeapTuple tuple
Definition: tuptable.h:250
Datum heap_getsysattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
Definition: heaptuple.c:627
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
int16 attnum
Definition: pg_attribute.h:79

◆ tts_heap_init()

static void tts_heap_init ( TupleTableSlot slot)
static

Definition at line 294 of file execTuples.c.

Referenced by slot_deform_heap_tuple().

295 {
296 }

◆ tts_heap_materialize()

static void tts_heap_materialize ( TupleTableSlot slot)
static

Definition at line 342 of file execTuples.c.

References Assert, heap_copytuple(), heap_form_tuple(), MemoryContextSwitchTo(), HeapTupleTableSlot::off, TTS_EMPTY, TTS_FLAG_SHOULDFREE, TupleTableSlot::tts_flags, TupleTableSlot::tts_isnull, TupleTableSlot::tts_mcxt, TupleTableSlot::tts_nvalid, TTS_SHOULDFREE, TupleTableSlot::tts_tupleDescriptor, TupleTableSlot::tts_values, and HeapTupleTableSlot::tuple.

Referenced by slot_deform_heap_tuple(), tts_heap_copy_heap_tuple(), tts_heap_copy_minimal_tuple(), and tts_heap_get_heap_tuple().

343 {
344  HeapTupleTableSlot *hslot = (HeapTupleTableSlot *) slot;
345  MemoryContext oldContext;
346 
347  Assert(!TTS_EMPTY(slot));
348 
349  /* This slot has it's tuple already materialized. Nothing to do. */
350  if (TTS_SHOULDFREE(slot))
351  return;
352 
354 
355  oldContext = MemoryContextSwitchTo(slot->tts_mcxt);
356 
357  if (!hslot->tuple)
359  slot->tts_values,
360  slot->tts_isnull);
361  else
362  {
363  /*
364  * The tuple contained in this slot is not allocated in the memory
365  * context of the given slot (else it would have TTS_SHOULDFREE set).
366  * Copy the tuple into the given slot's memory context.
367  */
368  hslot->tuple = heap_copytuple(hslot->tuple);
369  }
370 
371  /*
372  * Have to deform from scratch, otherwise tts_values[] entries could point
373  * into the non-materialized tuple (which might be gone when accessed).
374  */
375  slot->tts_nvalid = 0;
376  hslot->off = 0;
377 
378  MemoryContextSwitchTo(oldContext);
379 }
HeapTuple heap_copytuple(HeapTuple tuple)
Definition: heaptuple.c:680
#define TTS_EMPTY(slot)
Definition: tuptable.h:97
#define TTS_SHOULDFREE(slot)
Definition: tuptable.h:101
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
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
Definition: heaptuple.c:1020
uint16 tts_flags
Definition: tuptable.h:119
bool * tts_isnull
Definition: tuptable.h:128
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
#define Assert(condition)
Definition: c.h:732
AttrNumber tts_nvalid
Definition: tuptable.h:121

◆ tts_heap_release()

static void tts_heap_release ( TupleTableSlot slot)
static

Definition at line 299 of file execTuples.c.

Referenced by slot_deform_heap_tuple().

300 {
301 }

◆ tts_heap_store_tuple()

static void tts_heap_store_tuple ( TupleTableSlot slot,
HeapTuple  tuple,
bool  shouldFree 
)
static

Definition at line 430 of file execTuples.c.

References HeapTupleTableSlot::off, HeapTupleData::t_self, TTS_FLAG_EMPTY, TTS_FLAG_SHOULDFREE, TupleTableSlot::tts_flags, tts_heap_clear(), TupleTableSlot::tts_nvalid, TupleTableSlot::tts_tid, and HeapTupleTableSlot::tuple.

Referenced by ExecStoreHeapTuple().

431 {
432  HeapTupleTableSlot *hslot = (HeapTupleTableSlot *) slot;
433 
434  tts_heap_clear(slot);
435 
436  slot->tts_nvalid = 0;
437  hslot->tuple = tuple;
438  hslot->off = 0;
439  slot->tts_flags &= ~TTS_FLAG_EMPTY;
440  slot->tts_tid = tuple->t_self;
441 
442  if (shouldFree)
444 }
#define TTS_FLAG_EMPTY
Definition: tuptable.h:96
#define TTS_FLAG_SHOULDFREE
Definition: tuptable.h:100
HeapTuple tuple
Definition: tuptable.h:250
static void tts_heap_clear(TupleTableSlot *slot)
Definition: execTuples.c:304
uint16 tts_flags
Definition: tuptable.h:119
ItemPointerData t_self
Definition: htup.h:65
AttrNumber tts_nvalid
Definition: tuptable.h:121
ItemPointerData tts_tid
Definition: tuptable.h:130

◆ tts_minimal_clear()

static void tts_minimal_clear ( TupleTableSlot slot)
static

Definition at line 469 of file execTuples.c.

References heap_free_minimal_tuple(), ItemPointerSetInvalid, MinimalTupleTableSlot::mintuple, MinimalTupleTableSlot::off, TTS_FLAG_EMPTY, TTS_FLAG_SHOULDFREE, TupleTableSlot::tts_flags, TupleTableSlot::tts_nvalid, TTS_SHOULDFREE, and TupleTableSlot::tts_tid.

Referenced by slot_deform_heap_tuple(), and tts_minimal_store_tuple().

470 {
472 
473  if (TTS_SHOULDFREE(slot))
474  {
476  slot->tts_flags &= ~TTS_FLAG_SHOULDFREE;
477  }
478 
479  slot->tts_nvalid = 0;
480  slot->tts_flags |= TTS_FLAG_EMPTY;
482  mslot->off = 0;
483  mslot->mintuple = NULL;
484 }
#define TTS_FLAG_EMPTY
Definition: tuptable.h:96
#define TTS_SHOULDFREE(slot)
Definition: tuptable.h:101
#define TTS_FLAG_SHOULDFREE
Definition: tuptable.h:100
uint16 tts_flags
Definition: tuptable.h:119
void heap_free_minimal_tuple(MinimalTuple mtup)
Definition: heaptuple.c:1427
MinimalTuple mintuple
Definition: tuptable.h:284
#define ItemPointerSetInvalid(pointer)
Definition: itemptr.h:172
AttrNumber tts_nvalid
Definition: tuptable.h:121
ItemPointerData tts_tid
Definition: tuptable.h:130

◆ tts_minimal_copy_heap_tuple()

static HeapTuple tts_minimal_copy_heap_tuple ( TupleTableSlot slot)
static

Definition at line 575 of file execTuples.c.

References heap_tuple_from_minimal_tuple(), MinimalTupleTableSlot::mintuple, and tts_minimal_materialize().

Referenced by slot_deform_heap_tuple().

576 {
578 
579  if (!mslot->mintuple)
581 
583 }
static void tts_minimal_materialize(TupleTableSlot *slot)
Definition: execTuples.c:505
HeapTuple heap_tuple_from_minimal_tuple(MinimalTuple mtup)
Definition: heaptuple.c:1458
MinimalTuple mintuple
Definition: tuptable.h:284

◆ tts_minimal_copy_minimal_tuple()

static MinimalTuple tts_minimal_copy_minimal_tuple ( TupleTableSlot slot)
static

Definition at line 586 of file execTuples.c.

References heap_copy_minimal_tuple(), MinimalTupleTableSlot::mintuple, and tts_minimal_materialize().

Referenced by slot_deform_heap_tuple().

587 {
589 
590  if (!mslot->mintuple)
592 
593  return heap_copy_minimal_tuple(mslot->mintuple);
594 }
static void tts_minimal_materialize(TupleTableSlot *slot)
Definition: execTuples.c:505
MinimalTuple heap_copy_minimal_tuple(MinimalTuple mtup)
Definition: heaptuple.c:1439
MinimalTuple mintuple
Definition: tuptable.h:284

◆ tts_minimal_copyslot()

static void tts_minimal_copyslot ( TupleTableSlot dstslot,
TupleTableSlot srcslot 
)
static

Definition at line 551 of file execTuples.c.

References ExecCopySlotMinimalTuple(), ExecStoreMinimalTuple(), MemoryContextSwitchTo(), and TupleTableSlot::tts_mcxt.

Referenced by slot_deform_heap_tuple().

552 {
553  MemoryContext oldcontext;
554  MinimalTuple mintuple;
555 
556  oldcontext = MemoryContextSwitchTo(dstslot->tts_mcxt);
557  mintuple = ExecCopySlotMinimalTuple(srcslot);
558  MemoryContextSwitchTo(oldcontext);
559 
560  ExecStoreMinimalTuple(mintuple, dstslot, true);
561 }
TupleTableSlot * ExecStoreMinimalTuple(MinimalTuple mtup, TupleTableSlot *slot, bool shouldFree)
Definition: execTuples.c:1410
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
MemoryContext tts_mcxt
Definition: tuptable.h:129
static MinimalTuple ExecCopySlotMinimalTuple(TupleTableSlot *slot)
Definition: tuptable.h:464

◆ tts_minimal_get_minimal_tuple()

static MinimalTuple tts_minimal_get_minimal_tuple ( TupleTableSlot slot)
static

Definition at line 564 of file execTuples.c.

References MinimalTupleTableSlot::mintuple, and tts_minimal_materialize().

Referenced by slot_deform_heap_tuple().

565 {
567 
568  if (!mslot->mintuple)
570 
571  return mslot->mintuple;
572 }
static void tts_minimal_materialize(TupleTableSlot *slot)
Definition: execTuples.c:505
MinimalTuple mintuple
Definition: tuptable.h:284

◆ tts_minimal_getsomeattrs()

static void tts_minimal_getsomeattrs ( TupleTableSlot slot,
int  natts 
)
static

Definition at line 487 of file execTuples.c.

References Assert, MinimalTupleTableSlot::off, slot_deform_heap_tuple(), TTS_EMPTY, and MinimalTupleTableSlot::tuple.

Referenced by slot_deform_heap_tuple().

488 {
490 
491  Assert(!TTS_EMPTY(slot));
492 
493  slot_deform_heap_tuple(slot, mslot->tuple, &mslot->off, natts);
494 }
#define TTS_EMPTY(slot)
Definition: tuptable.h:97
static pg_attribute_always_inline void slot_deform_heap_tuple(TupleTableSlot *slot, HeapTuple tuple, uint32 *offp, int natts)
Definition: execTuples.c:889
#define Assert(condition)
Definition: c.h:732

◆ tts_minimal_getsysattr()

static Datum tts_minimal_getsysattr ( TupleTableSlot slot,
int  attnum,
bool isnull 
)
static

Definition at line 497 of file execTuples.c.

References elog, and ERROR.

Referenced by slot_deform_heap_tuple().

498 {
499  elog(ERROR, "minimal tuple table slot does not have system attributes");
500 
501  return 0; /* silence compiler warnings */
502 }
#define ERROR
Definition: elog.h:43
#define elog(elevel,...)
Definition: elog.h:226

◆ tts_minimal_init()

static void tts_minimal_init ( TupleTableSlot slot)
static

Definition at line 452 of file execTuples.c.

References MinimalTupleTableSlot::minhdr, and MinimalTupleTableSlot::tuple.

Referenced by slot_deform_heap_tuple().

453 {
455 
456  /*
457  * Initialize the heap tuple pointer to access attributes of the minimal
458  * tuple contained in the slot as if its a heap tuple.
459  */
460  mslot->tuple = &mslot->minhdr;
461 }
HeapTupleData minhdr
Definition: tuptable.h:285

◆ tts_minimal_materialize()

static void tts_minimal_materialize ( TupleTableSlot slot)
static

Definition at line 505 of file execTuples.c.

References Assert, heap_copy_minimal_tuple(), heap_form_minimal_tuple(), MemoryContextSwitchTo(), MinimalTupleTableSlot::minhdr, MINIMAL_TUPLE_OFFSET, MinimalTupleTableSlot::mintuple, MinimalTupleTableSlot::off, HeapTupleData::t_data, HeapTupleData::t_len, MinimalTupleData::t_len, TTS_EMPTY, TTS_FLAG_SHOULDFREE, TupleTableSlot::tts_flags, TupleTableSlot::tts_isnull, TupleTableSlot::tts_mcxt, TupleTableSlot::tts_nvalid, TTS_SHOULDFREE, TupleTableSlot::tts_tupleDescriptor, TupleTableSlot::tts_values, and MinimalTupleTableSlot::tuple.

Referenced by slot_deform_heap_tuple(), tts_minimal_copy_heap_tuple(), tts_minimal_copy_minimal_tuple(), and tts_minimal_get_minimal_tuple().

506 {
508  MemoryContext oldContext;
509 
510  Assert(!TTS_EMPTY(slot));
511 
512  /* This slot has it's tuple already materialized. Nothing to do. */
513  if (TTS_SHOULDFREE(slot))
514  return;
515 
517  oldContext = MemoryContextSwitchTo(slot->tts_mcxt);
518 
519  if (!mslot->mintuple)
520  {
522  slot->tts_values,
523  slot->tts_isnull);
524  }
525  else
526  {
527  /*
528  * The minimal tuple contained in this slot is not allocated in the
529  * memory context of the given slot (else it would have TTS_SHOULDFREE
530  * set). Copy the minimal tuple into the given slot's memory context.
531  */
532  mslot->mintuple = heap_copy_minimal_tuple(mslot->mintuple);
533  }
534 
535  Assert(mslot->tuple == &mslot->minhdr);
536 
537  mslot->minhdr.t_len = mslot->mintuple->t_len + MINIMAL_TUPLE_OFFSET;
538  mslot->minhdr.t_data = (HeapTupleHeader) ((char *) mslot->mintuple - MINIMAL_TUPLE_OFFSET);
539 
540  MemoryContextSwitchTo(oldContext);
541 
542  /*
543  * Have to deform from scratch, otherwise tts_values[] entries could point
544  * into the non-materialized tuple (which might be gone when accessed).
545  */
546  slot->tts_nvalid = 0;
547  mslot->off = 0;
548 }
#define TTS_EMPTY(slot)
Definition: tuptable.h:97
HeapTupleHeaderData * HeapTupleHeader
Definition: htup.h:23
#define TTS_SHOULDFREE(slot)
Definition: tuptable.h:101
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
#define TTS_FLAG_SHOULDFREE
Definition: tuptable.h:100
MemoryContext tts_mcxt
Definition: tuptable.h:129
Datum * tts_values
Definition: tuptable.h:126
MinimalTuple heap_copy_minimal_tuple(MinimalTuple mtup)
Definition: heaptuple.c:1439
HeapTupleHeader t_data
Definition: htup.h:68
uint16 tts_flags
Definition: tuptable.h:119
uint32 t_len
Definition: htup.h:64
bool * tts_isnull
Definition: tuptable.h:128
MinimalTuple heap_form_minimal_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
Definition: heaptuple.c:1356
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
#define Assert(condition)
Definition: c.h:732
#define MINIMAL_TUPLE_OFFSET
Definition: htup_details.h:619
MinimalTuple mintuple
Definition: tuptable.h:284
HeapTupleData minhdr
Definition: tuptable.h:285
AttrNumber tts_nvalid
Definition: tuptable.h:121

◆ tts_minimal_release()

static void tts_minimal_release ( TupleTableSlot slot)
static

Definition at line 464 of file execTuples.c.

Referenced by slot_deform_heap_tuple().

465 {
466 }

◆ tts_minimal_store_tuple()

static void tts_minimal_store_tuple ( TupleTableSlot slot,
MinimalTuple  mtup,
bool  shouldFree 
)
static

Definition at line 597 of file execTuples.c.

References Assert, MinimalTupleTableSlot::minhdr, MINIMAL_TUPLE_OFFSET, MinimalTupleTableSlot::mintuple, MinimalTupleTableSlot::off, HeapTupleData::t_data, HeapTupleData::t_len, MinimalTupleData::t_len, TTS_EMPTY, TTS_FLAG_EMPTY, TTS_FLAG_SHOULDFREE, TupleTableSlot::tts_flags, tts_minimal_clear(), TupleTableSlot::tts_nvalid, TTS_SHOULDFREE, and MinimalTupleTableSlot::tuple.

Referenced by ExecForceStoreMinimalTuple(), and ExecStoreMinimalTuple().

598 {
600 
601  tts_minimal_clear(slot);
602 
603  Assert(!TTS_SHOULDFREE(slot));
604  Assert(TTS_EMPTY(slot));
605 
606  slot->tts_flags &= ~TTS_FLAG_EMPTY;
607  slot->tts_nvalid = 0;
608  mslot->off = 0;
609 
610  mslot->mintuple = mtup;
611  Assert(mslot->tuple == &mslot->minhdr);
612  mslot->minhdr.t_len = mtup->t_len + MINIMAL_TUPLE_OFFSET;
613  mslot->minhdr.t_data = (HeapTupleHeader) ((char *) mtup - MINIMAL_TUPLE_OFFSET);
614  /* no need to set t_self or t_tableOid since we won't allow access */
615 
616  if (shouldFree)
618  else
619  Assert(!TTS_SHOULDFREE(slot));
620 }
#define TTS_FLAG_EMPTY
Definition: tuptable.h:96
#define TTS_EMPTY(slot)
Definition: tuptable.h:97
HeapTupleHeaderData * HeapTupleHeader
Definition: htup.h:23
#define TTS_SHOULDFREE(slot)
Definition: tuptable.h:101
#define TTS_FLAG_SHOULDFREE
Definition: tuptable.h:100
HeapTupleHeader t_data
Definition: htup.h:68
uint16 tts_flags
Definition: tuptable.h:119
uint32 t_len
Definition: htup.h:64
static void tts_minimal_clear(TupleTableSlot *slot)
Definition: execTuples.c:469
#define Assert(condition)
Definition: c.h:732
#define MINIMAL_TUPLE_OFFSET
Definition: htup_details.h:619
MinimalTuple mintuple
Definition: tuptable.h:284
HeapTupleData minhdr
Definition: tuptable.h:285
AttrNumber tts_nvalid
Definition: tuptable.h:121

◆ tts_virtual_clear()

static void tts_virtual_clear ( TupleTableSlot slot)
static

Definition at line 107 of file execTuples.c.

References VirtualTupleTableSlot::data, ItemPointerSetInvalid, pfree(), TTS_FLAG_EMPTY, TTS_FLAG_SHOULDFREE, TupleTableSlot::tts_flags, TupleTableSlot::tts_nvalid, TTS_SHOULDFREE, TupleTableSlot::tts_tid, and unlikely.

Referenced by slot_deform_heap_tuple(), and tts_virtual_copyslot().

108 {
109  if (unlikely(TTS_SHOULDFREE(slot)))
110  {
112 
113  pfree(vslot->data);
114  vslot->data = NULL;
115 
116  slot->tts_flags &= ~TTS_FLAG_SHOULDFREE;
117  }
118 
119  slot->tts_nvalid = 0;
120  slot->tts_flags |= TTS_FLAG_EMPTY;
122 }
#define TTS_FLAG_EMPTY
Definition: tuptable.h:96
#define TTS_SHOULDFREE(slot)
Definition: tuptable.h:101
#define TTS_FLAG_SHOULDFREE
Definition: tuptable.h:100
uint16 tts_flags
Definition: tuptable.h:119
void pfree(void *pointer)
Definition: mcxt.c:1031
#define ItemPointerSetInvalid(pointer)
Definition: itemptr.h:172
#define unlikely(x)
Definition: c.h:208
AttrNumber tts_nvalid
Definition: tuptable.h:121
ItemPointerData tts_tid
Definition: tuptable.h:130

◆ tts_virtual_copy_heap_tuple()

static HeapTuple tts_virtual_copy_heap_tuple ( TupleTableSlot slot)
static

Definition at line 268 of file execTuples.c.

References Assert, heap_form_tuple(), TTS_EMPTY, TupleTableSlot::tts_isnull, TupleTableSlot::tts_tupleDescriptor, and TupleTableSlot::tts_values.

Referenced by slot_deform_heap_tuple().

269 {
270  Assert(!TTS_EMPTY(slot));
271 
273  slot->tts_values,
274  slot->tts_isnull);
275 
276 }
#define TTS_EMPTY(slot)
Definition: tuptable.h:97
Datum * tts_values
Definition: tuptable.h:126
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
Definition: heaptuple.c:1020
bool * tts_isnull
Definition: tuptable.h:128
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
#define Assert(condition)
Definition: c.h:732

◆ tts_virtual_copy_minimal_tuple()

static MinimalTuple tts_virtual_copy_minimal_tuple ( TupleTableSlot slot)
static

Definition at line 279 of file execTuples.c.

References Assert, heap_form_minimal_tuple(), TTS_EMPTY, TupleTableSlot::tts_isnull, TupleTableSlot::tts_tupleDescriptor, and TupleTableSlot::tts_values.

Referenced by slot_deform_heap_tuple().

280 {
281  Assert(!TTS_EMPTY(slot));
282 
284  slot->tts_values,
285  slot->tts_isnull);
286 }
#define TTS_EMPTY(slot)
Definition: tuptable.h:97
Datum * tts_values
Definition: tuptable.h:126
bool * tts_isnull
Definition: tuptable.h:128
MinimalTuple heap_form_minimal_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
Definition: heaptuple.c:1356
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
#define Assert(condition)
Definition: c.h:732

◆ tts_virtual_copyslot()

static void tts_virtual_copyslot ( TupleTableSlot dstslot,
TupleTableSlot srcslot 
)
static

Definition at line 244 of file execTuples.c.

References Assert, TupleDescData::natts, slot_getallattrs(), TTS_FLAG_EMPTY, TupleTableSlot::tts_flags, TupleTableSlot::tts_isnull, TupleTableSlot::tts_nvalid, TupleTableSlot::tts_tupleDescriptor, TupleTableSlot::tts_values, tts_virtual_clear(), and tts_virtual_materialize().

Referenced by slot_deform_heap_tuple().

245 {
246  TupleDesc srcdesc = dstslot->tts_tupleDescriptor;
247 
248  Assert(srcdesc->natts <= dstslot->tts_tupleDescriptor->natts);
249 
250  tts_virtual_clear(dstslot);
251 
252  slot_getallattrs(srcslot);
253 
254  for (int natt = 0; natt < srcdesc->natts; natt++)
255  {
256  dstslot->tts_values[natt] = srcslot->tts_values[natt];
257  dstslot->tts_isnull[natt] = srcslot->tts_isnull[natt];
258  }
259 
260  dstslot->tts_nvalid = srcdesc->natts;
261  dstslot->tts_flags &= ~TTS_FLAG_EMPTY;
262 
263  /* make sure storage doesn't depend on external memory */
264  tts_virtual_materialize(dstslot);
265 }
#define TTS_FLAG_EMPTY
Definition: tuptable.h:96
Datum * tts_values
Definition: tuptable.h:126
uint16 tts_flags
Definition: tuptable.h:119
static void slot_getallattrs(TupleTableSlot *slot)
Definition: tuptable.h:355
bool * tts_isnull
Definition: tuptable.h:128
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
static void tts_virtual_materialize(TupleTableSlot *slot)
Definition: execTuples.c:151
#define Assert(condition)
Definition: c.h:732
static void tts_virtual_clear(TupleTableSlot *slot)
Definition: execTuples.c:107
AttrNumber tts_nvalid
Definition: tuptable.h:121

◆ tts_virtual_getsomeattrs()

static void tts_virtual_getsomeattrs ( TupleTableSlot slot,
int  natts 
)
static

Definition at line 130 of file execTuples.c.

References elog, and ERROR.

Referenced by slot_deform_heap_tuple().

131 {
132  elog(ERROR, "getsomeattrs is not required to be called on a virtual tuple table slot");
133 }
#define ERROR
Definition: elog.h:43
#define elog(elevel,...)
Definition: elog.h:226

◆ tts_virtual_getsysattr()

static Datum tts_virtual_getsysattr ( TupleTableSlot slot,
int  attnum,
bool isnull 
)
static

Definition at line 136 of file execTuples.c.

References elog, and ERROR.

Referenced by slot_deform_heap_tuple().

137 {
138  elog(ERROR, "virtual tuple table slot does not have system attributes");
139 
140  return 0; /* silence compiler warnings */
141 }
#define ERROR
Definition: elog.h:43
#define elog(elevel,...)
Definition: elog.h:226

◆ tts_virtual_init()

static void tts_virtual_init ( TupleTableSlot slot)
static

Definition at line 97 of file execTuples.c.

Referenced by slot_deform_heap_tuple().

98 {
99 }

◆ tts_virtual_materialize()

static void tts_virtual_materialize ( TupleTableSlot slot)
static

Definition at line 151 of file execTuples.c.

References att_addlength_datum, att_align_nominal, VirtualTupleTableSlot::data, DatumGetEOHP(), DatumGetPointer, EOH_flatten_into(), EOH_get_flat_size(), MemoryContextAlloc(), TupleDescData::natts, PointerGetDatum, TTS_FLAG_SHOULDFREE, TupleTableSlot::tts_flags, TupleTableSlot::tts_isnull, TupleTableSlot::tts_mcxt, TTS_SHOULDFREE, TupleTableSlot::tts_tupleDescriptor, TupleTableSlot::tts_values, TupleDescAttr, val, and VARATT_IS_EXTERNAL_EXPANDED.

Referenced by slot_deform_heap_tuple(), and tts_virtual_copyslot().

152 {
154  TupleDesc desc = slot->tts_tupleDescriptor;
155  Size sz = 0;
156  char *data;
157 
158  /* already materialized */
159  if (TTS_SHOULDFREE(slot))
160  return;
161 
162  /* compute size of memory required */
163  for (int natt = 0; natt < desc->natts; natt++)
164  {
165  Form_pg_attribute att = TupleDescAttr(desc, natt);
166  Datum val;
167 
168  if (att->attbyval || slot->tts_isnull[natt])
169  continue;
170 
171  val = slot->tts_values[natt];
172 
173  if (att->attlen == -1 &&
175  {
176  /*
177  * We want to flatten the expanded value so that the materialized
178  * slot doesn't depend on it.
179  */
180  sz = att_align_nominal(sz, att->attalign);
181  sz += EOH_get_flat_size(DatumGetEOHP(val));
182  }
183  else
184  {
185  sz = att_align_nominal(sz, att->attalign);
186  sz = att_addlength_datum(sz, att->attlen, val);
187  }
188  }
189 
190  /* all data is byval */
191  if (sz == 0)
192  return;
193 
194  /* allocate memory */
195  vslot->data = data = MemoryContextAlloc(slot->tts_mcxt, sz);
197 
198  /* and copy all attributes into the pre-allocated space */
199  for (int natt = 0; natt < desc->natts; natt++)
200  {
201  Form_pg_attribute att = TupleDescAttr(desc, natt);
202  Datum val;
203 
204  if (att->attbyval || slot->tts_isnull[natt])
205  continue;
206 
207  val = slot->tts_values[natt];
208 
209  if (att->attlen == -1 &&
211  {
212  Size data_length;
213 
214  /*
215  * We want to flatten the expanded value so that the materialized
216  * slot doesn't depend on it.
217  */
219 
220  data = (char *) att_align_nominal(data,
221  att->attalign);
222  data_length = EOH_get_flat_size(eoh);
223  EOH_flatten_into(eoh, data, data_length);
224 
225  slot->tts_values[natt] = PointerGetDatum(data);
226  data += data_length;
227  }
228  else
229  {
230  Size data_length = 0;
231 
232  data = (char *) att_align_nominal(data, att->attalign);
233  data_length = att_addlength_datum(data_length, att->attlen, val);
234 
235  memcpy(data, DatumGetPointer(val), data_length);
236 
237  slot->tts_values[natt] = PointerGetDatum(data);
238  data += data_length;
239  }
240  }
241 }
#define att_align_nominal(cur_offset, attalign)
Definition: tupmacs.h:146
#define VARATT_IS_EXTERNAL_EXPANDED(PTR)
Definition: postgres.h:322
#define PointerGetDatum(X)
Definition: postgres.h:556
#define TTS_SHOULDFREE(slot)
Definition: tuptable.h:101
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:92
#define TTS_FLAG_SHOULDFREE
Definition: tuptable.h:100
MemoryContext tts_mcxt
Definition: tuptable.h:129
Datum * tts_values
Definition: tuptable.h:126
uint16 tts_flags
Definition: tuptable.h:119
bool * tts_isnull
Definition: tuptable.h:128
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:200
Size EOH_get_flat_size(ExpandedObjectHeader *eohptr)
Definition: expandeddatum.c:75
ExpandedObjectHeader * DatumGetEOHP(Datum d)
Definition: expandeddatum.c:29
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
uintptr_t Datum
Definition: postgres.h:367
void EOH_flatten_into(ExpandedObjectHeader *eohptr, void *result, Size allocated_size)
Definition: expandeddatum.c:81
size_t Size
Definition: c.h:466
#define DatumGetPointer(X)
Definition: postgres.h:549
#define att_addlength_datum(cur_offset, attlen, attdatum)
Definition: tupmacs.h:162
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition: mcxt.c:771
long val
Definition: informix.c:689

◆ tts_virtual_release()

static void tts_virtual_release ( TupleTableSlot slot)
static

Definition at line 102 of file execTuples.c.

Referenced by slot_deform_heap_tuple().

103 {
104 }

◆ TupleDescGetAttInMetadata()

AttInMetadata* TupleDescGetAttInMetadata ( TupleDesc  tupdesc)

Definition at line 2062 of file execTuples.c.

References AttInMetadata::attinfuncs, AttInMetadata::attioparams, AttInMetadata::atttypmods, BlessTupleDesc(), fmgr_info(), getTypeInputInfo(), i, TupleDescData::natts, palloc(), palloc0(), AttInMetadata::tupdesc, and TupleDescAttr.

Referenced by bt_metap(), bt_page_items(), bt_page_items_bytea(), bt_page_stats(), build_pgstattuple_type(), connectby_text(), connectby_text_serial(), create_foreign_modify(), crosstab(), dblink_get_pkey(), get_crosstab_tuplestore(), hash_page_items(), libpqrcv_processTuples(), materializeResult(), pg_config(), pg_get_keywords(), pg_get_multixact_members(), pg_logdir_ls_internal(), pg_stats_ext_mcvlist_items(), pgp_armor_headers(), pgrowlocks(), pgstatindex_impl(), pltcl_build_tuple_result(), pltcl_func_handler(), pltcl_init_tuple_store(), postgresAcquireSampleRowsFunc(), postgresBeginDirectModify(), postgresBeginForeignScan(), prs_setup_firstcall(), show_all_settings(), storeRow(), ts_setup_firstcall(), tt_setup_firstcall(), and xpath_table().

2063 {
2064  int natts = tupdesc->natts;
2065  int i;
2066  Oid atttypeid;
2067  Oid attinfuncid;
2068  FmgrInfo *attinfuncinfo;
2069  Oid *attioparams;
2070  int32 *atttypmods;
2071  AttInMetadata *attinmeta;
2072 
2073  attinmeta = (AttInMetadata *) palloc(sizeof(AttInMetadata));
2074 
2075  /* "Bless" the tupledesc so that we can make rowtype datums with it */
2076  attinmeta->tupdesc = BlessTupleDesc(tupdesc);
2077 
2078  /*
2079  * Gather info needed later to call the "in" function for each attribute
2080  */
2081  attinfuncinfo = (FmgrInfo *) palloc0(natts * sizeof(FmgrInfo));
2082  attioparams = (Oid *) palloc0(natts * sizeof(Oid));
2083  atttypmods = (int32 *) palloc0(natts * sizeof(int32));
2084 
2085  for (i = 0; i < natts; i++)
2086  {
2087  Form_pg_attribute att = TupleDescAttr(tupdesc, i);
2088 
2089  /* Ignore dropped attributes */
2090  if (!att->attisdropped)
2091  {
2092  atttypeid = att->atttypid;
2093  getTypeInputInfo(atttypeid, &attinfuncid, &attioparams[i]);
2094  fmgr_info(attinfuncid, &attinfuncinfo[i]);
2095  atttypmods[i] = att->atttypmod;
2096  }
2097  }
2098  attinmeta->attinfuncs = attinfuncinfo;
2099  attinmeta->attioparams = attioparams;
2100  attinmeta->atttypmods = atttypmods;
2101 
2102  return attinmeta;
2103 }
Definition: fmgr.h:56
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:92
int32 * atttypmods
Definition: funcapi.h:48
unsigned int Oid
Definition: postgres_ext.h:31
Oid * attioparams
Definition: funcapi.h:45
signed int int32
Definition: c.h:346
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:124
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
Definition: execTuples.c:2047
TupleDesc tupdesc
Definition: funcapi.h:39
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:200
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
Definition: lsyscache.c:2641
void * palloc0(Size size)
Definition: mcxt.c:955
void * palloc(Size size)
Definition: mcxt.c:924
int i
FmgrInfo * attinfuncs
Definition: funcapi.h:42

Variable Documentation

◆ TTSOpsBufferHeapTuple

const TupleTableSlotOps TTSOpsBufferHeapTuple
Initial value:
= {
.base_slot_size = sizeof(BufferHeapTupleTableSlot),
.get_heap_tuple = tts_buffer_heap_get_heap_tuple,
.get_minimal_tuple = NULL,
.copy_heap_tuple = tts_buffer_heap_copy_heap_tuple,
.copy_minimal_tuple = tts_buffer_heap_copy_minimal_tuple
}
static void tts_buffer_heap_copyslot(TupleTableSlot *dstslot, TupleTableSlot *srcslot)
Definition: execTuples.c:742
static HeapTuple tts_buffer_heap_get_heap_tuple(TupleTableSlot *slot)
Definition: execTuples.c:784
static MinimalTuple tts_buffer_heap_copy_minimal_tuple(TupleTableSlot *slot)
Definition: execTuples.c:810
static Datum tts_buffer_heap_getsysattr(TupleTableSlot *slot, int attnum, bool *isnull)
Definition: execTuples.c:680
static HeapTuple tts_buffer_heap_copy_heap_tuple(TupleTableSlot *slot)
Definition: execTuples.c:797
static void tts_buffer_heap_init(TupleTableSlot *slot)
Definition: execTuples.c:628
#define init()
struct BufferHeapTupleTableSlot BufferHeapTupleTableSlot
static void tts_buffer_heap_clear(TupleTableSlot *slot)
Definition: execTuples.c:638
static void tts_buffer_heap_getsomeattrs(TupleTableSlot *slot, int natts)
Definition: execTuples.c:670
static void tts_buffer_heap_materialize(TupleTableSlot *slot)
Definition: execTuples.c:689
static void tts_buffer_heap_release(TupleTableSlot *slot)
Definition: execTuples.c:633

Definition at line 86 of file execTuples.c.

Referenced by CheckOpSlotCompatibility(), heapam_slot_callbacks(), and slot_compile_deform().

◆ TTSOpsHeapTuple

const TupleTableSlotOps TTSOpsHeapTuple
Initial value:
= {
.base_slot_size = sizeof(HeapTupleTableSlot),
.release = tts_heap_release,
.clear = tts_heap_clear,
.getsomeattrs = tts_heap_getsomeattrs,
.getsysattr = tts_heap_getsysattr,
.materialize = tts_heap_materialize,
.copyslot = tts_heap_copyslot,
.get_heap_tuple = tts_heap_get_heap_tuple,
.get_minimal_tuple = NULL,
.copy_heap_tuple = tts_heap_copy_heap_tuple,
.copy_minimal_tuple = tts_heap_copy_minimal_tuple
}
static void tts_heap_materialize(TupleTableSlot *slot)
Definition: execTuples.c:342
static void tts_heap_clear(TupleTableSlot *slot)
Definition: execTuples.c:304
static Datum tts_heap_getsysattr(TupleTableSlot *slot, int attnum, bool *isnull)
Definition: execTuples.c:333
static HeapTuple tts_heap_get_heap_tuple(TupleTableSlot *slot)
Definition: execTuples.c:395
struct HeapTupleTableSlot HeapTupleTableSlot
static void tts_heap_copyslot(TupleTableSlot *dstslot, TupleTableSlot *srcslot)
Definition: execTuples.c:382
#define init()
static void tts_heap_release(TupleTableSlot *slot)
Definition: execTuples.c:299
static MinimalTuple tts_heap_copy_minimal_tuple(TupleTableSlot *slot)
Definition: execTuples.c:419
static void tts_heap_init(TupleTableSlot *slot)
Definition: execTuples.c:294
static void tts_heap_getsomeattrs(TupleTableSlot *slot, int natts)
Definition: execTuples.c:323
static HeapTuple tts_heap_copy_heap_tuple(TupleTableSlot *slot)
Definition: execTuples.c:407

Definition at line 84 of file execTuples.c.

Referenced by CatalogIndexInsert(), CheckOpSlotCompatibility(), compute_index_stats(), ExecInitForeignScan(), ExecInitGather(), ExecInitSetOp(), ExecuteCallStmt(), gather_merge_setup(), heapam_index_validate_scan(), slot_compile_deform(), and table_slot_callbacks().

◆ TTSOpsMinimalTuple

const TupleTableSlotOps TTSOpsMinimalTuple
Initial value:
= {
.base_slot_size = sizeof(MinimalTupleTableSlot),
.release = tts_minimal_release,
.getsomeattrs = tts_minimal_getsomeattrs,
.getsysattr = tts_minimal_getsysattr,
.materialize = tts_minimal_materialize,
.copyslot = tts_minimal_copyslot,
.get_heap_tuple = NULL,
.get_minimal_tuple = tts_minimal_get_minimal_tuple,
.copy_heap_tuple = tts_minimal_copy_heap_tuple,
.copy_minimal_tuple = tts_minimal_copy_minimal_tuple
}
static void tts_minimal_materialize(TupleTableSlot *slot)
Definition: execTuples.c:505
static void tts_minimal_getsomeattrs(TupleTableSlot *slot, int natts)
Definition: execTuples.c:487
static void tts_minimal_init(TupleTableSlot *slot)
Definition: execTuples.c:452
static HeapTuple tts_minimal_copy_heap_tuple(TupleTableSlot *slot)
Definition: execTuples.c:575
static MinimalTuple tts_minimal_get_minimal_tuple(TupleTableSlot *slot)
Definition: execTuples.c:564
static MinimalTuple tts_minimal_copy_minimal_tuple(TupleTableSlot *slot)
Definition: execTuples.c:586
#define init()
static Datum tts_minimal_getsysattr(TupleTableSlot *slot, int attnum, bool *isnull)
Definition: execTuples.c:497
static void tts_minimal_release(TupleTableSlot *slot)
Definition: execTuples.c:464
struct MinimalTupleTableSlot MinimalTupleTableSlot
static void tts_minimal_clear(TupleTableSlot *slot)
Definition: execTuples.c:469
static void tts_minimal_copyslot(TupleTableSlot *dstslot, TupleTableSlot *srcslot)
Definition: execTuples.c:551

Definition at line 85 of file execTuples.c.

Referenced by afterTriggerInvokeEvents(), build_pertrans_for_aggref(), BuildTupleHashTableExt(), check_sql_fn_retval(), ExecInitAgg(), ExecInitCteScan(), ExecInitFunctionScan(), ExecInitHash(), ExecInitMaterial(), ExecInitNamedTuplestoreScan(), ExecInitSetOp(), ExecInitSort(), ExecInitSubPlan(), ExecInitTableFuncScan(), ExecInitUnique(), ExecInitWindowAgg(), ExecInitWorkTableScan(), ExecPrepareTuplestoreResult(), fetch_remote_table_info(), fetch_table_list(), find_hash_columns(), hypothetical_dense_rank_final(), ordered_set_startup(), RunFromStore(), and slot_compile_deform().

◆ TTSOpsVirtual

const TupleTableSlotOps TTSOpsVirtual
Initial value:
= {
.base_slot_size = sizeof(VirtualTupleTableSlot),
.release = tts_virtual_release,
.getsomeattrs = tts_virtual_getsomeattrs,
.getsysattr = tts_virtual_getsysattr,
.materialize = tts_virtual_materialize,
.copyslot = tts_virtual_copyslot,
.get_heap_tuple = NULL,
.get_minimal_tuple = NULL,
.copy_heap_tuple = tts_virtual_copy_heap_tuple,
.copy_minimal_tuple = tts_virtual_copy_minimal_tuple
}
static HeapTuple tts_virtual_copy_heap_tuple(TupleTableSlot *slot)
Definition: execTuples.c:268
struct VirtualTupleTableSlot VirtualTupleTableSlot
static void tts_virtual_getsomeattrs(TupleTableSlot *slot, int natts)
Definition: execTuples.c:130
static void tts_virtual_init(TupleTableSlot *slot)
Definition: execTuples.c:97
static Datum tts_virtual_getsysattr(TupleTableSlot *slot, int attnum, bool *isnull)
Definition: execTuples.c:136
#define init()
static void tts_virtual_materialize(TupleTableSlot *slot)
Definition: execTuples.c:151
static MinimalTuple tts_virtual_copy_minimal_tuple(TupleTableSlot *slot)
Definition: execTuples.c:279
static void tts_virtual_clear(TupleTableSlot *slot)
Definition: execTuples.c:107
static void tts_virtual_copyslot(TupleTableSlot *dstslot, TupleTableSlot *srcslot)
Definition: execTuples.c:244
static void tts_virtual_release(TupleTableSlot *slot)
Definition: execTuples.c:102

Definition at line 83 of file execTuples.c.

Referenced by AfterTriggerSaveEvent(), apply_handle_delete(), apply_handle_insert(), apply_handle_update(), CheckOpSlotCompatibility(), CreateReplicationSlot(), EvalPlanQualSlot(), ExecConditionalAssignProjectionInfo(), ExecConstraints(), ExecGetResultSlotOps(), ExecInitAgg(), ExecInitAppend(), ExecInitCustomScan(), ExecInitGroup(), ExecInitHashJoin(), ExecInitIndexOnlyScan(), ExecInitJunkFilter(), ExecInitJunkFilterConversion(), ExecInitMergeAppend(), ExecInitMergeJoin(), ExecInitModifyTable(), ExecInitNestLoop(), ExecInitPartitionDispatchInfo(), ExecInitPartitionInfo(), ExecInitProjectSet(), ExecInitResult(), ExecInitSort(), ExecInitSubPlan(), ExecInitValuesScan(), ExecInitWholeRowVar(), ExecInitWindowAgg(), ExecPartitionCheckEmitError(), ExecWithCheckOptions(), ExplainQuery(), IdentifySystem(), InitPlan(), RI_Initial_Check(), RI_PartitionRemove_Check(), ShowAllGUCConfig(), ShowGUCConfigOption(), slot_compile_deform(), StartReplication(), table_slot_callbacks(), and tuplesort_begin_cluster().