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

Go to the source code of this file.

Functions

static TupleDesc ExecTypeFromTLInternal (List *targetList, bool hasoid, bool skipjunk)
 
TupleTableSlotMakeTupleTableSlot (TupleDesc tupleDesc)
 
TupleTableSlotExecAllocTableSlot (List **tupleTable, TupleDesc desc)
 
void ExecResetTupleTable (List *tupleTable, bool shouldFree)
 
TupleTableSlotMakeSingleTupleTableSlot (TupleDesc tupdesc)
 
void ExecDropSingleTupleTableSlot (TupleTableSlot *slot)
 
void ExecSetSlotDescriptor (TupleTableSlot *slot, TupleDesc tupdesc)
 
TupleTableSlotExecStoreTuple (HeapTuple tuple, TupleTableSlot *slot, Buffer buffer, bool shouldFree)
 
TupleTableSlotExecStoreMinimalTuple (MinimalTuple mtup, TupleTableSlot *slot, bool shouldFree)
 
TupleTableSlotExecClearTuple (TupleTableSlot *slot)
 
TupleTableSlotExecStoreVirtualTuple (TupleTableSlot *slot)
 
TupleTableSlotExecStoreAllNullTuple (TupleTableSlot *slot)
 
HeapTuple ExecCopySlotTuple (TupleTableSlot *slot)
 
MinimalTuple ExecCopySlotMinimalTuple (TupleTableSlot *slot)
 
HeapTuple ExecFetchSlotTuple (TupleTableSlot *slot)
 
MinimalTuple ExecFetchSlotMinimalTuple (TupleTableSlot *slot)
 
Datum ExecFetchSlotTupleDatum (TupleTableSlot *slot)
 
HeapTuple ExecMaterializeSlot (TupleTableSlot *slot)
 
TupleTableSlotExecCopySlot (TupleTableSlot *dstslot, TupleTableSlot *srcslot)
 
void ExecInitResultTupleSlotTL (EState *estate, PlanState *planstate)
 
void ExecInitScanTupleSlot (EState *estate, ScanState *scanstate, TupleDesc tupledesc)
 
TupleTableSlotExecInitExtraTupleSlot (EState *estate, TupleDesc tupledesc)
 
TupleTableSlotExecInitNullTupleSlot (EState *estate, TupleDesc tupType)
 
TupleDesc ExecTypeFromTL (List *targetList, bool hasoid)
 
TupleDesc ExecCleanTypeFromTL (List *targetList, bool hasoid)
 
TupleDesc ExecTypeFromExprList (List *exprList)
 
void ExecTypeSetColNames (TupleDesc typeInfo, List *namesList)
 
TupleDesc BlessTupleDesc (TupleDesc tupdesc)
 
TupleTableSlotTupleDescGetSlot (TupleDesc tupdesc)
 
AttInMetadataTupleDescGetAttInMetadata (TupleDesc tupdesc)
 
HeapTuple BuildTupleFromCStrings (AttInMetadata *attinmeta, char **values)
 
Datum HeapTupleHeaderGetDatum (HeapTupleHeader tuple)
 
TupOutputStatebegin_tup_output_tupdesc (DestReceiver *dest, TupleDesc tupdesc)
 
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)
 

Function Documentation

◆ begin_tup_output_tupdesc()

TupOutputState* begin_tup_output_tupdesc ( DestReceiver dest,
TupleDesc  tupdesc 
)

Definition at line 1291 of file execTuples.c.

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

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

1292 {
1293  TupOutputState *tstate;
1294 
1295  tstate = (TupOutputState *) palloc(sizeof(TupOutputState));
1296 
1297  tstate->slot = MakeSingleTupleTableSlot(tupdesc);
1298  tstate->dest = dest;
1299 
1300  tstate->dest->rStartup(tstate->dest, (int) CMD_SELECT, tupdesc);
1301 
1302  return tstate;
1303 }
TupleTableSlot * slot
Definition: executor.h:448
void(* rStartup)(DestReceiver *self, int operation, TupleDesc typeinfo)
Definition: dest.h:121
TupleTableSlot * MakeSingleTupleTableSlot(TupleDesc tupdesc)
Definition: execTuples.c:232
void * palloc(Size size)
Definition: mcxt.c:835
DestReceiver * dest
Definition: executor.h:449

◆ BlessTupleDesc()

TupleDesc BlessTupleDesc ( TupleDesc  tupdesc)

Definition at line 1088 of file execTuples.c.

References assign_record_type_typmod(), RECORDOID, tupleDesc::tdtypeid, and tupleDesc::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_prepared_xact(), pg_sequence_parameters(), pg_stat_file(), pg_stat_get_archiver(), 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(), ts_setup_firstcall(), tsvector_unnest(), TupleDescGetAttInMetadata(), and TupleDescGetSlot().

1089 {
1090  if (tupdesc->tdtypeid == RECORDOID &&
1091  tupdesc->tdtypmod < 0)
1092  assign_record_type_typmod(tupdesc);
1093 
1094  return tupdesc; /* just for notational convenience */
1095 }
Oid tdtypeid
Definition: tupdesc.h:80
int32 tdtypmod
Definition: tupdesc.h:81
void assign_record_type_typmod(TupleDesc tupDesc)
Definition: typcache.c:1761
#define RECORDOID
Definition: pg_type.h:680

◆ BuildTupleFromCStrings()

HeapTuple BuildTupleFromCStrings ( AttInMetadata attinmeta,
char **  values 
)

Definition at line 1174 of file execTuples.c.

References AttInMetadata::attinfuncs, AttInMetadata::attioparams, AttInMetadata::atttypmods, heap_form_tuple(), i, InputFunctionCall(), tupleDesc::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(), materializeQueryResult(), materializeResult(), pg_config(), pg_get_keywords(), pg_get_multixact_members(), pg_logdir_ls(), 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().

1175 {
1176  TupleDesc tupdesc = attinmeta->tupdesc;
1177  int natts = tupdesc->natts;
1178  Datum *dvalues;
1179  bool *nulls;
1180  int i;
1181  HeapTuple tuple;
1182 
1183  dvalues = (Datum *) palloc(natts * sizeof(Datum));
1184  nulls = (bool *) palloc(natts * sizeof(bool));
1185 
1186  /* Call the "in" function for each non-dropped attribute */
1187  for (i = 0; i < natts; i++)
1188  {
1189  if (!TupleDescAttr(tupdesc, i)->attisdropped)
1190  {
1191  /* Non-dropped attributes */
1192  dvalues[i] = InputFunctionCall(&attinmeta->attinfuncs[i],
1193  values[i],
1194  attinmeta->attioparams[i],
1195  attinmeta->atttypmods[i]);
1196  if (values[i] != NULL)
1197  nulls[i] = false;
1198  else
1199  nulls[i] = true;
1200  }
1201  else
1202  {
1203  /* Handle dropped attributes by setting to NULL */
1204  dvalues[i] = (Datum) 0;
1205  nulls[i] = true;
1206  }
1207  }
1208 
1209  /*
1210  * Form a tuple
1211  */
1212  tuple = heap_form_tuple(tupdesc, dvalues, nulls);
1213 
1214  /*
1215  * Release locally palloc'd space. XXX would probably be good to pfree
1216  * values of pass-by-reference datums, as well.
1217  */
1218  pfree(dvalues);
1219  pfree(nulls);
1220 
1221  return tuple;
1222 }
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:90
int32 * atttypmods
Definition: funcapi.h:48
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
Definition: heaptuple.c:695
Oid * attioparams
Definition: funcapi.h:45
int natts
Definition: tupdesc.h:79
void pfree(void *pointer)
Definition: mcxt.c:936
TupleDesc tupdesc
Definition: funcapi.h:39
uintptr_t Datum
Definition: postgres.h:365
Datum InputFunctionCall(FmgrInfo *flinfo, char *str, Oid typioparam, int32 typmod)
Definition: fmgr.c:1618
static Datum values[MAXATTR]
Definition: bootstrap.c:164
void * palloc(Size size)
Definition: mcxt.c:835
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 1337 of file execTuples.c.

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

Referenced by ExplainQuery().

