PostgreSQL Source Code  git master
execTuples.c File Reference
#include "postgres.h"
#include "access/heaptoast.h"
#include "access/htup_details.h"
#include "access/tupdesc_details.h"
#include "funcapi.h"
#include "catalog/pg_type.h"
#include "nodes/nodeFuncs.h"
#include "storage/bufmgr.h"
#include "utils/builtins.h"
#include "utils/expandeddatum.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 2232 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().

2235 {
2236  TupOutputState *tstate;
2237 
2238  tstate = (TupOutputState *) palloc(sizeof(TupOutputState));
2239 
2240  tstate->slot = MakeSingleTupleTableSlot(tupdesc, tts_ops);
2241  tstate->dest = dest;
2242 
2243  tstate->dest->rStartup(tstate->dest, (int) CMD_SELECT, tupdesc);
2244 
2245  return tstate;
2246 }
TupleTableSlot * MakeSingleTupleTableSlot(TupleDesc tupdesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1203
TupleTableSlot * slot
Definition: executor.h:458
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:459

◆ BlessTupleDesc()

TupleDesc BlessTupleDesc ( TupleDesc  tupdesc)

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

2049 {
2050  if (tupdesc->tdtypeid == RECORDOID &&
2051  tupdesc->tdtypmod < 0)
2052  assign_record_type_typmod(tupdesc);
2053 
2054  return tupdesc; /* just for notational convenience */
2055 }
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 2112 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().

2113 {
2114  TupleDesc tupdesc = attinmeta->tupdesc;
2115  int natts = tupdesc->natts;
2116  Datum *dvalues;
2117  bool *nulls;
2118  int i;
2119  HeapTuple tuple;
2120 
2121  dvalues = (Datum *) palloc(natts * sizeof(Datum));
2122  nulls = (bool *) palloc(natts * sizeof(bool));
2123 
2124  /*
2125  * Call the "in" function for each non-dropped attribute, even for nulls,
2126  * to support domains.
2127  */
2128  for (i = 0; i < natts; i++)
2129  {
2130  if (!TupleDescAttr(tupdesc, i)->attisdropped)
2131  {
2132  /* Non-dropped attributes */
2133  dvalues[i] = InputFunctionCall(&attinmeta->attinfuncs[i],
2134  values[i],
2135  attinmeta->attioparams[i],
2136  attinmeta->atttypmods[i]);
2137  if (values[i] != NULL)
2138  nulls[i] = false;
2139  else
2140  nulls[i] = true;
2141  }
2142  else
2143  {
2144  /* Handle dropped attributes by setting to NULL */
2145  dvalues[i] = (Datum) 0;
2146  nulls[i] = true;
2147  }
2148  }
2149 
2150  /*
2151  * Form a tuple
2152  */
2153  tuple = heap_form_tuple(tupdesc, dvalues, nulls);
2154 
2155  /*
2156  * Release locally palloc'd space. XXX would probably be good to pfree
2157  * values of pass-by-reference datums, as well.
2158  */
2159  pfree(dvalues);
2160  pfree(nulls);
2161 
2162  return tuple;
2163 }
#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 2280 of file execTuples.c.

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

Referenced by ExplainQuery().

2281 {
2282  Datum values[1];
2283  bool isnull[1] = {false};
2284 
2285  while (*txt)
2286  {
2287  const char *eol;
2288  int len;
2289 
2290  eol = strchr(txt, '\n');
2291  if (eol)
2292  {
2293  len = eol - txt;
2294  eol++;
2295  }
2296  else
2297  {
2298  len = strlen(txt);
2299  eol = txt + len;
2300  }
2301 
2302  values[0] = PointerGetDatum(cstring_to_text_with_len(txt, len));
2303  do_tup_output(tstate, values, isnull);
2304  pfree(DatumGetPointer(values[0]));
2305  txt = eol;
2306  }
2307 }
#define PointerGetDatum(X)
Definition: postgres.h:556
void do_tup_output(TupOutputState *tstate, Datum *values, bool *isnull)
Definition: execTuples.c:2252
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 2252 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().

2253 {
2254  TupleTableSlot *slot = tstate->slot;
2255  int natts = slot->tts_tupleDescriptor->natts;
2256 
2257  /* make sure the slot is clear */
2258  ExecClearTuple(slot);
2259 
2260  /* insert data */
2261  memcpy(slot->tts_values, values, natts * sizeof(Datum));
2262  memcpy(slot->tts_isnull, isnull, natts * sizeof(bool));
2263 
2264  /* mark slot as containing a virtual tuple */
2265  ExecStoreVirtualTuple(slot);
2266 
2267  /* send the tuple to the receiver */
2268  (void) tstate->dest->receiveSlot(slot, tstate->dest);
2269 
2270  /* clean up */
2271  ExecClearTuple(slot);
2272 }
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:458
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:459
TupleTableSlot * ExecStoreVirtualTuple(TupleTableSlot *slot)
Definition: execTuples.c:1517

◆ end_tup_output()

void end_tup_output ( TupOutputState tstate)

Definition at line 2310 of file execTuples.c.

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

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

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

◆ ExecAllocTableSlot()

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

Definition at line 1136 of file execTuples.c.

References lappend(), and MakeTupleTableSlot().

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

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

◆ ExecCleanTypeFromTL()

TupleDesc ExecCleanTypeFromTL ( List targetList)

Definition at line 1916 of file execTuples.c.

References ExecTypeFromTLInternal().

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

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

◆ ExecDropSingleTupleTableSlot()

void ExecDropSingleTupleTableSlot ( TupleTableSlot slot)

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

1220 {
1221  /* This should match ExecResetTupleTable's processing of one slot */
1222  Assert(IsA(slot, TupleTableSlot));
1223  ExecClearTuple(slot);
1224  slot->tts_ops->release(slot);
1225  if (slot->tts_tupleDescriptor)
1227  if (!TTS_FIXED(slot))
1228  {
1229  if (slot->tts_values)
1230  pfree(slot->tts_values);
1231  if (slot->tts_isnull)
1232  pfree(slot->tts_isnull);
1233  }
1234  pfree(slot);
1235 }
#define TTS_FIXED(slot)
Definition: tuptable.h:109
#define IsA(nodeptr, _type_)
Definition: nodes.h:576
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 1609 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().

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

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

Referenced by ExecMakeFunctionResultSet(), and postquel_get_single_result().

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

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

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

◆ ExecForceStoreMinimalTuple()

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

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

1480 {
1481  if (TTS_IS_MINIMALTUPLE(slot))
1482  {
1483  tts_minimal_store_tuple(slot, mtup, shouldFree);
1484  }
1485  else
1486  {
1487  HeapTupleData htup;
1488 
1489  ExecClearTuple(slot);
1490 
1491  htup.t_len = mtup->t_len + MINIMAL_TUPLE_OFFSET;
1492  htup.t_data = (HeapTupleHeader) ((char *) mtup - MINIMAL_TUPLE_OFFSET);
1494  slot->tts_values, slot->tts_isnull);
1495  ExecStoreVirtualTuple(slot);
1496 
1497  if (shouldFree)
1498  {
1499  ExecMaterializeSlot(slot);
1500  pfree(mtup);
1501  }
1502  }
1503 }
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:598
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:1517