1338 {
1339  Datum values[1];
1340  bool isnull[1] = {false};
1341 
1342  while (*txt)
1343  {
1344  const char *eol;
1345  int len;
1346 
1347  eol = strchr(txt, '\n');
1348  if (eol)
1349  {
1350  len = eol - txt;
1351  eol++;
1352  }
1353  else
1354  {
1355  len = strlen(txt);
1356  eol = txt + len;
1357  }
1358 
1359  values[0] = PointerGetDatum(cstring_to_text_with_len(txt, len));
1360  do_tup_output(tstate, values, isnull);
1361  pfree(DatumGetPointer(values[0]));
1362  txt = eol;
1363  }
1364 }
#define PointerGetDatum(X)
Definition: postgres.h:539
void do_tup_output(TupOutputState *tstate, Datum *values, bool *isnull)
Definition: execTuples.c:1309
void pfree(void *pointer)
Definition: mcxt.c:936
text * cstring_to_text_with_len(const char *s, int len)
Definition: varlena.c:161
uintptr_t Datum
Definition: postgres.h:365
#define DatumGetPointer(X)
Definition: postgres.h:532
static Datum values[MAXATTR]
Definition: bootstrap.c:164

◆ do_tup_output()

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

Definition at line 1309 of file execTuples.c.

References TupOutputState::dest, ExecClearTuple(), ExecStoreVirtualTuple(), tupleDesc::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().

1310 {
1311  TupleTableSlot *slot = tstate->slot;
1312  int natts = slot->tts_tupleDescriptor->natts;
1313 
1314  /* make sure the slot is clear */
1315  ExecClearTuple(slot);
1316 
1317  /* insert data */
1318  memcpy(slot->tts_values, values, natts * sizeof(Datum));
1319  memcpy(slot->tts_isnull, isnull, natts * sizeof(bool));
1320 
1321  /* mark slot as containing a virtual tuple */
1322  ExecStoreVirtualTuple(slot);
1323 
1324  /* send the tuple to the receiver */
1325  (void) tstate->dest->receiveSlot(slot, tstate->dest);
1326 
1327  /* clean up */
1328  ExecClearTuple(slot);
1329 }
bool(* receiveSlot)(TupleTableSlot *slot, DestReceiver *self)
Definition: dest.h:118
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: execTuples.c:475
Datum * tts_values
Definition: tuptable.h:125
TupleTableSlot * slot
Definition: executor.h:448
int natts
Definition: tupdesc.h:79
bool * tts_isnull
Definition: tuptable.h:126
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:121
uintptr_t Datum
Definition: postgres.h:365
static Datum values[MAXATTR]
Definition: bootstrap.c:164
DestReceiver * dest
Definition: executor.h:449
TupleTableSlot * ExecStoreVirtualTuple(TupleTableSlot *slot)
Definition: execTuples.c:524

◆ end_tup_output()

void end_tup_output ( TupOutputState tstate)

Definition at line 1367 of file execTuples.c.

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

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

1368 {
1369  tstate->dest->rShutdown(tstate->dest);
1370  /* note that destroying the dest is not ours to do */
1372  pfree(tstate);
1373 }
TupleTableSlot * slot
Definition: executor.h:448
void pfree(void *pointer)
Definition: mcxt.c:936
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
Definition: execTuples.c:247
void(* rShutdown)(DestReceiver *self)
Definition: dest.h:124
DestReceiver * dest
Definition: executor.h:449

◆ ExecAllocTableSlot()

TupleTableSlot* ExecAllocTableSlot ( List **  tupleTable,
TupleDesc  desc 
)

Definition at line 167 of file execTuples.c.

References lappend(), and MakeTupleTableSlot().

Referenced by ExecInitExtraTupleSlot(), ExecInitResultTupleSlotTL(), ExecInitScanTupleSlot(), and find_hash_columns().

168 {
169  TupleTableSlot *slot = MakeTupleTableSlot(desc);
170 
171  *tupleTable = lappend(*tupleTable, slot);
172 
173  return slot;
174 }
List * lappend(List *list, void *datum)
Definition: list.c:128
TupleTableSlot * MakeTupleTableSlot(TupleDesc tupleDesc)
Definition: execTuples.c:113

◆ ExecCleanTypeFromTL()

TupleDesc ExecCleanTypeFromTL ( List targetList,
bool  hasoid 
)

Definition at line 956 of file execTuples.c.

References ExecTypeFromTLInternal().

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

957 {
958  return ExecTypeFromTLInternal(targetList, hasoid, true);
959 }
static TupleDesc ExecTypeFromTLInternal(List *targetList, bool hasoid, bool skipjunk)
Definition: execTuples.c:962

◆ ExecClearTuple()

TupleTableSlot* ExecClearTuple ( TupleTableSlot slot)

Definition at line 475 of file execTuples.c.

References Assert, BufferIsValid, heap_free_minimal_tuple(), heap_freetuple(), InvalidBuffer, ReleaseBuffer(), TupleTableSlot::tts_buffer, TupleTableSlot::tts_isempty, TupleTableSlot::tts_mintuple, TupleTableSlot::tts_nvalid, TupleTableSlot::tts_shouldFree, TupleTableSlot::tts_shouldFreeMin, and TupleTableSlot::tts_tuple.

Referenced by agg_retrieve_hash_table(), apply_handle_update(), apply_returning_filter(), begin_partition(), BitmapHeapNext(), buildSubPlanHash(), CteScanNext(), do_tup_output(), eval_windowaggregates(), ExecAppend(), ExecDelete(), ExecDropSingleTupleTableSlot(), ExecEndAgg(), ExecEndBitmapHeapScan(), ExecEndCteScan(), ExecEndCustomScan(), ExecEndForeignScan(), ExecEndFunctionScan(), ExecEndGather(), ExecEndGatherMerge(), ExecEndGroup(), ExecEndHashJoin(), ExecEndIndexOnlyScan(), ExecEndIndexScan(), ExecEndMaterial(), ExecEndMergeJoin(), ExecEndModifyTable(), ExecEndNamedTuplestoreScan(), ExecEndNestLoop(), ExecEndProjectSet(), ExecEndRecursiveUnion(), ExecEndResult(), ExecEndSampleScan(), ExecEndSeqScan(), ExecEndSetOp(), ExecEndSort(), ExecEndSubqueryScan(), ExecEndTableFuncScan(), ExecEndTidScan(), ExecEndUnique(), ExecEndValuesScan(), ExecEndWindowAgg(), ExecEndWorkTableScan(), ExecEvalAggOrderedTransTuple(), ExecFilterJunk(), ExecFindPartition(), ExecHashJoinGetSavedTuple(), ExecHashSubPlan(), ExecMaterial(), ExecMergeAppend(), ExecParallelHashJoinOuterGetTuple(), ExecProject(), ExecProjectSRF(), ExecReScanAgg(), ExecReScanCteScan(), ExecReScanFunctionScan(), ExecReScanGroup(), ExecReScanMaterial(), ExecReScanMergeJoin(), ExecReScanNamedTuplestoreScan(), ExecReScanSetOp(), ExecReScanSort(), ExecReScanTableFuncScan(), ExecReScanUnique(), ExecReScanValuesScan(), ExecReScanWindowAgg(), ExecReScanWorkTableScan(), ExecResetTupleTable(), ExecScan(), ExecScanFetch(), ExecSetSlotDescriptor(), ExecStoreAllNullTuple(), ExecUnique(), ExecWindowAgg(), fetch_remote_table_info(), fetch_table_list(), fileIterateForeignScan(), FunctionNext(), gather_getnext(), gather_merge_clear_tuples(), gather_merge_init(), get_returning_data(), hypothetical_dense_rank_final(), hypothetical_rank_common(), IndexNext(), IndexNextWithReorder(), IndexOnlyNext(), lookup_hash_entry(), ordered_set_shutdown(), ordered_set_transition_multi(), per_MultiFuncCall(), postgresIterateDirectModify(), postgresIterateForeignScan(), process_ordered_aggregate_multi(), RunFromStore(), SampleNext(), SeqNext(), setop_retrieve_direct(), setop_retrieve_hash_table(), ShutdownSetExpr(), slot_modify_cstrings(), slot_store_cstrings(), StoreIndexTuple(), tfuncLoadRows(), TidNext(), tuplesort_gettupleslot(), tuplestore_gettupleslot(), update_frameheadpos(), update_frametailpos(), update_grouptailpos(), ValuesNext(), and WinRowsArePeers().

476 {
477  /*
478  * sanity checks
479  */
480  Assert(slot != NULL);
481 
482  /*
483  * Free the old physical tuple if necessary.
484  */
485  if (slot->tts_shouldFree)
486  heap_freetuple(slot->tts_tuple);
487  if (slot->tts_shouldFreeMin)
489 
490  slot->tts_tuple = NULL;
491  slot->tts_mintuple = NULL;
492  slot->tts_shouldFree = false;
493  slot->tts_shouldFreeMin = false;
494 
495  /*
496  * Drop the pin on the referenced buffer, if there is one.
497  */
498  if (BufferIsValid(slot->tts_buffer))
499  ReleaseBuffer(slot->tts_buffer);
500 
501  slot->tts_buffer = InvalidBuffer;
502 
503  /*
504  * Mark it empty.
505  */
506  slot->tts_isempty = true;
507  slot->tts_nvalid = 0;
508 
509  return slot;
510 }
bool tts_isempty
Definition: tuptable.h:116
#define InvalidBuffer
Definition: buf.h:25
bool tts_shouldFreeMin
Definition: tuptable.h:118
void ReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3309
void heap_freetuple(HeapTuple htup)
Definition: heaptuple.c:1373
void heap_free_minimal_tuple(MinimalTuple mtup)
Definition: heaptuple.c:1468
bool tts_shouldFree
Definition: tuptable.h:117
#define Assert(condition)
Definition: c.h:688
#define BufferIsValid(bufnum)
Definition: bufmgr.h:114
MinimalTuple tts_mintuple
Definition: tuptable.h:127
HeapTuple tts_tuple
Definition: tuptable.h:120
Buffer tts_buffer
Definition: tuptable.h:123

◆ ExecCopySlot()

TupleTableSlot* ExecCopySlot ( TupleTableSlot dstslot,
TupleTableSlot srcslot 
)

Definition at line 831 of file execTuples.c.

References ExecCopySlotTuple(), ExecStoreTuple(), InvalidBuffer, MemoryContextSwitchTo(), and TupleTableSlot::tts_mcxt.

Referenced by begin_partition(), CteScanNext(), ExecGroup(), ExecUnique(), ExecWindowAgg(), postgresRecheckForeignScan(), spool_tuples(), update_frameheadpos(), and update_frametailpos().

832 {
833  HeapTuple newTuple;
834  MemoryContext oldContext;
835 
836  /*
837  * There might be ways to optimize this when the source is virtual, but
838  * for now just always build a physical copy. Make sure it is in the
839  * right context.
840  */
841  oldContext = MemoryContextSwitchTo(dstslot->tts_mcxt);
842  newTuple = ExecCopySlotTuple(srcslot);
843  MemoryContextSwitchTo(oldContext);
844 
845  return ExecStoreTuple(newTuple, dstslot, InvalidBuffer, true);
846 }
TupleTableSlot * ExecStoreTuple(HeapTuple tuple, TupleTableSlot *slot, Buffer buffer, bool shouldFree)
Definition: execTuples.c:356
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
#define InvalidBuffer
Definition: buf.h:25
MemoryContext tts_mcxt
Definition: tuptable.h:122
HeapTuple ExecCopySlotTuple(TupleTableSlot *slot)
Definition: execTuples.c:581

◆ ExecCopySlotMinimalTuple()

MinimalTuple ExecCopySlotMinimalTuple ( TupleTableSlot slot)

Definition at line 613 of file execTuples.c.

References Assert, heap_copy_minimal_tuple(), heap_form_minimal_tuple(), minimal_tuple_from_heap_tuple(), TupleTableSlot::tts_isempty, TupleTableSlot::tts_isnull, TupleTableSlot::tts_mintuple, TupleTableSlot::tts_tuple, TupleTableSlot::tts_tupleDescriptor, and TupleTableSlot::tts_values.

Referenced by copytup_heap(), ExecFetchSlotMinimalTuple(), LookupTupleHashEntry(), and tuplestore_puttupleslot().

614 {
615  /*
616  * sanity checks
617  */
618  Assert(slot != NULL);
619  Assert(!slot->tts_isempty);
620 
621  /*
622  * If we have a physical tuple then just copy it. Prefer to copy
623  * tts_mintuple since that's a tad cheaper.
624  */
625  if (slot->tts_mintuple)
627  if (slot->tts_tuple)
629 
630  /*
631  * Otherwise we need to build a tuple from the Datum array.
632  */
634  slot->tts_values,
635  slot->tts_isnull);
636 }
bool tts_isempty
Definition: tuptable.h:116
Datum * tts_values
Definition: tuptable.h:125
MinimalTuple heap_copy_minimal_tuple(MinimalTuple mtup)
Definition: heaptuple.c:1480
bool * tts_isnull
Definition: tuptable.h:126
MinimalTuple heap_form_minimal_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
Definition: heaptuple.c:1391
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:121
#define Assert(condition)
Definition: c.h:688
MinimalTuple tts_mintuple
Definition: tuptable.h:127
MinimalTuple minimal_tuple_from_heap_tuple(HeapTuple htup)
Definition: heaptuple.c:1521
HeapTuple tts_tuple
Definition: tuptable.h:120

◆ ExecCopySlotTuple()

HeapTuple ExecCopySlotTuple ( TupleTableSlot slot)

Definition at line 581 of file execTuples.c.

References Assert, heap_copytuple(), heap_form_tuple(), heap_tuple_from_minimal_tuple(), TTS_HAS_PHYSICAL_TUPLE, TupleTableSlot::tts_isempty, TupleTableSlot::tts_isnull, TupleTableSlot::tts_mintuple, TupleTableSlot::tts_tuple, TupleTableSlot::tts_tupleDescriptor, and TupleTableSlot::tts_values.

Referenced by agg_retrieve_direct(), ExecCopySlot(), ExecMaterializeSlot(), ExecScanSubPlan(), ExecSetParamPlan(), setop_retrieve_direct(), and spi_printtup().

582 {
583  /*
584  * sanity checks
585  */
586  Assert(slot != NULL);
587  Assert(!slot->tts_isempty);
588 
589  /*
590  * If we have a physical tuple (either format) then just copy it.
591  */
592  if (TTS_HAS_PHYSICAL_TUPLE(slot))
593  return heap_copytuple(slot->tts_tuple);
594  if (slot->tts_mintuple)
596 
597  /*
598  * Otherwise we need to build a tuple from the Datum array.
599  */
601  slot->tts_values,
602  slot->tts_isnull);
603 }
HeapTuple heap_copytuple(HeapTuple tuple)
Definition: heaptuple.c:611
bool tts_isempty
Definition: tuptable.h:116
Datum * tts_values
Definition: tuptable.h:125
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
Definition: heaptuple.c:695
bool * tts_isnull
Definition: tuptable.h:126
HeapTuple heap_tuple_from_minimal_tuple(MinimalTuple mtup)
Definition: heaptuple.c:1499
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:121
#define Assert(condition)
Definition: c.h:688
MinimalTuple tts_mintuple
Definition: tuptable.h:127
HeapTuple tts_tuple
Definition: tuptable.h:120
#define TTS_HAS_PHYSICAL_TUPLE(slot)
Definition: tuptable.h:133

◆ ExecDropSingleTupleTableSlot()

void ExecDropSingleTupleTableSlot ( TupleTableSlot slot)

Definition at line 247 of file execTuples.c.

References Assert, ExecClearTuple(), IsA, pfree(), ReleaseTupleDesc, TupleTableSlot::tts_fixedTupleDescriptor, TupleTableSlot::tts_isnull, TupleTableSlot::tts_tupleDescriptor, and TupleTableSlot::tts_values.

Referenced by afterTriggerInvokeEvents(), ATRewriteTable(), CatalogIndexInsert(), check_default_allows_bound(), check_exclusion_or_unique_constraint(), compute_index_stats(), end_tup_output(), ExecCleanupTupleRouting(), fetch_remote_table_info(), fetch_table_list(), get_actual_variable_range(), hypothetical_dense_rank_final(), IndexBuildHeapRangeScan(), IndexCheckExclusion(), RunFromStore(), tuplesort_end(), unique_key_recheck(), validate_index_heapscan(), and validateCheckConstraint().