◆ ExecInitExtraTupleSlot()

◆ ExecInitNullTupleSlot()

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

Definition at line 1812 of file execTuples.c.

References ExecInitExtraTupleSlot(), and ExecStoreAllNullTuple().

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

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

◆ ExecInitResultSlot()

void ExecInitResultSlot ( PlanState planstate,
const TupleTableSlotOps tts_ops 
)

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

1745 {
1746  TupleTableSlot *slot;
1747 
1748  slot = ExecAllocTableSlot(&planstate->state->es_tupleTable,
1749  planstate->ps_ResultTupleDesc, tts_ops);
1750  planstate->ps_ResultTupleSlot = slot;
1751 
1752  planstate->resultopsfixed = planstate->ps_ResultTupleDesc != NULL;
1753  planstate->resultops = tts_ops;
1754  planstate->resultopsset = true;
1755 }
EState * state
Definition: execnodes.h:942
const TupleTableSlotOps * resultops
Definition: execnodes.h:1015
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:978
bool resultopsset
Definition: execnodes.h:1023
TupleTableSlot * ExecAllocTableSlot(List **tupleTable, TupleDesc desc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1136
TupleDesc ps_ResultTupleDesc
Definition: execnodes.h:977
List * es_tupleTable
Definition: execnodes.h:552
bool resultopsfixed
Definition: execnodes.h:1019

◆ ExecInitResultTupleSlotTL()

void ExecInitResultTupleSlotTL ( PlanState planstate,
const TupleTableSlotOps tts_ops 
)

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

1766 {
1767  ExecInitResultTypeTL(planstate);
1768  ExecInitResultSlot(planstate, tts_ops);
1769 }
void ExecInitResultTypeTL(PlanState *planstate)
Definition: execTuples.c:1720
void ExecInitResultSlot(PlanState *planstate, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1744

◆ ExecInitResultTypeTL()

◆ ExecInitScanTupleSlot()

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

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

1778 {
1779  scanstate->ss_ScanTupleSlot = ExecAllocTableSlot(&estate->es_tupleTable,
1780  tupledesc, tts_ops);
1781  scanstate->ps.scandesc = tupledesc;
1782  scanstate->ps.scanopsfixed = tupledesc != NULL;
1783  scanstate->ps.scanops = tts_ops;
1784  scanstate->ps.scanopsset = true;
1785 }
TupleTableSlot * ss_ScanTupleSlot
Definition: execnodes.h:1334
PlanState ps
Definition: execnodes.h:1331
const TupleTableSlotOps * scanops
Definition: execnodes.h:1012
TupleTableSlot * ExecAllocTableSlot(List **tupleTable, TupleDesc desc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1136
List * es_tupleTable
Definition: execnodes.h:552
TupleDesc scandesc
Definition: execnodes.h:987
bool scanopsfixed
Definition: execnodes.h:1016
bool scanopsset
Definition: execnodes.h:1020

◆ ExecResetTupleTable()

void ExecResetTupleTable ( List tupleTable,
bool  shouldFree 
)

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

1158 {
1159  ListCell *lc;
1160 
1161  foreach(lc, tupleTable)
1162  {
1164 
1165  /* Always release resources and reset the slot to empty */
1166  ExecClearTuple(slot);
1167  slot->tts_ops->release(slot);
1168  if (slot->tts_tupleDescriptor)
1169  {
1171  slot->tts_tupleDescriptor = NULL;
1172  }
1173 
1174  /* If shouldFree, release memory occupied by the slot itself */
1175  if (shouldFree)
1176  {
1177  if (!TTS_FIXED(slot))
1178  {
1179  if (slot->tts_values)
1180  pfree(slot->tts_values);
1181  if (slot->tts_isnull)
1182  pfree(slot->tts_isnull);
1183  }
1184  pfree(slot);
1185  }
1186  }
1187 
1188  /* If shouldFree, release the list structure */
1189  if (shouldFree)
1190  list_free(tupleTable);
1191 }
#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:1373
#define ReleaseTupleDesc(tupdesc)
Definition: tupdesc.h:122

◆ ExecSetSlotDescriptor()

void ExecSetSlotDescriptor ( TupleTableSlot slot,
TupleDesc  tupdesc 
)

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

1256 {
1257  Assert(!TTS_FIXED(slot));
1258 
1259  /* For safety, make sure slot is empty before changing it */
1260  ExecClearTuple(slot);
1261 
1262  /*
1263  * Release any old descriptor. Also release old Datum/isnull arrays if
1264  * present (we don't bother to check if they could be re-used).
1265  */
1266  if (slot->tts_tupleDescriptor)
1268 
1269  if (slot->tts_values)
1270  pfree(slot->tts_values);
1271  if (slot->tts_isnull)
1272  pfree(slot->tts_isnull);
1273 
1274  /*
1275  * Install the new descriptor; if it's refcounted, bump its refcount.
1276  */
1277  slot->tts_tupleDescriptor = tupdesc;
1278  PinTupleDesc(tupdesc);
1279 
1280  /*
1281  * Allocate Datum/isnull arrays of the appropriate size. These must have
1282  * the same lifetime as the slot, so allocate in the slot's own context.
1283  */
1284  slot->tts_values = (Datum *)
1285  MemoryContextAlloc(slot->tts_mcxt, tupdesc->natts * sizeof(Datum));
1286  slot->tts_isnull = (bool *)
1287  MemoryContextAlloc(slot->tts_mcxt, tupdesc->natts * sizeof(bool));
1288 }
#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 1541 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().

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

◆ ExecStoreBufferHeapTuple()

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

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

1360 {
1361  /*
1362  * sanity checks
1363  */
1364  Assert(tuple != NULL);
1365  Assert(slot != NULL);
1366  Assert(slot->tts_tupleDescriptor != NULL);
1367  Assert(BufferIsValid(buffer));
1368 
1369  if (unlikely(!TTS_IS_BUFFERTUPLE(slot)))
1370  elog(ERROR, "trying to store an on-disk heap tuple into wrong type of slot");
1371  tts_buffer_heap_store_tuple(slot, tuple, buffer, false);
1372 
1373  slot->tts_tableOid = tuple->t_tableOid;
1374 
1375  return slot;
1376 }
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:824
#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 1317 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().

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

◆ ExecStoreHeapTupleDatum()

void ExecStoreHeapTupleDatum ( Datum  data,
TupleTableSlot slot 
)

Definition at line 1571 of file execTuples.c.

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

Referenced by EvalPlanQualFetchRowMark().

1572 {
1573  HeapTupleData tuple = {0};
1574  HeapTupleHeader td;
1575 
1576  td = DatumGetHeapTupleHeader(data);
1577 
1579  tuple.t_self = td->t_ctid;
1580  tuple.t_data = td;
1581 
1582  ExecClearTuple(slot);
1583 
1584  heap_deform_tuple(&tuple, slot->tts_tupleDescriptor,
1585  slot->tts_values, slot->tts_isnull);
1586  ExecStoreVirtualTuple(slot);
1587 }
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:1517
#define HeapTupleHeaderGetDatumLength(tup)
Definition: htup_details.h:452

◆ ExecStoreMinimalTuple()

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

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

1414 {
1415  /*
1416  * sanity checks
1417  */
1418  Assert(mtup != NULL);
1419  Assert(slot != NULL);
1420  Assert(slot->tts_tupleDescriptor != NULL);
1421 
1422  if (unlikely(!TTS_IS_MINIMALTUPLE(slot)))
1423  elog(ERROR, "trying to store a minimal tuple into wrong type of slot");
1424  tts_minimal_store_tuple(slot, mtup, shouldFree);
1425 
1426  return slot;
1427 }
#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:598
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 1383 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().

1386 {
1387  /*
1388  * sanity checks
1389  */
1390  Assert(tuple != NULL);
1391  Assert(slot != NULL);
1392  Assert(slot->tts_tupleDescriptor != NULL);
1393  Assert(BufferIsValid(buffer));
1394 
1395  if (unlikely(!TTS_IS_BUFFERTUPLE(slot)))
1396  elog(ERROR, "trying to store an on-disk heap tuple into wrong type of slot");
1397  tts_buffer_heap_store_tuple(slot, tuple, buffer, true);
1398 
1399  slot->tts_tableOid = tuple->t_tableOid;
1400 
1401  return slot;
1402 }
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:824
#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 1517 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().

1518 {
1519  /*
1520  * sanity checks
1521  */
1522  Assert(slot != NULL);
1523  Assert(slot->tts_tupleDescriptor != NULL);
1524  Assert(TTS_EMPTY(slot));
1525 
1526  slot->tts_flags &= ~TTS_FLAG_EMPTY;
1527  slot->tts_nvalid = slot->tts_tupleDescriptor->natts;
1528 
1529  return slot;
1530 }
#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 1963 of file execTuples.c.

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

Referenced by ExecInitExprRec(), and ExecInitValuesScan().

1964 {
1965  TupleDesc typeInfo;
1966  ListCell *lc;
1967  int cur_resno = 1;
1968 
1969  typeInfo = CreateTemplateTupleDesc(list_length(exprList));
1970 
1971  foreach(lc, exprList)
1972  {
1973  Node *e = lfirst(lc);
1974 
1975  TupleDescInitEntry(typeInfo,
1976  cur_resno,
1977  NULL,
1978  exprType(e),
1979  exprTypmod(e),
1980  0);
1981  TupleDescInitEntryCollation(typeInfo,
1982  cur_resno,
1983  exprCollation(e));
1984  cur_resno++;
1985  }
1986 
1987  return typeInfo;
1988 }
TupleDesc CreateTemplateTupleDesc(int natts)
Definition: tupdesc.c:44
int32 exprTypmod(const Node *expr)
Definition: nodeFuncs.c:276
Definition: nodes.h:525
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 1904 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().

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

◆ ExecTypeFromTLInternal()

static TupleDesc ExecTypeFromTLInternal ( List targetList,
bool  skipjunk 
)
static

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

1923 {
1924  TupleDesc typeInfo;
1925  ListCell *l;
1926  int len;
1927  int cur_resno = 1;
1928 
1929  if (skipjunk)
1930  len = ExecCleanTargetListLength(targetList);
1931  else
1932  len = ExecTargetListLength(targetList);
1933  typeInfo = CreateTemplateTupleDesc(len);
1934 
1935  foreach(l, targetList)
1936  {
1937  TargetEntry *tle = lfirst(l);
1938 
1939  if (skipjunk && tle->resjunk)
1940  continue;
1941  TupleDescInitEntry(typeInfo,
1942  cur_resno,
1943  tle->resname,
1944  exprType((Node *) tle->expr),
1945  exprTypmod((Node *) tle->expr),
1946  0);
1947  TupleDescInitEntryCollation(typeInfo,
1948  cur_resno,
1949  exprCollation((Node *) tle->expr));
1950  cur_resno++;
1951  }
1952 
1953  return typeInfo;
1954 }
int ExecTargetListLength(List *targetlist)
Definition: execUtils.c:1075
TupleDesc CreateTemplateTupleDesc(int natts)
Definition: tupdesc.c:44
int32 exprTypmod(const Node *expr)
Definition: nodeFuncs.c:276
Definition: nodes.h:525
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:1085
#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 2002 of file execTuples.c.

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

Referenced by ExecEvalWholeRowVar(), and ExecInitExprRec().

2003 {
2004  bool modified = false;
2005  int colno = 0;
2006  ListCell *lc;
2007 
2008  foreach(lc, namesList)
2009  {
2010  char *cname = strVal(lfirst(lc));
2011  Form_pg_attribute attr;
2012 
2013  /* Guard against too-long names list */
2014  if (colno >= typeInfo->natts)
2015  break;
2016  attr = TupleDescAttr(typeInfo, colno);
2017  colno++;
2018 
2019  /* Ignore empty aliases (these must be for dropped columns) */
2020  if (cname[0] == '\0')
2021  continue;
2022 
2023  /* Change tupdesc only if alias is actually different */
2024  if (strcmp(cname, NameStr(attr->attname)) != 0)
2025  {
2026  namestrcpy(&(attr->attname), cname);
2027  modified = true;
2028  }
2029  }
2030 
2031  /* If we modified the tupdesc, it's now a new record type */
2032  if (modified)
2033  {
2034  typeInfo->tdtypeid = RECORDOID;
2035  typeInfo->tdtypmod = -1;
2036  }
2037 }
#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 2201 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().

2202 {
2203  Datum result;
2204  TupleDesc tupDesc;
2205 
2206  /* No work if there are no external TOAST pointers in the tuple */
2207  if (!HeapTupleHeaderHasExternal(tuple))
2208  return PointerGetDatum(tuple);
2209 
2210  /* Use the type data saved by heap_form_tuple to look up the rowtype */
2212  HeapTupleHeaderGetTypMod(tuple));
2213 
2214  /* And do the flattening */
2215  result = toast_flatten_tuple_to_datum(tuple,
2217  tupDesc);
2218 
2219  ReleaseTupleDesc(tupDesc);
2220 
2221  return result;
2222 }
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
uintptr_t Datum
Definition: postgres.h:367
#define HeapTupleHeaderGetTypeId(tup)
Definition: htup_details.h:458
#define HeapTupleHeaderHasExternal(tup)
Definition: htup_details.h:539
Datum toast_flatten_tuple_to_datum(HeapTupleHeader tup, uint32 tup_len, TupleDesc tupleDesc)
Definition: heaptoast.c:442
#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 1077 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().

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

892 {
893  TupleDesc tupleDesc = slot->tts_tupleDescriptor;
894  Datum *values = slot->tts_values;
895  bool *isnull = slot->tts_isnull;
896  HeapTupleHeader tup = tuple->t_data;
897  bool hasnulls = HeapTupleHasNulls(tuple);
898  int attnum;
899  char *tp; /* ptr to tuple data */
900  uint32 off; /* offset in tuple data */
901  bits8 *bp = tup->t_bits; /* ptr to null bitmap in tuple */
902  bool slow; /* can we use/set attcacheoff? */
903 
904  /* We can only fetch as many attributes as the tuple has. */
905  natts = Min(HeapTupleHeaderGetNatts(tuple->t_data), natts);
906 
907  /*
908  * Check whether the first call for this tuple, and initialize or restore
909  * loop state.
910  */
911  attnum = slot->tts_nvalid;
912  if (attnum == 0)
913  {
914  /* Start from the first attribute */
915  off = 0;
916  slow = false;
917  }
918  else
919  {
920  /* Restore state from previous execution */
921  off = *offp;
922  slow = TTS_SLOW(slot);
923  }
924 
925  tp = (char *) tup + tup->t_hoff;
926 
927  for (; attnum < natts; attnum++)
928  {
929  Form_pg_attribute thisatt = TupleDescAttr(tupleDesc, attnum);
930 
931  if (hasnulls && att_isnull(attnum, bp))
932  {
933  values[attnum] = (Datum) 0;
934  isnull[attnum] = true;
935  slow = true; /* can't use attcacheoff anymore */
936  continue;
937  }
938 
939  isnull[attnum] = false;
940 
941  if (!slow && thisatt->attcacheoff >= 0)
942  off = thisatt->attcacheoff;
943  else if (thisatt->attlen == -1)
944  {
945  /*
946  * We can only cache the offset for a varlena attribute if the
947  * offset is already suitably aligned, so that there would be no
948  * pad bytes in any case: then the offset will be valid for either
949  * an aligned or unaligned value.
950  */
951  if (!slow &&
952  off == att_align_nominal(off, thisatt->attalign))
953  thisatt->attcacheoff = off;
954  else
955  {
956  off = att_align_pointer(off, thisatt->attalign, -1,
957  tp + off);
958  slow = true;
959  }
960  }
961  else
962  {
963  /* not varlena, so safe to use att_align_nominal */
964  off = att_align_nominal(off, thisatt->attalign);
965 
966  if (!slow)
967  thisatt->attcacheoff = off;
968  }
969 
970  values[attnum] = fetchatt(thisatt, tp + off);
971 
972  off = att_addlength_pointer(off, thisatt->attlen, tp + off);
973 
974  if (thisatt->attlen <= 0)
975  slow = true; /* can't use attcacheoff anymore */
976  }
977 
978  /*
979  * Save state for next execution
980  */
981  slot->tts_nvalid = attnum;
982  *offp = off;
983  if (slow)
984  slot->tts_flags |= TTS_FLAG_SLOW;
985  else
986  slot->tts_flags &= ~TTS_FLAG_SLOW;
987 }
#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:904
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 1833 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().

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

1869 {
1870  /* Check for caller errors */
1871  Assert(slot->tts_nvalid < attnum); /* checked in slot_getsomeattrs */
1872  Assert(attnum > 0);
1873 
1874  if (unlikely(attnum > slot->tts_tupleDescriptor->natts))
1875  elog(ERROR, "invalid attribute number %d", attnum);
1876 
1877  /* Fetch as many attributes as possible from the underlying tuple. */
1878  slot->tts_ops->getsomeattrs(slot, attnum);
1879 
1880  /*
1881  * If the underlying tuple doesn't have enough attributes, tuple
1882  * descriptor must have the missing attributes.
1883  */
1884  if (unlikely(slot->tts_nvalid < attnum))
1885  {
1886  slot_getmissingattrs(slot, slot->tts_nvalid, attnum);
1887  slot->tts_nvalid = attnum;
1888  }
1889 }
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:1833
#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 639 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().

640 {
642 
643  /*
644  * Free the memory for heap tuple if allowed. A tuple coming from buffer
645  * can never be freed. But we may have materialized a tuple from buffer.
646  * Such a tuple can be freed.
647  */
648  if (TTS_SHOULDFREE(slot))
649  {
650  /* We should have unpinned the buffer while materializing the tuple. */
651  Assert(!BufferIsValid(bslot->buffer));
652 
653  heap_freetuple(bslot->base.tuple);
654  slot->tts_flags &= ~TTS_FLAG_SHOULDFREE;
655 
656  Assert(!BufferIsValid(bslot->buffer));
657  }
658 
659  if (BufferIsValid(bslot->buffer))
660  ReleaseBuffer(bslot->buffer);
661 
662  slot->tts_nvalid = 0;
663  slot->tts_flags |= TTS_FLAG_EMPTY;
665  bslot->base.tuple = NULL;
666  bslot->base.off = 0;
667  bslot->buffer = InvalidBuffer;
668 }
#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 798 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().

799 {
801 
802  Assert(!TTS_EMPTY(slot));
803 
804  if (!bslot->base.tuple)
806 
807  return heap_copytuple(bslot->base.tuple);
808 }
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:690
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 811 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().

812 {
814 
815  Assert(!TTS_EMPTY(slot));
816 
817  if (!bslot->base.tuple)
819 
821 }
#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:690
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 743 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().

744 {
745  BufferHeapTupleTableSlot *bsrcslot = (BufferHeapTupleTableSlot *) srcslot;
746  BufferHeapTupleTableSlot *bdstslot = (BufferHeapTupleTableSlot *) dstslot;
747 
748  /*
749  * If the source slot is of a different kind, or is a buffer slot that has
750  * been materialized / is virtual, make a new copy of the tuple. Otherwise
751  * make a new reference to the in-buffer tuple.
752  */
753  if (dstslot->tts_ops != srcslot->tts_ops ||
754  TTS_SHOULDFREE(srcslot) ||
755  !bsrcslot->base.tuple)
756  {
757  MemoryContext oldContext;
758 
759  ExecClearTuple(dstslot);
760  dstslot->tts_flags |= TTS_FLAG_SHOULDFREE;
761  dstslot->tts_flags &= ~TTS_FLAG_EMPTY;
762  oldContext = MemoryContextSwitchTo(dstslot->tts_mcxt);
763  bdstslot->base.tuple = ExecCopySlotHeapTuple(srcslot);
764  MemoryContextSwitchTo(oldContext);
765  }
766  else
767  {
768  Assert(BufferIsValid(bsrcslot->buffer));
769 
770  tts_buffer_heap_store_tuple(dstslot, bsrcslot->base.tuple,
771  bsrcslot->buffer, false);
772 
773  /*
774  * The HeapTupleData portion of the source tuple might be shorter
775  * lived than the destination slot. Therefore copy the HeapTuple into
776  * our slot's tupdata, which is guaranteed to live long enough (but
777  * will still point into the buffer).
778  */
779  memcpy(&bdstslot->base.tupdata, bdstslot->base.tuple, sizeof(HeapTupleData));
780  bdstslot->base.tuple = &bdstslot->base.tupdata;
781  }
782 }
static void tts_buffer_heap_store_tuple(TupleTableSlot *slot, HeapTuple tuple, Buffer buffer, bool transfer_pin)
Definition: execTuples.c:824
#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 785 of file execTuples.c.

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

Referenced by slot_deform_heap_tuple().

786 {
788 
789  Assert(!TTS_EMPTY(slot));
790 
791  if (!bslot->base.tuple)
793 
794  return bslot->base.tuple;
795 }
#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:690
HeapTupleTableSlot base
Definition: tuptable.h:259

◆ tts_buffer_heap_getsomeattrs()

static void tts_buffer_heap_getsomeattrs ( TupleTableSlot slot,
int  natts 
)
static

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

672 {
674 
675  Assert(!TTS_EMPTY(slot));
676 
677  slot_deform_heap_tuple(slot, bslot->base.tuple, &bslot->base.off, natts);
678 }
#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:890
#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 681 of file execTuples.c.

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

Referenced by slot_deform_heap_tuple().

682 {
684 
685  return heap_getsysattr(bslot->base.tuple, attnum,
686  slot->tts_tupleDescriptor, isnull);
687 }
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 629 of file execTuples.c.

Referenced by slot_deform_heap_tuple().

630 {
631 }

◆ tts_buffer_heap_materialize()

static void tts_buffer_heap_materialize ( TupleTableSlot slot)
static

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

691 {
693  MemoryContext oldContext;
694 
695  Assert(!TTS_EMPTY(slot));
696 
697  /* If already materialized nothing to do. */
698  if (TTS_SHOULDFREE(slot))
699  return;
700 
702 
703  oldContext = MemoryContextSwitchTo(slot->tts_mcxt);
704 
705  if (!bslot->base.tuple)
706  {
707  /*
708  * Normally BufferHeapTupleTableSlot should have a tuple + buffer
709  * associated with it, unless it's materialized (which would've
710  * returned above). But when it's useful to allow storing virtual
711  * tuples in a buffer slot, which then also needs to be
712  * materializable.
713  */
715  slot->tts_values,
716  slot->tts_isnull);
717 
718  }
719  else
720  {
721  bslot->base.tuple = heap_copytuple(bslot->base.tuple);
722 
723  /*
724  * A heap tuple stored in a BufferHeapTupleTableSlot should have a
725  * buffer associated with it, unless it's materialized or virtual.
726  */
727  Assert(BufferIsValid(bslot->buffer));
728  if (likely(BufferIsValid(bslot->buffer)))
729  ReleaseBuffer(bslot->buffer);
730  bslot->buffer = InvalidBuffer;
731  }
732  MemoryContextSwitchTo(oldContext);
733 
734  /*
735  * Have to deform from scratch, otherwise tts_values[] entries could point
736  * into the non-materialized tuple (which might be gone when accessed).
737  */
738  bslot->base.off = 0;
739  slot->tts_nvalid = 0;
740 }
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 634 of file execTuples.c.

Referenced by slot_deform_heap_tuple().

635 {
636 }

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

826 {
828 
829  if (TTS_SHOULDFREE(slot))
830  {
831  /* materialized slot shouldn't have a buffer to release */
832  Assert(!BufferIsValid(bslot->buffer));
833 
834  heap_freetuple(bslot->base.tuple);
835  slot->tts_flags &= ~TTS_FLAG_SHOULDFREE;
836  }
837 
838  slot->tts_flags &= ~TTS_FLAG_EMPTY;
839  slot->tts_nvalid = 0;
840  bslot->base.tuple = tuple;
841  bslot->base.off = 0;
842  slot->tts_tid = tuple->t_self;
843 
844  /*
845  * If tuple is on a disk page, keep the page pinned as long as we hold a
846  * pointer into it. We assume the caller already has such a pin. If
847  * transfer_pin is true, we'll transfer that pin to this slot, if not
848  * we'll pin it again ourselves.
849  *
850  * This is coded to optimize the case where the slot previously held a
851  * tuple on the same disk page: in that case releasing and re-acquiring
852  * the pin is a waste of cycles. This is a common situation during
853  * seqscans, so it's worth troubling over.
854  */
855  if (bslot->buffer != buffer)
856  {
857  if (BufferIsValid(bslot->buffer))
858  ReleaseBuffer(bslot->buffer);
859 
860  bslot->buffer = buffer;
861 
862  if (!transfer_pin && BufferIsValid(buffer))
863  IncrBufferRefCount(buffer);
864  }
865  else if (transfer_pin && BufferIsValid(buffer))
866  {
867  /*
868  * In transfer_pin mode the caller won't know about the same-page
869  * optimization, so we gotta release its pin.
870  */
871  ReleaseBuffer(buffer);
872  }
873 }
#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 305 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().

306 {
307  HeapTupleTableSlot *hslot = (HeapTupleTableSlot *) slot;
308 
309  /* Free the memory for the heap tuple if it's allowed. */
310  if (TTS_SHOULDFREE(slot))
311  {
312  heap_freetuple(hslot->tuple);
313  slot->tts_flags &= ~TTS_FLAG_SHOULDFREE;
314  }
315 
316  slot->tts_nvalid = 0;
317  slot->tts_flags |= TTS_FLAG_EMPTY;
319  hslot->off = 0;
320  hslot->tuple = NULL;
321 }
#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 408 of file execTuples.c.

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

Referenced by slot_deform_heap_tuple().

409 {
410  HeapTupleTableSlot *hslot = (HeapTupleTableSlot *) slot;
411 
412  Assert(!TTS_EMPTY(slot));
413  if (!hslot->tuple)
414  tts_heap_materialize(slot);
415 
416  return heap_copytuple(hslot->tuple);
417 }
HeapTuple heap_copytuple(HeapTuple tuple)
Definition: heaptuple.c:680
static void tts_heap_materialize(TupleTableSlot *slot)
Definition: execTuples.c:343
#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 420 of file execTuples.c.

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

Referenced by slot_deform_heap_tuple().

421 {
422  HeapTupleTableSlot *hslot = (HeapTupleTableSlot *) slot;
423 
424  if (!hslot->tuple)
425  tts_heap_materialize(slot);
426 
427  return minimal_tuple_from_heap_tuple(hslot->tuple);
428 }
static void tts_heap_materialize(TupleTableSlot *slot)
Definition: execTuples.c:343
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 383 of file execTuples.c.

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

Referenced by slot_deform_heap_tuple().

384 {
385  HeapTuple tuple;
386  MemoryContext oldcontext;
387 
388  oldcontext = MemoryContextSwitchTo(dstslot->tts_mcxt);
389  tuple = ExecCopySlotHeapTuple(srcslot);
390  MemoryContextSwitchTo(oldcontext);
391 
392  ExecStoreHeapTuple(tuple, dstslot, true);
393 }
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:1317

◆ tts_heap_get_heap_tuple()

static HeapTuple tts_heap_get_heap_tuple ( TupleTableSlot slot)
static

Definition at line 396 of file execTuples.c.

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

Referenced by slot_deform_heap_tuple().

397 {
398  HeapTupleTableSlot *hslot = (HeapTupleTableSlot *) slot;
399 
400  Assert(!TTS_EMPTY(slot));
401  if (!hslot->tuple)
402  tts_heap_materialize(slot);
403 
404  return hslot->tuple;
405 }
static void tts_heap_materialize(TupleTableSlot *slot)
Definition: execTuples.c:343
#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 324 of file execTuples.c.

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

Referenced by slot_deform_heap_tuple().

325 {
326  HeapTupleTableSlot *hslot = (HeapTupleTableSlot *) slot;
327 
328  Assert(!TTS_EMPTY(slot));
329 
330  slot_deform_heap_tuple(slot, hslot->tuple, &hslot->off, natts);
331 }
#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:890
#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 334 of file execTuples.c.

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

Referenced by slot_deform_heap_tuple().

335 {
336  HeapTupleTableSlot *hslot = (HeapTupleTableSlot *) slot;
337 
338  return heap_getsysattr(hslot->tuple, attnum,
339  slot->tts_tupleDescriptor, isnull);
340 }
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 295 of file execTuples.c.

Referenced by slot_deform_heap_tuple().

296 {
297 }

◆ tts_heap_materialize()

static void tts_heap_materialize ( TupleTableSlot slot)
static

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

344 {
345  HeapTupleTableSlot *hslot = (HeapTupleTableSlot *) slot;
346  MemoryContext oldContext;
347 
348  Assert(!TTS_EMPTY(slot));
349 
350  /* This slot has it's tuple already materialized. Nothing to do. */
351  if (TTS_SHOULDFREE(slot))
352  return;
353 
355 
356  oldContext = MemoryContextSwitchTo(slot->tts_mcxt);
357 
358  if (!hslot->tuple)
360  slot->tts_values,
361  slot->tts_isnull);
362  else
363  {
364  /*
365  * The tuple contained in this slot is not allocated in the memory
366  * context of the given slot (else it would have TTS_SHOULDFREE set).
367  * Copy the tuple into the given slot's memory context.
368  */
369  hslot->tuple = heap_copytuple(hslot->tuple);
370  }
371 
372  /*
373  * Have to deform from scratch, otherwise tts_values[] entries could point
374  * into the non-materialized tuple (which might be gone when accessed).
375  */
376  slot->tts_nvalid = 0;
377  hslot->off = 0;
378 
379  MemoryContextSwitchTo(oldContext);
380 }
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 300 of file execTuples.c.

Referenced by slot_deform_heap_tuple().

301 {
302 }

◆ tts_heap_store_tuple()

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

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

432 {
433  HeapTupleTableSlot *hslot = (HeapTupleTableSlot *) slot;
434 
435  tts_heap_clear(slot);
436 
437  slot->tts_nvalid = 0;
438  hslot->tuple = tuple;
439  hslot->off = 0;
440  slot->tts_flags &= ~TTS_FLAG_EMPTY;
441  slot->tts_tid = tuple->t_self;
442 
443  if (shouldFree)
445 }
#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:305
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 470 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().

471 {
473 
474  if (TTS_SHOULDFREE(slot))
475  {
477  slot->tts_flags &= ~TTS_FLAG_SHOULDFREE;
478  }
479 
480  slot->tts_nvalid = 0;
481  slot->tts_flags |= TTS_FLAG_EMPTY;
483  mslot->off = 0;
484  mslot->mintuple = NULL;
485 }
#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 576 of file execTuples.c.

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

Referenced by slot_deform_heap_tuple().

577 {
579 
580  if (!mslot->mintuple)
582 
584 }
static void tts_minimal_materialize(TupleTableSlot *slot)
Definition: execTuples.c:506
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 587 of file execTuples.c.

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

Referenced by slot_deform_heap_tuple().