248 {
249  /* This should match ExecResetTupleTable's processing of one slot */
250  Assert(IsA(slot, TupleTableSlot));
251  ExecClearTuple(slot);
252  if (slot->tts_tupleDescriptor)
254  if (!slot->tts_fixedTupleDescriptor)
255  {
256  if (slot->tts_values)
257  pfree(slot->tts_values);
258  if (slot->tts_isnull)
259  pfree(slot->tts_isnull);
260  }
261  pfree(slot);
262 }
#define IsA(nodeptr, _type_)
Definition: nodes.h:564
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: execTuples.c:475
Datum * tts_values
Definition: tuptable.h:125
void pfree(void *pointer)
Definition: mcxt.c:936
bool * tts_isnull
Definition: tuptable.h:126
bool tts_fixedTupleDescriptor
Definition: tuptable.h:130
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:121
#define Assert(condition)
Definition: c.h:688
#define ReleaseTupleDesc(tupdesc)
Definition: tupdesc.h:121

◆ ExecFetchSlotMinimalTuple()

MinimalTuple ExecFetchSlotMinimalTuple ( TupleTableSlot slot)

Definition at line 688 of file execTuples.c.

References Assert, ExecCopySlotMinimalTuple(), MemoryContextSwitchTo(), TupleTableSlot::tts_isempty, TupleTableSlot::tts_mcxt, TupleTableSlot::tts_mintuple, and TupleTableSlot::tts_shouldFreeMin.

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

689 {
690  MemoryContext oldContext;
691 
692  /*
693  * sanity checks
694  */
695  Assert(slot != NULL);
696  Assert(!slot->tts_isempty);
697 
698  /*
699  * If we have a minimal physical tuple (local or not) then just return it.
700  */
701  if (slot->tts_mintuple)
702  return slot->tts_mintuple;
703 
704  /*
705  * Otherwise, copy or build a minimal tuple, and store it into the slot.
706  *
707  * We may be called in a context that is shorter-lived than the tuple
708  * slot, but we have to ensure that the materialized tuple will survive
709  * anyway.
710  */
711  oldContext = MemoryContextSwitchTo(slot->tts_mcxt);
713  slot->tts_shouldFreeMin = true;
714  MemoryContextSwitchTo(oldContext);
715 
716  /*
717  * Note: we may now have a situation where we have a local minimal tuple
718  * attached to a virtual or non-local physical tuple. There seems no harm
719  * in that at the moment, but if any materializes, we should change this
720  * function to force the slot into minimal-tuple-only state.
721  */
722 
723  return slot->tts_mintuple;
724 }
bool tts_isempty
Definition: tuptable.h:116
MinimalTuple ExecCopySlotMinimalTuple(TupleTableSlot *slot)
Definition: execTuples.c:613
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
bool tts_shouldFreeMin
Definition: tuptable.h:118
MemoryContext tts_mcxt
Definition: tuptable.h:122
#define Assert(condition)
Definition: c.h:688
MinimalTuple tts_mintuple
Definition: tuptable.h:127

◆ ExecFetchSlotTuple()

HeapTuple ExecFetchSlotTuple ( TupleTableSlot slot)

Definition at line 654 of file execTuples.c.

References Assert, ExecMaterializeSlot(), TTS_HAS_PHYSICAL_TUPLE, TupleTableSlot::tts_isempty, and TupleTableSlot::tts_tuple.

Referenced by ExecConstraints(), ExecFetchSlotTupleDatum(), ExecFindPartition(), ExecPartitionCheckEmitError(), and ExecWithCheckOptions().

655 {
656  /*
657  * sanity checks
658  */
659  Assert(slot != NULL);
660  Assert(!slot->tts_isempty);
661 
662  /*
663  * If we have a regular physical tuple then just return it.
664  */
665  if (TTS_HAS_PHYSICAL_TUPLE(slot))
666  return slot->tts_tuple;
667 
668  /*
669  * Otherwise materialize the slot...
670  */
671  return ExecMaterializeSlot(slot);
672 }
bool tts_isempty
Definition: tuptable.h:116
#define Assert(condition)
Definition: c.h:688
HeapTuple ExecMaterializeSlot(TupleTableSlot *slot)
Definition: execTuples.c:761
HeapTuple tts_tuple
Definition: tuptable.h:120
#define TTS_HAS_PHYSICAL_TUPLE(slot)
Definition: tuptable.h:133

◆ ExecFetchSlotTupleDatum()

Datum ExecFetchSlotTupleDatum ( TupleTableSlot slot)

Definition at line 734 of file execTuples.c.

References ExecFetchSlotTuple(), heap_copy_tuple_as_datum(), and TupleTableSlot::tts_tupleDescriptor.

Referenced by ExecMakeFunctionResultSet(), and postquel_get_single_result().

735 {
736  HeapTuple tup;
737  TupleDesc tupdesc;
738 
739  /* Fetch slot's contents in regular-physical-tuple form */
740  tup = ExecFetchSlotTuple(slot);
741  tupdesc = slot->tts_tupleDescriptor;
742 
743  /* Convert to Datum form */
744  return heap_copy_tuple_as_datum(tup, tupdesc);
745 }
Datum heap_copy_tuple_as_datum(HeapTuple tuple, TupleDesc tupleDesc)
Definition: heaptuple.c:659
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:121
HeapTuple ExecFetchSlotTuple(TupleTableSlot *slot)
Definition: execTuples.c:654

◆ ExecInitExtraTupleSlot()

◆ ExecInitNullTupleSlot()

TupleTableSlot* ExecInitNullTupleSlot ( EState estate,
TupleDesc  tupType 
)

Definition at line 924 of file execTuples.c.

References ExecInitExtraTupleSlot(), and ExecStoreAllNullTuple().

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

925 {
926  TupleTableSlot *slot = ExecInitExtraTupleSlot(estate, tupType);
927 
928  return ExecStoreAllNullTuple(slot);
929 }
TupleTableSlot * ExecStoreAllNullTuple(TupleTableSlot *slot)
Definition: execTuples.c:548
TupleTableSlot * ExecInitExtraTupleSlot(EState *estate, TupleDesc tupledesc)
Definition: execTuples.c:910

◆ ExecInitResultTupleSlotTL()

void ExecInitResultTupleSlotTL ( EState estate,
PlanState planstate 
)

Definition at line 870 of file execTuples.c.

References EState::es_tupleTable, ExecAllocTableSlot(), ExecContextForcesOids(), ExecTypeFromTL(), PlanState::plan, PlanState::ps_ResultTupleSlot, and Plan::targetlist.

Referenced by ExecInitAgg(), ExecInitAppend(), ExecInitBitmapHeapScan(), ExecInitCteScan(), ExecInitCustomScan(), ExecInitForeignScan(), ExecInitFunctionScan(), ExecInitGather(), ExecInitGatherMerge(), ExecInitGroup(), ExecInitHash(), ExecInitHashJoin(), ExecInitIndexOnlyScan(), ExecInitIndexScan(), ExecInitLimit(), ExecInitLockRows(), ExecInitMaterial(), ExecInitMergeAppend(), ExecInitMergeJoin(), ExecInitModifyTable(), ExecInitNamedTuplestoreScan(), ExecInitNestLoop(), ExecInitProjectSet(), ExecInitRecursiveUnion(), ExecInitResult(), ExecInitSampleScan(), ExecInitSeqScan(), ExecInitSetOp(), ExecInitSort(), ExecInitSubqueryScan(), ExecInitTableFuncScan(), ExecInitTidScan(), ExecInitUnique(), ExecInitValuesScan(), ExecInitWindowAgg(), and ExecInitWorkTableScan().

871 {
872  bool hasoid;
873  TupleDesc tupDesc;
874 
875  if (ExecContextForcesOids(planstate, &hasoid))
876  {
877  /* context forces OID choice; hasoid is now set correctly */
878  }
879  else
880  {
881  /* given free choice, don't leave space for OIDs in result tuples */
882  hasoid = false;
883  }
884 
885  tupDesc = ExecTypeFromTL(planstate->plan->targetlist, hasoid);
886 
887  planstate->ps_ResultTupleSlot = ExecAllocTableSlot(&estate->es_tupleTable, tupDesc);
888 }
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:901
TupleTableSlot * ExecAllocTableSlot(List **tupleTable, TupleDesc desc)
Definition: execTuples.c:167
TupleDesc ExecTypeFromTL(List *targetList, bool hasoid)
Definition: execTuples.c:944
List * es_tupleTable
Definition: execnodes.h:490
Plan * plan
Definition: execnodes.h:868
List * targetlist
Definition: plannodes.h:144
bool ExecContextForcesOids(PlanState *planstate, bool *hasoids)
Definition: execMain.c:1516