588 {
590 
591  if (!mslot->mintuple)
593 
594  return heap_copy_minimal_tuple(mslot->mintuple);
595 }
static void tts_minimal_materialize(TupleTableSlot *slot)
Definition: execTuples.c:506
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 552 of file execTuples.c.

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

Referenced by slot_deform_heap_tuple().

553 {
554  MemoryContext oldcontext;
555  MinimalTuple mintuple;
556 
557  oldcontext = MemoryContextSwitchTo(dstslot->tts_mcxt);
558  mintuple = ExecCopySlotMinimalTuple(srcslot);
559  MemoryContextSwitchTo(oldcontext);
560 
561  ExecStoreMinimalTuple(mintuple, dstslot, true);
562 }
TupleTableSlot * ExecStoreMinimalTuple(MinimalTuple mtup, TupleTableSlot *slot, bool shouldFree)
Definition: execTuples.c:1411
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 565 of file execTuples.c.

References MinimalTupleTableSlot::mintuple, and tts_minimal_materialize().

Referenced by slot_deform_heap_tuple().

566 {
568 
569  if (!mslot->mintuple)
571 
572  return mslot->mintuple;
573 }
static void tts_minimal_materialize(TupleTableSlot *slot)
Definition: execTuples.c:506
MinimalTuple mintuple
Definition: tuptable.h:284

◆ tts_minimal_getsomeattrs()

static void tts_minimal_getsomeattrs ( TupleTableSlot slot,
int  natts 
)
static

Definition at line 488 of file execTuples.c.

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

Referenced by slot_deform_heap_tuple().

489 {
491 
492  Assert(!TTS_EMPTY(slot));
493 
494  slot_deform_heap_tuple(slot, mslot->tuple, &mslot->off, natts);
495 }
#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:890
#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 498 of file execTuples.c.

References elog, and ERROR.

Referenced by slot_deform_heap_tuple().

499 {
500  elog(ERROR, "minimal tuple table slot does not have system attributes");
501 
502  return 0; /* silence compiler warnings */
503 }
#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 453 of file execTuples.c.

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

Referenced by slot_deform_heap_tuple().

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

◆ tts_minimal_materialize()

static void tts_minimal_materialize ( TupleTableSlot slot)
static

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

507 {
509  MemoryContext oldContext;
510 
511  Assert(!TTS_EMPTY(slot));
512 
513  /* This slot has it's tuple already materialized. Nothing to do. */
514  if (TTS_SHOULDFREE(slot))
515  return;
516 
518  oldContext = MemoryContextSwitchTo(slot->tts_mcxt);
519 
520  if (!mslot->mintuple)
521  {
523  slot->tts_values,
524  slot->tts_isnull);
525  }
526  else
527  {
528  /*
529  * The minimal tuple contained in this slot is not allocated in the
530  * memory context of the given slot (else it would have TTS_SHOULDFREE
531  * set). Copy the minimal tuple into the given slot's memory context.
532  */
533  mslot->mintuple = heap_copy_minimal_tuple(mslot->mintuple);
534  }
535 
536  Assert(mslot->tuple == &mslot->minhdr);
537 
538  mslot->minhdr.t_len = mslot->mintuple->t_len + MINIMAL_TUPLE_OFFSET;
539  mslot->minhdr.t_data = (HeapTupleHeader) ((char *) mslot->mintuple - MINIMAL_TUPLE_OFFSET);
540 
541  MemoryContextSwitchTo(oldContext);
542 
543  /*
544  * Have to deform from scratch, otherwise tts_values[] entries could point
545  * into the non-materialized tuple (which might be gone when accessed).
546  */
547  slot->tts_nvalid = 0;
548  mslot->off = 0;
549 }
#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 465 of file execTuples.c.