◆ ExecInitScanTupleSlot()

◆ ExecMaterializeSlot()

HeapTuple ExecMaterializeSlot ( TupleTableSlot slot)

Definition at line 761 of file execTuples.c.

References Assert, BufferIsValid, ExecCopySlotTuple(), InvalidBuffer, MemoryContextSwitchTo(), ReleaseBuffer(), TupleTableSlot::tts_buffer, TupleTableSlot::tts_isempty, TupleTableSlot::tts_mcxt, TupleTableSlot::tts_mintuple, TupleTableSlot::tts_nvalid, TupleTableSlot::tts_shouldFree, TupleTableSlot::tts_shouldFreeMin, and TupleTableSlot::tts_tuple.

Referenced by AfterTriggerExecute(), apply_returning_filter(), CopyFrom(), EvalPlanQual(), ExecBRInsertTriggers(), ExecBRUpdateTriggers(), ExecDelete(), ExecFetchSlotTuple(), ExecInsert(), ExecIRInsertTriggers(), ExecIRUpdateTriggers(), ExecProcessReturning(), ExecSimpleRelationInsert(), ExecSimpleRelationUpdate(), ExecUpdate(), ForeignNext(), intorel_receive(), RelationFindReplTupleByIndex(), RelationFindReplTupleSeq(), tqueueReceiveSlot(), and transientrel_receive().

762 {
763  MemoryContext oldContext;
764 
765  /*
766  * sanity checks
767  */
768  Assert(slot != NULL);
769  Assert(!slot->tts_isempty);
770 
771  /*
772  * If we have a regular physical tuple, and it's locally palloc'd, we have
773  * nothing to do.
774  */
775  if (slot->tts_tuple && slot->tts_shouldFree)
776  return slot->tts_tuple;
777 
778  /*
779  * Otherwise, copy or build a physical tuple, and store it into the slot.
780  *
781  * We may be called in a context that is shorter-lived than the tuple
782  * slot, but we have to ensure that the materialized tuple will survive
783  * anyway.
784  */
785  oldContext = MemoryContextSwitchTo(slot->tts_mcxt);
786  slot->tts_tuple = ExecCopySlotTuple(slot);
787  slot->tts_shouldFree = true;
788  MemoryContextSwitchTo(oldContext);
789 
790  /*
791  * Drop the pin on the referenced buffer, if there is one.
792  */
793  if (BufferIsValid(slot->tts_buffer))
794  ReleaseBuffer(slot->tts_buffer);
795 
796  slot->tts_buffer = InvalidBuffer;
797 
798  /*
799  * Mark extracted state invalid. This is important because the slot is
800  * not supposed to depend any more on the previous external data; we
801  * mustn't leave any dangling pass-by-reference datums in tts_values.
802  * However, we have not actually invalidated any such datums, if there
803  * happen to be any previously fetched from the slot. (Note in particular
804  * that we have not pfree'd tts_mintuple, if there is one.)
805  */
806  slot->tts_nvalid = 0;
807 
808  /*
809  * On the same principle of not depending on previous remote storage,
810  * forget the mintuple if it's not local storage. (If it is local
811  * storage, we must not pfree it now, since callers might have already
812  * fetched datum pointers referencing it.)
813  */
814  if (!slot->tts_shouldFreeMin)
815  slot->tts_mintuple = NULL;
816 
817  return slot->tts_tuple;
818 }
bool tts_isempty
Definition: tuptable.h:116
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
#define InvalidBuffer
Definition: buf.h:25
bool tts_shouldFreeMin
Definition: tuptable.h:118
MemoryContext tts_mcxt
Definition: tuptable.h:122
void ReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3309
bool tts_shouldFree
Definition: tuptable.h:117
HeapTuple ExecCopySlotTuple(TupleTableSlot *slot)
Definition: execTuples.c:581
#define Assert(condition)
Definition: c.h:688
#define BufferIsValid(bufnum)
Definition: bufmgr.h:114
MinimalTuple tts_mintuple
Definition: tuptable.h:127
HeapTuple tts_tuple
Definition: tuptable.h:120
Buffer tts_buffer
Definition: tuptable.h:123

◆ ExecResetTupleTable()

void ExecResetTupleTable ( List tupleTable,
bool  shouldFree 
)

Definition at line 186 of file execTuples.c.

References ExecClearTuple(), lfirst_node, list_free(), pfree(), ReleaseTupleDesc, TupleTableSlot::tts_fixedTupleDescriptor, TupleTableSlot::tts_isnull, TupleTableSlot::tts_tupleDescriptor, and TupleTableSlot::tts_values.

Referenced by apply_handle_delete(), apply_handle_insert(), apply_handle_update(), CopyFrom(), EvalPlanQualEnd(), and ExecEndPlan().

188 {
189  ListCell *lc;
190 
191  foreach(lc, tupleTable)
192  {
194 
195  /* Always release resources and reset the slot to empty */
196  ExecClearTuple(slot);
197  if (slot->tts_tupleDescriptor)
198  {
200  slot->tts_tupleDescriptor = NULL;
201  }
202 
203  /* If shouldFree, release memory occupied by the slot itself */
204  if (shouldFree)
205  {
206  if (!slot->tts_fixedTupleDescriptor)
207  {
208  if (slot->tts_values)
209  pfree(slot->tts_values);
210  if (slot->tts_isnull)
211  pfree(slot->tts_isnull);
212  }
213  pfree(slot);
214  }
215  }
216 
217  /* If shouldFree, release the list structure */
218  if (shouldFree)
219  list_free(tupleTable);
220 }
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: execTuples.c:475
Datum * tts_values
Definition: tuptable.h:125
void pfree(void *pointer)
Definition: mcxt.c:936
#define lfirst_node(type, lc)
Definition: pg_list.h:109
bool * tts_isnull
Definition: tuptable.h:126
bool tts_fixedTupleDescriptor
Definition: tuptable.h:130
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:121
void list_free(List *list)
Definition: list.c:1133
#define ReleaseTupleDesc(tupdesc)
Definition: tupdesc.h:121

◆ ExecSetSlotDescriptor()

void ExecSetSlotDescriptor ( TupleTableSlot slot,
TupleDesc  tupdesc 
)

Definition at line 281 of file execTuples.c.

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

Referenced by apply_returning_filter(), ConvertPartitionTupleSlot(), ExecAssignScanType(), ExecBRInsertTriggers(), ExecBRUpdateTriggers(), ExecConstraints(), ExecDelete(), ExecInitJunkFilter(), ExecInitJunkFilterConversion(), ExecIRInsertTriggers(), ExecIRUpdateTriggers(), ExecPartitionCheckEmitError(), ExecWithCheckOptions(), and TriggerEnabled().

283 {
285 
286  /* For safety, make sure slot is empty before changing it */
287  ExecClearTuple(slot);
288 
289  /*
290  * Release any old descriptor. Also release old Datum/isnull arrays if
291  * present (we don't bother to check if they could be re-used).
292  */
293  if (slot->tts_tupleDescriptor)
295 
296  if (slot->tts_values)
297  pfree(slot->tts_values);
298  if (slot->tts_isnull)
299  pfree(slot->tts_isnull);
300 
301  /*
302  * Install the new descriptor; if it's refcounted, bump its refcount.
303  */
304  slot->tts_tupleDescriptor = tupdesc;
305  PinTupleDesc(tupdesc);
306 
307  /*
308  * Allocate Datum/isnull arrays of the appropriate size. These must have
309  * the same lifetime as the slot, so allocate in the slot's own context.
310  */
311  slot->tts_values = (Datum *)
312  MemoryContextAlloc(slot->tts_mcxt, tupdesc->natts * sizeof(Datum));
313  slot->tts_isnull = (bool *)
314  MemoryContextAlloc(slot->tts_mcxt, tupdesc->natts * sizeof(bool));
315 }
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: execTuples.c:475
MemoryContext tts_mcxt
Definition: tuptable.h:122
Datum * tts_values
Definition: tuptable.h:125
int natts
Definition: tupdesc.h:79
void pfree(void *pointer)
Definition: mcxt.c:936
bool * tts_isnull
Definition: tuptable.h:126
bool tts_fixedTupleDescriptor
Definition: tuptable.h:130
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:121
uintptr_t Datum
Definition: postgres.h:365
#define Assert(condition)
Definition: c.h:688
#define PinTupleDesc(tupdesc)
Definition: tupdesc.h:115
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition: mcxt.c:693
#define ReleaseTupleDesc(tupdesc)
Definition: tupdesc.h:121

◆ ExecStoreAllNullTuple()

TupleTableSlot* ExecStoreAllNullTuple ( TupleTableSlot slot)

Definition at line 548 of file execTuples.c.

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

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

549 {
550  /*
551  * sanity checks
552  */
553  Assert(slot != NULL);
554  Assert(slot->tts_tupleDescriptor != NULL);
555 
556  /* Clear any old contents */
557  ExecClearTuple(slot);
558 
559  /*
560  * Fill all the columns of the virtual tuple with nulls
561  */
562  MemSet(slot->tts_values, 0,
563  slot->tts_tupleDescriptor->natts * sizeof(Datum));
564  memset(slot->tts_isnull, true,
565  slot->tts_tupleDescriptor->natts * sizeof(bool));
566 
567  return ExecStoreVirtualTuple(slot);
568 }
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: execTuples.c:475
#define MemSet(start, val, len)
Definition: c.h:897
Datum * tts_values
Definition: tuptable.h:125
int natts
Definition: tupdesc.h:79
bool * tts_isnull
Definition: tuptable.h:126
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:121
uintptr_t Datum
Definition: postgres.h:365
#define Assert(condition)
Definition: c.h:688
TupleTableSlot * ExecStoreVirtualTuple(TupleTableSlot *slot)
Definition: execTuples.c:524

◆ ExecStoreMinimalTuple()

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

Definition at line 420 of file execTuples.c.

References Assert, BufferIsValid, heap_free_minimal_tuple(), heap_freetuple(), InvalidBuffer, MINIMAL_TUPLE_OFFSET, ReleaseBuffer(), HeapTupleData::t_data, HeapTupleData::t_len, MinimalTupleData::t_len, TupleTableSlot::tts_buffer, TupleTableSlot::tts_isempty, TupleTableSlot::tts_minhdr, TupleTableSlot::tts_mintuple, TupleTableSlot::tts_nvalid, TupleTableSlot::tts_shouldFree, TupleTableSlot::tts_shouldFreeMin, TupleTableSlot::tts_tuple, and TupleTableSlot::tts_tupleDescriptor.

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

423 {
424  /*
425  * sanity checks
426  */
427  Assert(mtup != NULL);
428  Assert(slot != NULL);
429  Assert(slot->tts_tupleDescriptor != NULL);
430 
431  /*
432  * Free any old physical tuple belonging to the slot.
433  */
434  if (slot->tts_shouldFree)
435  heap_freetuple(slot->tts_tuple);
436  if (slot->tts_shouldFreeMin)
438 
439  /*
440  * Drop the pin on the referenced buffer, if there is one.
441  */
442  if (BufferIsValid(slot->tts_buffer))
443  ReleaseBuffer(slot->tts_buffer);
444 
445  slot->tts_buffer = InvalidBuffer;
446 
447  /*
448  * Store the new tuple into the specified slot.
449  */
450  slot->tts_isempty = false;
451  slot->tts_shouldFree = false;
452  slot->tts_shouldFreeMin = shouldFree;
453  slot->tts_tuple = &slot->tts_minhdr;
454  slot->tts_mintuple = mtup;
455 
456  slot->tts_minhdr.t_len = mtup->t_len + MINIMAL_TUPLE_OFFSET;
457  slot->tts_minhdr.t_data = (HeapTupleHeader) ((char *) mtup - MINIMAL_TUPLE_OFFSET);
458  /* no need to set t_self or t_tableOid since we won't allow access */
459 
460  /* Mark extracted state invalid */
461  slot->tts_nvalid = 0;
462 
463  return slot;
464 }
bool tts_isempty
Definition: tuptable.h:116
HeapTupleHeaderData * HeapTupleHeader
Definition: htup.h:23
#define InvalidBuffer
Definition: buf.h:25
bool tts_shouldFreeMin
Definition: tuptable.h:118
void ReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3309
void heap_freetuple(HeapTuple htup)
Definition: heaptuple.c:1373
HeapTupleHeader t_data
Definition: htup.h:67
HeapTupleData tts_minhdr
Definition: tuptable.h:128
void heap_free_minimal_tuple(MinimalTuple mtup)
Definition: heaptuple.c:1468
uint32 t_len
Definition: htup.h:64
bool tts_shouldFree
Definition: tuptable.h:117
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:121
#define Assert(condition)
Definition: c.h:688
#define BufferIsValid(bufnum)
Definition: bufmgr.h:114
MinimalTuple tts_mintuple
Definition: tuptable.h:127
#define MINIMAL_TUPLE_OFFSET
Definition: htup_details.h:625
HeapTuple tts_tuple
Definition: tuptable.h:120
Buffer tts_buffer
Definition: tuptable.h:123

◆ ExecStoreTuple()

TupleTableSlot* ExecStoreTuple ( HeapTuple  tuple,
TupleTableSlot slot,
Buffer  buffer,
bool  shouldFree 
)

Definition at line 356 of file execTuples.c.

References Assert, buffer, BufferIsValid, heap_free_minimal_tuple(), heap_freetuple(), IncrBufferRefCount(), ReleaseBuffer(), TupleTableSlot::tts_buffer, TupleTableSlot::tts_isempty, TupleTableSlot::tts_mintuple, TupleTableSlot::tts_nvalid, TupleTableSlot::tts_shouldFree, TupleTableSlot::tts_shouldFreeMin, TupleTableSlot::tts_tuple, and TupleTableSlot::tts_tupleDescriptor.

Referenced by agg_retrieve_direct(), apply_handle_update(), ATRewriteTable(), BitmapHeapNext(), CatalogIndexInsert(), check_default_allows_bound(), check_exclusion_or_unique_constraint(), comparetup_cluster(), compute_index_stats(), ConvertPartitionTupleSlot(), CopyFrom(), CopyFromInsertBatch(), ExecBRInsertTriggers(), ExecBRUpdateTriggers(), ExecConstraints(), ExecCopySlot(), ExecDelete(), ExecFindPartition(), ExecIRInsertTriggers(), ExecIRUpdateTriggers(), ExecOnConflictUpdate(), ExecPartitionCheckEmitError(), ExecScanFetch(), ExecWithCheckOptions(), gather_getnext(), gather_merge_readnext(), get_actual_variable_range(), get_returning_data(), IndexBuildHeapRangeScan(), IndexCheckExclusion(), IndexNext(), IndexNextWithReorder(), IndexOnlyNext(), postgresIterateForeignScan(), RelationFindReplTupleByIndex(), RelationFindReplTupleSeq(), SampleNext(), SeqNext(), setop_retrieve_direct(), store_returning_result(), TidNext(), TriggerEnabled(), unique_key_recheck(), validate_index_heapscan(), and validateCheckConstraint().

360 {
361  /*
362  * sanity checks
363  */
364  Assert(tuple != NULL);
365  Assert(slot != NULL);
366  Assert(slot->tts_tupleDescriptor != NULL);
367  /* passing shouldFree=true for a tuple on a disk page is not sane */
368  Assert(BufferIsValid(buffer) ? (!shouldFree) : true);
369 
370  /*
371  * Free any old physical tuple belonging to the slot.
372  */
373  if (slot->tts_shouldFree)
374  heap_freetuple(slot->tts_tuple);
375  if (slot->tts_shouldFreeMin)
377 
378  /*
379  * Store the new tuple into the specified slot.
380  */
381  slot->tts_isempty = false;
382  slot->tts_shouldFree = shouldFree;
383  slot->tts_shouldFreeMin = false;
384  slot->tts_tuple = tuple;
385  slot->tts_mintuple = NULL;
386 
387  /* Mark extracted state invalid */
388  slot->tts_nvalid = 0;
389 
390  /*
391  * If tuple is on a disk page, keep the page pinned as long as we hold a
392  * pointer into it. We assume the caller already has such a pin.
393  *
394  * This is coded to optimize the case where the slot previously held a
395  * tuple on the same disk page: in that case releasing and re-acquiring
396  * the pin is a waste of cycles. This is a common situation during
397  * seqscans, so it's worth troubling over.
398  */
399  if (slot->tts_buffer != buffer)
400  {
401  if (BufferIsValid(slot->tts_buffer))
402  ReleaseBuffer(slot->tts_buffer);
403  slot->tts_buffer = buffer;
404  if (BufferIsValid(buffer))
406  }
407 
408  return slot;
409 }
bool tts_isempty
Definition: tuptable.h:116
bool tts_shouldFreeMin
Definition: tuptable.h:118
void ReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3309
void heap_freetuple(HeapTuple htup)
Definition: heaptuple.c:1373
void heap_free_minimal_tuple(MinimalTuple mtup)
Definition: heaptuple.c:1468
bool tts_shouldFree
Definition: tuptable.h:117
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:121
#define Assert(condition)
Definition: c.h:688
WalTimeSample buffer[LAG_TRACKER_BUFFER_SIZE]
Definition: walsender.c:215
#define BufferIsValid(bufnum)
Definition: bufmgr.h:114
MinimalTuple tts_mintuple
Definition: tuptable.h:127
HeapTuple tts_tuple
Definition: tuptable.h:120
Buffer tts_buffer
Definition: tuptable.h:123
void IncrBufferRefCount(Buffer buffer)
Definition: bufmgr.c:3347