Referenced by slot_deform_heap_tuple().

466 {
467 }

◆ tts_minimal_store_tuple()

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

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

599 {
601 
602  tts_minimal_clear(slot);
603 
604  Assert(!TTS_SHOULDFREE(slot));
605  Assert(TTS_EMPTY(slot));
606 
607  slot->tts_flags &= ~TTS_FLAG_EMPTY;
608  slot->tts_nvalid = 0;
609  mslot->off = 0;
610 
611  mslot->mintuple = mtup;
612  Assert(mslot->tuple == &mslot->minhdr);
613  mslot->minhdr.t_len = mtup->t_len + MINIMAL_TUPLE_OFFSET;
614  mslot->minhdr.t_data = (HeapTupleHeader) ((char *) mtup - MINIMAL_TUPLE_OFFSET);
615  /* no need to set t_self or t_tableOid since we won't allow access */
616 
617  if (shouldFree)
619  else
620  Assert(!TTS_SHOULDFREE(slot));
621 }
#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:470
#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 108 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().

109 {
110  if (unlikely(TTS_SHOULDFREE(slot)))
111  {
113 
114  pfree(vslot->data);
115  vslot->data = NULL;
116 
117  slot->tts_flags &= ~TTS_FLAG_SHOULDFREE;
118  }
119 
120  slot->tts_nvalid = 0;
121  slot->tts_flags |= TTS_FLAG_EMPTY;
123 }
#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 269 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().