◆ ExecStoreVirtualTuple()

◆ ExecTypeFromExprList()

TupleDesc ExecTypeFromExprList ( List exprList)

Definition at line 1003 of file execTuples.c.

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

Referenced by ExecInitExprRec(), and ExecInitValuesScan().

1004 {
1005  TupleDesc typeInfo;
1006  ListCell *lc;
1007  int cur_resno = 1;
1008 
1009  typeInfo = CreateTemplateTupleDesc(list_length(exprList), false);
1010 
1011  foreach(lc, exprList)
1012  {
1013  Node *e = lfirst(lc);
1014 
1015  TupleDescInitEntry(typeInfo,
1016  cur_resno,
1017  NULL,
1018  exprType(e),
1019  exprTypmod(e),
1020  0);
1021  TupleDescInitEntryCollation(typeInfo,
1022  cur_resno,
1023  exprCollation(e));
1024  cur_resno++;
1025  }
1026 
1027  return typeInfo;
1028 }
int32 exprTypmod(const Node *expr)
Definition: nodeFuncs.c:276
Definition: nodes.h:513
void TupleDescInitEntryCollation(TupleDesc desc, AttrNumber attributeNumber, Oid collationid)
Definition: tupdesc.c:702
void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)
Definition: tupdesc.c:543
#define lfirst(lc)
Definition: pg_list.h:106
Oid exprType(const Node *expr)
Definition: nodeFuncs.c:42
static int list_length(const List *l)
Definition: pg_list.h:89
Oid exprCollation(const Node *expr)
Definition: nodeFuncs.c:720
TupleDesc CreateTemplateTupleDesc(int natts, bool hasoid)
Definition: tupdesc.c:43
e
Definition: preproc-init.c:82

◆ ExecTypeFromTL()

TupleDesc ExecTypeFromTL ( List targetList,
bool  hasoid 
)

Definition at line 944 of file execTuples.c.

References ExecTypeFromTLInternal().

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

945 {
946  return ExecTypeFromTLInternal(targetList, hasoid, false);
947 }
static TupleDesc ExecTypeFromTLInternal(List *targetList, bool hasoid, bool skipjunk)
Definition: execTuples.c:962

◆ ExecTypeFromTLInternal()

static TupleDesc ExecTypeFromTLInternal ( List targetList,
bool  hasoid,
bool  skipjunk 
)
static

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

963 {
964  TupleDesc typeInfo;
965  ListCell *l;
966  int len;
967  int cur_resno = 1;
968 
969  if (skipjunk)
970  len = ExecCleanTargetListLength(targetList);
971  else
972  len = ExecTargetListLength(targetList);
973  typeInfo = CreateTemplateTupleDesc(len, hasoid);
974 
975  foreach(l, targetList)
976  {
977  TargetEntry *tle = lfirst(l);
978 
979  if (skipjunk && tle->resjunk)
980  continue;
981  TupleDescInitEntry(typeInfo,
982  cur_resno,
983  tle->resname,
984  exprType((Node *) tle->expr),
985  exprTypmod((Node *) tle->expr),
986  0);
988  cur_resno,
989  exprCollation((Node *) tle->expr));
990  cur_resno++;
991  }
992 
993  return typeInfo;
994 }
int ExecTargetListLength(List *targetlist)
Definition: execUtils.c:1034
int32 exprTypmod(const Node *expr)
Definition: nodeFuncs.c:276
Definition: nodes.h:513
char * resname
Definition: primnodes.h:1377
bool resjunk
Definition: primnodes.h:1382
void TupleDescInitEntryCollation(TupleDesc desc, AttrNumber attributeNumber, Oid collationid)
Definition: tupdesc.c:702
void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)
Definition: tupdesc.c:543
int ExecCleanTargetListLength(List *targetlist)
Definition: execUtils.c:1044
#define lfirst(lc)
Definition: pg_list.h:106
Expr * expr
Definition: primnodes.h:1375
Oid exprType(const Node *expr)
Definition: nodeFuncs.c:42
Oid exprCollation(const Node *expr)
Definition: nodeFuncs.c:720
TupleDesc CreateTemplateTupleDesc(int natts, bool hasoid)
Definition: tupdesc.c:43

◆ ExecTypeSetColNames()

void ExecTypeSetColNames ( TupleDesc  typeInfo,
List namesList 
)

Definition at line 1042 of file execTuples.c.

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

Referenced by ExecEvalWholeRowVar(), and ExecInitExprRec().

1043 {
1044  bool modified = false;
1045  int colno = 0;
1046  ListCell *lc;
1047 
1048  foreach(lc, namesList)
1049  {
1050  char *cname = strVal(lfirst(lc));
1051  Form_pg_attribute attr;
1052 
1053  /* Guard against too-long names list */
1054  if (colno >= typeInfo->natts)
1055  break;
1056  attr = TupleDescAttr(typeInfo, colno);
1057  colno++;
1058 
1059  /* Ignore empty aliases (these must be for dropped columns) */
1060  if (cname[0] == '\0')
1061  continue;
1062 
1063  /* Change tupdesc only if alias is actually different */
1064  if (strcmp(cname, NameStr(attr->attname)) != 0)
1065  {
1066  namestrcpy(&(attr->attname), cname);
1067  modified = true;
1068  }
1069  }
1070 
1071  /* If we modified the tupdesc, it's now a new record type */
1072  if (modified)
1073  {
1074  typeInfo->tdtypeid = RECORDOID;
1075  typeInfo->tdtypmod = -1;
1076  }
1077 }
Oid tdtypeid
Definition: tupdesc.h:80
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:90
#define strVal(v)
Definition: value.h:54
int namestrcpy(Name name, const char *str)
Definition: name.c:216
int natts
Definition: tupdesc.h:79
int32 tdtypmod
Definition: tupdesc.h:81
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:187
#define RECORDOID
Definition: pg_type.h:680
#define lfirst(lc)
Definition: pg_list.h:106
#define NameStr(name)
Definition: c.h:565

◆ HeapTupleHeaderGetDatum()

Datum HeapTupleHeaderGetDatum ( HeapTupleHeader  tuple)

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

1261 {
1262  Datum result;
1263  TupleDesc tupDesc;
1264 
1265  /* No work if there are no external TOAST pointers in the tuple */
1266  if (!HeapTupleHeaderHasExternal(tuple))
1267  return PointerGetDatum(tuple);
1268 
1269  /* Use the type data saved by heap_form_tuple to look up the rowtype */
1271  HeapTupleHeaderGetTypMod(tuple));
1272 
1273  /* And do the flattening */
1274  result = toast_flatten_tuple_to_datum(tuple,
1276  tupDesc);
1277 
1278  ReleaseTupleDesc(tupDesc);
1279 
1280  return result;
1281 }
TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod)
Definition: typcache.c:1641
#define PointerGetDatum(X)
Definition: postgres.h:539
#define HeapTupleHeaderGetTypMod(tup)
Definition: htup_details.h:460
Datum toast_flatten_tuple_to_datum(HeapTupleHeader tup, uint32 tup_len, TupleDesc tupleDesc)
Definition: tuptoaster.c:1187
uintptr_t Datum
Definition: postgres.h:365
#define HeapTupleHeaderGetTypeId(tup)
Definition: htup_details.h:450
#define HeapTupleHeaderHasExternal(tup)
Definition: htup_details.h:545
#define ReleaseTupleDesc(tupdesc)
Definition: tupdesc.h:121
#define HeapTupleHeaderGetDatumLength(tup)
Definition: htup_details.h:444