270 {
271  Assert(!TTS_EMPTY(slot));
272 
274  slot->tts_values,
275  slot->tts_isnull);
276 
277 }
#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 280 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().

281 {
282  Assert(!TTS_EMPTY(slot));
283 
285  slot->tts_values,
286  slot->tts_isnull);
287 }
#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 245 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().

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

◆ tts_virtual_getsomeattrs()

static void tts_virtual_getsomeattrs ( TupleTableSlot slot,
int  natts 
)
static

Definition at line 131 of file execTuples.c.

References elog, and ERROR.

Referenced by slot_deform_heap_tuple().

132 {
133  elog(ERROR, "getsomeattrs is not required to be called on a virtual tuple table slot");
134 }
#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 137 of file execTuples.c.

References elog, and ERROR.

Referenced by slot_deform_heap_tuple().

138 {
139  elog(ERROR, "virtual tuple table slot does not have system attributes");
140 
141  return 0; /* silence compiler warnings */
142 }
#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 98 of file execTuples.c.

Referenced by slot_deform_heap_tuple().

99 {
100 }

◆ tts_virtual_materialize()

static void tts_virtual_materialize ( TupleTableSlot slot)
static

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

153 {
155  TupleDesc desc = slot->tts_tupleDescriptor;
156  Size sz = 0;
157  char *data;
158 
159  /* already materialized */
160  if (TTS_SHOULDFREE(slot))
161  return;
162 
163  /* compute size of memory required */
164  for (int natt = 0; natt < desc->natts; natt++)
165  {
166  Form_pg_attribute att = TupleDescAttr(desc, natt);
167  Datum val;
168 
169  if (att->attbyval || slot->tts_isnull[natt])
170  continue;
171 
172  val = slot->tts_values[natt];
173 
174  if (att->attlen == -1 &&
176  {
177  /*
178  * We want to flatten the expanded value so that the materialized
179  * slot doesn't depend on it.
180  */
181  sz = att_align_nominal(sz, att->attalign);
182  sz += EOH_get_flat_size(DatumGetEOHP(val));
183  }
184  else
185  {
186  sz = att_align_nominal(sz, att->attalign);
187  sz = att_addlength_datum(sz, att->attlen, val);
188  }
189  }
190 
191  /* all data is byval */
192  if (sz == 0)
193  return;
194 
195  /* allocate memory */
196  vslot->data = data = MemoryContextAlloc(slot->tts_mcxt, sz);
198 
199  /* and copy all attributes into the pre-allocated space */
200  for (int natt = 0; natt < desc->natts; natt++)
201  {
202  Form_pg_attribute att = TupleDescAttr(desc, natt);
203  Datum val;
204 
205  if (att->attbyval || slot->tts_isnull[natt])
206  continue;
207 
208  val = slot->tts_values[natt];
209 
210  if (att->attlen == -1 &&
212  {
213  Size data_length;
214 
215  /*
216  * We want to flatten the expanded value so that the materialized
217  * slot doesn't depend on it.
218  */
220 
221  data = (char *) att_align_nominal(data,
222  att->attalign);
223  data_length = EOH_get_flat_size(eoh);
224  EOH_flatten_into(eoh, data, data_length);
225 
226  slot->tts_values[natt] = PointerGetDatum(data);
227  data += data_length;
228  }
229  else
230  {
231  Size data_length = 0;
232 
233  data = (char *) att_align_nominal(data, att->attalign);
234  data_length = att_addlength_datum(data_length, att->attlen, val);
235 
236  memcpy(data, DatumGetPointer(val), data_length);
237 
238  slot->tts_values[natt] = PointerGetDatum(data);
239  data += data_length;
240  }
241  }
242 }
#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:684

◆ tts_virtual_release()

static void tts_virtual_release ( TupleTableSlot slot)
static

Definition at line 103 of file execTuples.c.

Referenced by slot_deform_heap_tuple().

104 {
105 }

◆ TupleDescGetAttInMetadata()

AttInMetadata* TupleDescGetAttInMetadata ( TupleDesc  tupdesc)

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

2064 {
2065  int natts = tupdesc->natts;
2066  int i;
2067  Oid atttypeid;
2068  Oid attinfuncid;
2069  FmgrInfo *attinfuncinfo;
2070  Oid *attioparams;
2071  int32 *atttypmods;
2072  AttInMetadata *attinmeta;
2073 
2074  attinmeta = (AttInMetadata *) palloc(sizeof(AttInMetadata));
2075 
2076  /* "Bless" the tupledesc so that we can make rowtype datums with it */
2077  attinmeta->tupdesc = BlessTupleDesc(tupdesc);
2078 
2079  /*
2080  * Gather info needed later to call the "in" function for each attribute
2081  */
2082  attinfuncinfo = (FmgrInfo *) palloc0(natts * sizeof(FmgrInfo));
2083  attioparams = (Oid *) palloc0(natts * sizeof(Oid));
2084  atttypmods = (int32 *) palloc0(natts * sizeof(int32));
2085 
2086  for (i = 0; i < natts; i++)
2087  {
2088  Form_pg_attribute att = TupleDescAttr(tupdesc, i);
2089 
2090  /* Ignore dropped attributes */
2091  if (!att->attisdropped)
2092  {
2093  atttypeid = att->atttypid;
2094  getTypeInputInfo(atttypeid, &attinfuncid, &attioparams[i]);
2095  fmgr_info(attinfuncid, &attinfuncinfo[i]);
2096  atttypmods[i] = att->atttypmod;
2097  }
2098  }
2099  attinmeta->attinfuncs = attinfuncinfo;
2100  attinmeta->attioparams = attioparams;
2101  attinmeta->atttypmods = atttypmods;
2102 
2103  return attinmeta;
2104 }
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:2048
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:743
static HeapTuple tts_buffer_heap_get_heap_tuple(TupleTableSlot *slot)
Definition: execTuples.c:785
static MinimalTuple tts_buffer_heap_copy_minimal_tuple(TupleTableSlot *slot)
Definition: execTuples.c:811
static Datum tts_buffer_heap_getsysattr(TupleTableSlot *slot, int attnum, bool *isnull)
Definition: execTuples.c:681
static HeapTuple tts_buffer_heap_copy_heap_tuple(TupleTableSlot *slot)
Definition: execTuples.c:798
static void tts_buffer_heap_init(TupleTableSlot *slot)
Definition: execTuples.c:629
#define init()
struct BufferHeapTupleTableSlot BufferHeapTupleTableSlot
static void tts_buffer_heap_clear(TupleTableSlot *slot)
Definition: execTuples.c:639
static void tts_buffer_heap_getsomeattrs(TupleTableSlot *slot, int natts)
Definition: execTuples.c:671
static void tts_buffer_heap_materialize(TupleTableSlot *slot)
Definition: execTuples.c:690
static void tts_buffer_heap_release(TupleTableSlot *slot)
Definition: execTuples.c:634

Definition at line 87 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:343
static void tts_heap_clear(TupleTableSlot *slot)
Definition: execTuples.c:305
static Datum tts_heap_getsysattr(TupleTableSlot *slot, int attnum, bool *isnull)
Definition: execTuples.c:334
static HeapTuple tts_heap_get_heap_tuple(TupleTableSlot *slot)
Definition: execTuples.c:396
struct HeapTupleTableSlot HeapTupleTableSlot
static void tts_heap_copyslot(TupleTableSlot *dstslot, TupleTableSlot *srcslot)
Definition: execTuples.c:383
#define init()
static void tts_heap_release(TupleTableSlot *slot)
Definition: execTuples.c:300
static MinimalTuple tts_heap_copy_minimal_tuple(TupleTableSlot *slot)
Definition: execTuples.c:420
static void tts_heap_init(TupleTableSlot *slot)
Definition: execTuples.c:295
static void tts_heap_getsomeattrs(TupleTableSlot *slot, int natts)
Definition: execTuples.c:324
static HeapTuple tts_heap_copy_heap_tuple(TupleTableSlot *slot)
Definition: execTuples.c:408

Definition at line 85 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:506
static void tts_minimal_getsomeattrs(TupleTableSlot *slot, int natts)
Definition: execTuples.c:488
static void tts_minimal_init(TupleTableSlot *slot)
Definition: execTuples.c:453
static HeapTuple tts_minimal_copy_heap_tuple(TupleTableSlot *slot)
Definition: execTuples.c:576
static MinimalTuple tts_minimal_get_minimal_tuple(TupleTableSlot *slot)
Definition: execTuples.c:565
static MinimalTuple tts_minimal_copy_minimal_tuple(TupleTableSlot *slot)
Definition: execTuples.c:587
#define init()
static Datum tts_minimal_getsysattr(TupleTableSlot *slot, int attnum, bool *isnull)
Definition: execTuples.c:498
static void tts_minimal_release(TupleTableSlot *slot)
Definition: execTuples.c:465
struct MinimalTupleTableSlot MinimalTupleTableSlot
static void tts_minimal_clear(TupleTableSlot *slot)
Definition: execTuples.c:470
static void tts_minimal_copyslot(TupleTableSlot *dstslot, TupleTableSlot *srcslot)
Definition: execTuples.c:552

Definition at line 86 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:269
struct VirtualTupleTableSlot VirtualTupleTableSlot
static void tts_virtual_getsomeattrs(TupleTableSlot *slot, int natts)
Definition: execTuples.c:131
static void tts_virtual_init(TupleTableSlot *slot)
Definition: execTuples.c:98
static Datum tts_virtual_getsysattr(TupleTableSlot *slot, int attnum, bool *isnull)
Definition: execTuples.c:137
#define init()
static void tts_virtual_materialize(TupleTableSlot *slot)
Definition: execTuples.c:152
static MinimalTuple tts_virtual_copy_minimal_tuple(TupleTableSlot *slot)
Definition: execTuples.c:280
static void tts_virtual_clear(TupleTableSlot *slot)
Definition: execTuples.c:108
static void tts_virtual_copyslot(TupleTableSlot *dstslot, TupleTableSlot *srcslot)
Definition: execTuples.c:245
static void tts_virtual_release(TupleTableSlot *slot)
Definition: execTuples.c:103

Definition at line 84 of file execTuples.c.

Referenced by AfterTriggerSaveEvent(), apply_handle_delete(), apply_handle_insert(), apply_handle_update(), CheckOpSlotCompatibility(), CreateReplicationSlot(), 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().