◆ MakeSingleTupleTableSlot()

◆ MakeTupleTableSlot()

TupleTableSlot* MakeTupleTableSlot ( TupleDesc  tupleDesc)

Definition at line 113 of file execTuples.c.

References CurrentMemoryContext, InvalidBuffer, MAXALIGN, tupleDesc::natts, palloc0(), PinTupleDesc, T_TupleTableSlot, TupleTableSlot::tts_buffer, TupleTableSlot::tts_fixedTupleDescriptor, TupleTableSlot::tts_isempty, TupleTableSlot::tts_isnull, TupleTableSlot::tts_mcxt, TupleTableSlot::tts_mintuple, TupleTableSlot::tts_nvalid, TupleTableSlot::tts_shouldFree, TupleTableSlot::tts_shouldFreeMin, TupleTableSlot::tts_tuple, TupleTableSlot::tts_tupleDescriptor, TupleTableSlot::tts_values, and TupleTableSlot::type.

Referenced by ExecAllocTableSlot(), ExecSetupPartitionTupleRouting(), and MakeSingleTupleTableSlot().

114 {
115  Size sz;
116  TupleTableSlot *slot;
117 
118  /*
119  * When a fixed descriptor is specified, we can reduce overhead by
120  * allocating the entire slot in one go.
121  */
122  if (tupleDesc)
123  sz = MAXALIGN(sizeof(TupleTableSlot)) +
124  MAXALIGN(tupleDesc->natts * sizeof(Datum)) +
125  MAXALIGN(tupleDesc->natts * sizeof(bool));
126  else
127  sz = sizeof(TupleTableSlot);
128 
129  slot = palloc0(sz);
130  slot->type = T_TupleTableSlot;
131  slot->tts_isempty = true;
132  slot->tts_shouldFree = false;
133  slot->tts_shouldFreeMin = false;
134  slot->tts_tuple = NULL;
135  slot->tts_fixedTupleDescriptor = tupleDesc != NULL;
136  slot->tts_tupleDescriptor = tupleDesc;
138  slot->tts_buffer = InvalidBuffer;
139  slot->tts_nvalid = 0;
140  slot->tts_values = NULL;
141  slot->tts_isnull = NULL;
142  slot->tts_mintuple = NULL;
143 
144  if (tupleDesc != NULL)
145  {
146  slot->tts_values = (Datum *)
147  (((char *) slot)
148  + MAXALIGN(sizeof(TupleTableSlot)));
149  slot->tts_isnull = (bool *)
150  (((char *) slot)
151  + MAXALIGN(sizeof(TupleTableSlot))
152  + MAXALIGN(tupleDesc->natts * sizeof(Datum)));
153 
154  PinTupleDesc(tupleDesc);
155  }
156 
157  return slot;
158 }
bool tts_isempty
Definition: tuptable.h:116
#define InvalidBuffer
Definition: buf.h:25
bool tts_shouldFreeMin
Definition: tuptable.h:118
MemoryContext tts_mcxt
Definition: tuptable.h:122
Datum * tts_values
Definition: tuptable.h:125
int natts
Definition: tupdesc.h:79
NodeTag type
Definition: tuptable.h:115
bool * tts_isnull
Definition: tuptable.h:126
MemoryContext CurrentMemoryContext
Definition: mcxt.c:37
bool tts_shouldFree
Definition: tuptable.h:117
bool tts_fixedTupleDescriptor
Definition: tuptable.h:130
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:121
void * palloc0(Size size)
Definition: mcxt.c:864
uintptr_t Datum
Definition: postgres.h:365
struct TupleTableSlot TupleTableSlot
size_t Size
Definition: c.h:422
#define MAXALIGN(LEN)
Definition: c.h:641
MinimalTuple tts_mintuple
Definition: tuptable.h:127
#define PinTupleDesc(tupdesc)
Definition: tupdesc.h:115
HeapTuple tts_tuple
Definition: tuptable.h:120
Buffer tts_buffer
Definition: tuptable.h:123

◆ TupleDescGetAttInMetadata()

AttInMetadata* TupleDescGetAttInMetadata ( TupleDesc  tupdesc)

Definition at line 1125 of file execTuples.c.

References AttInMetadata::attinfuncs, AttInMetadata::attioparams, AttInMetadata::atttypmods, BlessTupleDesc(), fmgr_info(), getTypeInputInfo(), i, tupleDesc::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(), crosstab(), dblink_get_pkey(), get_crosstab_tuplestore(), hash_page_items(), libpqrcv_processTuples(), materializeQueryResult(), materializeResult(), pg_config(), pg_get_keywords(), pg_get_multixact_members(), pg_logdir_ls(), pgp_armor_headers(), pgrowlocks(), pgstatindex_impl(), pltcl_build_tuple_result(), pltcl_func_handler(), pltcl_init_tuple_store(), postgresAcquireSampleRowsFunc(), postgresBeginDirectModify(), postgresBeginForeignModify(), postgresBeginForeignScan(), prs_setup_firstcall(), show_all_settings(), storeRow(), ts_setup_firstcall(), tt_setup_firstcall(), and xpath_table().

1126 {
1127  int natts = tupdesc->natts;
1128  int i;
1129  Oid atttypeid;
1130  Oid attinfuncid;
1131  FmgrInfo *attinfuncinfo;
1132  Oid *attioparams;
1133  int32 *atttypmods;
1134  AttInMetadata *attinmeta;
1135 
1136  attinmeta = (AttInMetadata *) palloc(sizeof(AttInMetadata));
1137 
1138  /* "Bless" the tupledesc so that we can make rowtype datums with it */
1139  attinmeta->tupdesc = BlessTupleDesc(tupdesc);
1140 
1141  /*
1142  * Gather info needed later to call the "in" function for each attribute
1143  */
1144  attinfuncinfo = (FmgrInfo *) palloc0(natts * sizeof(FmgrInfo));
1145  attioparams = (Oid *) palloc0(natts * sizeof(Oid));
1146  atttypmods = (int32 *) palloc0(natts * sizeof(int32));
1147 
1148  for (i = 0; i < natts; i++)
1149  {
1150  Form_pg_attribute att = TupleDescAttr(tupdesc, i);
1151 
1152  /* Ignore dropped attributes */
1153  if (!att->attisdropped)
1154  {
1155  atttypeid = att->atttypid;
1156  getTypeInputInfo(atttypeid, &attinfuncid, &attioparams[i]);
1157  fmgr_info(attinfuncid, &attinfuncinfo[i]);
1158  atttypmods[i] = att->atttypmod;
1159  }
1160  }
1161  attinmeta->attinfuncs = attinfuncinfo;
1162  attinmeta->attioparams = attioparams;
1163  attinmeta->atttypmods = atttypmods;
1164 
1165  return attinmeta;
1166 }
Definition: fmgr.h:56
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:90
int32 * atttypmods
Definition: funcapi.h:48
unsigned int Oid
Definition: postgres_ext.h:31
Oid * attioparams
Definition: funcapi.h:45
int natts
Definition: tupdesc.h:79
signed int int32
Definition: c.h:302
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:122
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
Definition: execTuples.c:1088
TupleDesc tupdesc
Definition: funcapi.h:39
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:187
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
Definition: lsyscache.c:2617
void * palloc0(Size size)
Definition: mcxt.c:864
void * palloc(Size size)
Definition: mcxt.c:835
int i
FmgrInfo * attinfuncs
Definition: funcapi.h:42

◆ TupleDescGetSlot()

TupleTableSlot* TupleDescGetSlot ( TupleDesc  tupdesc)

Definition at line 1105 of file execTuples.c.

References BlessTupleDesc(), and MakeSingleTupleTableSlot().

1106 {
1107  TupleTableSlot *slot;
1108 
1109  /* The useful work is here */
1110  BlessTupleDesc(tupdesc);
1111 
1112  /* Make a standalone slot */
1113  slot = MakeSingleTupleTableSlot(tupdesc);
1114 
1115  /* Return the slot */
1116  return slot;
1117 }
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
Definition: execTuples.c:1088
TupleTableSlot * MakeSingleTupleTableSlot(TupleDesc tupdesc)
Definition: execTuples.c:232