PostgreSQL Source Code  git master
execGrouping.c File Reference
#include "postgres.h"
#include "access/parallel.h"
#include "executor/executor.h"
#include "miscadmin.h"
#include "utils/lsyscache.h"
#include "utils/hashutils.h"
#include "utils/memutils.h"
#include "lib/simplehash.h"
Include dependency graph for execGrouping.c:

Go to the source code of this file.

Macros

#define SH_PREFIX   tuplehash
 
#define SH_ELEMENT_TYPE   TupleHashEntryData
 
#define SH_KEY_TYPE   MinimalTuple
 
#define SH_KEY   firstTuple
 
#define SH_HASH_KEY(tb, key)   TupleHashTableHash(tb, key)
 
#define SH_EQUAL(tb, a, b)   TupleHashTableMatch(tb, a, b) == 0
 
#define SH_SCOPE   extern
 
#define SH_STORE_HASH
 
#define SH_GET_HASH(tb, a)   a->hash
 
#define SH_DEFINE
 

Functions

static uint32 TupleHashTableHash (struct tuplehash_hash *tb, const MinimalTuple tuple)
 
static int TupleHashTableMatch (struct tuplehash_hash *tb, const MinimalTuple tuple1, const MinimalTuple tuple2)
 
ExprStateexecTuplesMatchPrepare (TupleDesc desc, int numCols, const AttrNumber *keyColIdx, const Oid *eqOperators, const Oid *collations, PlanState *parent)
 
void execTuplesHashPrepare (int numCols, const Oid *eqOperators, Oid **eqFuncOids, FmgrInfo **hashFunctions)
 
TupleHashTable BuildTupleHashTableExt (PlanState *parent, TupleDesc inputDesc, int numCols, AttrNumber *keyColIdx, const Oid *eqfuncoids, FmgrInfo *hashfunctions, Oid *collations, long nbuckets, Size additionalsize, MemoryContext metacxt, MemoryContext tablecxt, MemoryContext tempcxt, bool use_variable_hash_iv)
 
TupleHashTable BuildTupleHashTable (PlanState *parent, TupleDesc inputDesc, int numCols, AttrNumber *keyColIdx, const Oid *eqfuncoids, FmgrInfo *hashfunctions, Oid *collations, long nbuckets, Size additionalsize, MemoryContext tablecxt, MemoryContext tempcxt, bool use_variable_hash_iv)
 
void ResetTupleHashTable (TupleHashTable hashtable)
 
TupleHashEntry LookupTupleHashEntry (TupleHashTable hashtable, TupleTableSlot *slot, bool *isnew)
 
TupleHashEntry FindTupleHashEntry (TupleHashTable hashtable, TupleTableSlot *slot, ExprState *eqcomp, FmgrInfo *hashfunctions)
 

Macro Definition Documentation

◆ SH_DEFINE

#define SH_DEFINE

Definition at line 45 of file execGrouping.c.

◆ SH_ELEMENT_TYPE

#define SH_ELEMENT_TYPE   TupleHashEntryData

Definition at line 37 of file execGrouping.c.

◆ SH_EQUAL

#define SH_EQUAL (   tb,
  a,
 
)    TupleHashTableMatch(tb, a, b) == 0

Definition at line 41 of file execGrouping.c.

◆ SH_GET_HASH

#define SH_GET_HASH (   tb,
 
)    a->hash

Definition at line 44 of file execGrouping.c.

◆ SH_HASH_KEY

#define SH_HASH_KEY (   tb,
  key 
)    TupleHashTableHash(tb, key)

Definition at line 40 of file execGrouping.c.

◆ SH_KEY

#define SH_KEY   firstTuple

Definition at line 39 of file execGrouping.c.

◆ SH_KEY_TYPE

#define SH_KEY_TYPE   MinimalTuple

Definition at line 38 of file execGrouping.c.

◆ SH_PREFIX

#define SH_PREFIX   tuplehash

Definition at line 36 of file execGrouping.c.

◆ SH_SCOPE

#define SH_SCOPE   extern

Definition at line 42 of file execGrouping.c.

◆ SH_STORE_HASH

#define SH_STORE_HASH

Definition at line 43 of file execGrouping.c.

Function Documentation

◆ BuildTupleHashTable()

TupleHashTable BuildTupleHashTable ( PlanState parent,
TupleDesc  inputDesc,
int  numCols,
AttrNumber keyColIdx,
const Oid eqfuncoids,
FmgrInfo hashfunctions,
Oid collations,
long  nbuckets,
Size  additionalsize,
MemoryContext  tablecxt,
MemoryContext  tempcxt,
bool  use_variable_hash_iv 
)

Definition at line 252 of file execGrouping.c.

References BuildTupleHashTableExt().

262 {
263  return BuildTupleHashTableExt(parent,
264  inputDesc,
265  numCols, keyColIdx,
266  eqfuncoids,
267  hashfunctions,
268  collations,
269  nbuckets, additionalsize,
270  tablecxt,
271  tablecxt,
272  tempcxt,
273  use_variable_hash_iv);
274 }
TupleHashTable BuildTupleHashTableExt(PlanState *parent, TupleDesc inputDesc, int numCols, AttrNumber *keyColIdx, const Oid *eqfuncoids, FmgrInfo *hashfunctions, Oid *collations, long nbuckets, Size additionalsize, MemoryContext metacxt, MemoryContext tablecxt, MemoryContext tempcxt, bool use_variable_hash_iv)
Definition: execGrouping.c:154

◆ BuildTupleHashTableExt()

TupleHashTable BuildTupleHashTableExt ( PlanState parent,
TupleDesc  inputDesc,
int  numCols,
AttrNumber keyColIdx,
const Oid eqfuncoids,
FmgrInfo hashfunctions,
Oid collations,
long  nbuckets,
Size  additionalsize,
MemoryContext  metacxt,
MemoryContext  tablecxt,
MemoryContext  tempcxt,
bool  use_variable_hash_iv 
)

Definition at line 154 of file execGrouping.c.

References Assert, CreateStandaloneExprContext(), CreateTupleDescCopy(), TupleHashTableData::cur_eq_func, TupleHashTableData::entrysize, ExecBuildGroupingEqual(), TupleHashTableData::exprcontext, TupleHashTableData::hash_iv, TupleHashTableData::hashtab, TupleHashTableData::in_hash_funcs, TupleHashTableData::inputslot, TupleHashTableData::keyColIdx, MakeSingleTupleTableSlot(), MemoryContextSwitchTo(), Min, murmurhash32(), TupleHashTableData::numCols, palloc(), ParallelWorkerNumber, TupleHashTableData::tab_collations, TupleHashTableData::tab_eq_func, TupleHashTableData::tab_hash_funcs, TupleHashTableData::tablecxt, TupleHashTableData::tableslot, TupleHashTableData::tempcxt, TTSOpsMinimalTuple, and work_mem.

Referenced by build_hash_table(), buildSubPlanHash(), and BuildTupleHashTable().

165 {
166  TupleHashTable hashtable;
167  Size entrysize = sizeof(TupleHashEntryData) + additionalsize;
168  MemoryContext oldcontext;
169  bool allow_jit;
170 
171  Assert(nbuckets > 0);
172 
173  /* Limit initial table size request to not more than work_mem */
174  nbuckets = Min(nbuckets, (long) ((work_mem * 1024L) / entrysize));
175 
176  oldcontext = MemoryContextSwitchTo(metacxt);
177 
178  hashtable = (TupleHashTable) palloc(sizeof(TupleHashTableData));
179 
180  hashtable->numCols = numCols;
181  hashtable->keyColIdx = keyColIdx;
182  hashtable->tab_hash_funcs = hashfunctions;
183  hashtable->tab_collations = collations;
184  hashtable->tablecxt = tablecxt;
185  hashtable->tempcxt = tempcxt;
186  hashtable->entrysize = entrysize;
187  hashtable->tableslot = NULL; /* will be made on first lookup */
188  hashtable->inputslot = NULL;
189  hashtable->in_hash_funcs = NULL;
190  hashtable->cur_eq_func = NULL;
191 
192  /*
193  * If parallelism is in use, even if the master backend is performing the
194  * scan itself, we don't want to create the hashtable exactly the same way
195  * in all workers. As hashtables are iterated over in keyspace-order,
196  * doing so in all processes in the same way is likely to lead to
197  * "unbalanced" hashtables when the table size initially is
198  * underestimated.
199  */
200  if (use_variable_hash_iv)
202  else
203  hashtable->hash_iv = 0;
204 
205  hashtable->hashtab = tuplehash_create(metacxt, nbuckets, hashtable);
206 
207  /*
208  * We copy the input tuple descriptor just for safety --- we assume all
209  * input tuples will have equivalent descriptors.
210  */
213 
214  /*
215  * If the old reset interface is used (i.e. BuildTupleHashTable, rather
216  * than BuildTupleHashTableExt), allowing JIT would lead to the generated
217  * functions to a) live longer than the query b) be re-generated each time
218  * the table is being reset. Therefore prevent JIT from being used in that
219  * case, by not providing a parent node (which prevents accessing the
220  * JitContext in the EState).
221  */
222  allow_jit = metacxt != tablecxt;
223 
224  /* build comparator for all columns */
225  /* XXX: should we support non-minimal tuples for the inputslot? */
226  hashtable->tab_eq_func = ExecBuildGroupingEqual(inputDesc, inputDesc,
228  numCols,
229  keyColIdx, eqfuncoids, collations,
230  allow_jit ? parent : NULL);
231 
232  /*
233  * While not pretty, it's ok to not shut down this context, but instead
234  * rely on the containing memory context being reset, as
235  * ExecBuildGroupingEqual() only builds a very simple expression calling
236  * functions (i.e. nothing that'd employ RegisterExprContextCallback()).
237  */
239 
240  MemoryContextSwitchTo(oldcontext);
241 
242  return hashtable;
243 }
ExprContext * exprcontext
Definition: execnodes.h:708
ExprContext * CreateStandaloneExprContext(void)
Definition: execUtils.c:316
TupleDesc CreateTupleDescCopy(TupleDesc tupdesc)
Definition: tupdesc.c:110
TupleTableSlot * MakeSingleTupleTableSlot(TupleDesc tupdesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1203
ExprState * ExecBuildGroupingEqual(TupleDesc ldesc, TupleDesc rdesc, const TupleTableSlotOps *lops, const TupleTableSlotOps *rops, int numCols, const AttrNumber *keyColIdx, const Oid *eqfunctions, const Oid *collations, PlanState *parent)
Definition: execExpr.c:3331
TupleTableSlot * inputslot
Definition: execnodes.h:704
#define Min(x, y)
Definition: c.h:904
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
AttrNumber * keyColIdx
Definition: execnodes.h:695
ExprState * tab_eq_func
Definition: execnodes.h:697
ExprState * cur_eq_func
Definition: execnodes.h:706
FmgrInfo * tab_hash_funcs
Definition: execnodes.h:696
FmgrInfo * in_hash_funcs
Definition: execnodes.h:705
struct TupleHashEntryData TupleHashEntryData
MemoryContext tablecxt
Definition: execnodes.h:699
struct TupleHashTableData * TupleHashTable
Definition: execnodes.h:673
int ParallelWorkerNumber
Definition: parallel.c:110
int work_mem
Definition: globals.c:121
tuplehash_hash * hashtab
Definition: execnodes.h:693
#define Assert(condition)
Definition: c.h:732
TupleTableSlot * tableslot
Definition: execnodes.h:702
size_t Size
Definition: c.h:466
void * palloc(Size size)
Definition: mcxt.c:949
static uint32 murmurhash32(uint32 data)
Definition: hashutils.h:60
MemoryContext tempcxt
Definition: execnodes.h:700
const TupleTableSlotOps TTSOpsMinimalTuple
Definition: execTuples.c:86

◆ execTuplesHashPrepare()

void execTuplesHashPrepare ( int  numCols,
const Oid eqOperators,
Oid **  eqFuncOids,
FmgrInfo **  hashFunctions 
)

Definition at line 96 of file execGrouping.c.

References Assert, elog, ERROR, fmgr_info(), get_op_hash_functions(), get_opcode(), i, and palloc().

Referenced by ExecInitRecursiveUnion(), ExecInitSetOp(), and find_hash_columns().

100 {
101  int i;
102 
103  *eqFuncOids = (Oid *) palloc(numCols * sizeof(Oid));
104  *hashFunctions = (FmgrInfo *) palloc(numCols * sizeof(FmgrInfo));
105 
106  for (i = 0; i < numCols; i++)
107  {
108  Oid eq_opr = eqOperators[i];
109  Oid eq_function;
110  Oid left_hash_function;
111  Oid right_hash_function;
112 
113  eq_function = get_opcode(eq_opr);
114  if (!get_op_hash_functions(eq_opr,
115  &left_hash_function, &right_hash_function))
116  elog(ERROR, "could not find hash function for hash operator %u",
117  eq_opr);
118  /* We're not supporting cross-type cases here */
119  Assert(left_hash_function == right_hash_function);
120  (*eqFuncOids)[i] = eq_function;
121  fmgr_info(right_hash_function, &(*hashFunctions)[i]);
122  }
123 }
Definition: fmgr.h:56
bool get_op_hash_functions(Oid opno, RegProcedure *lhs_procno, RegProcedure *rhs_procno)
Definition: lsyscache.c:507
unsigned int Oid
Definition: postgres_ext.h:31
#define ERROR
Definition: elog.h:43
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:124
RegProcedure get_opcode(Oid opno)
Definition: lsyscache.c:1092
#define Assert(condition)
Definition: c.h:732
void * palloc(Size size)
Definition: mcxt.c:949
#define elog(elevel,...)
Definition: elog.h:226
int i

◆ execTuplesMatchPrepare()

ExprState* execTuplesMatchPrepare ( TupleDesc  desc,
int  numCols,
const AttrNumber keyColIdx,
const Oid eqOperators,
const Oid collations,
PlanState parent 
)

Definition at line 59 of file execGrouping.c.

References ExecBuildGroupingEqual(), get_opcode(), i, and palloc().

Referenced by build_pertrans_for_aggref(), ExecInitAgg(), ExecInitGroup(), ExecInitSetOp(), ExecInitUnique(), ExecInitWindowAgg(), and hypothetical_dense_rank_final().

65 {
66  Oid *eqFunctions = (Oid *) palloc(numCols * sizeof(Oid));
67  int i;
68  ExprState *expr;
69 
70  if (numCols == 0)
71  return NULL;
72 
73  /* lookup equality functions */
74  for (i = 0; i < numCols; i++)
75  eqFunctions[i] = get_opcode(eqOperators[i]);
76 
77  /* build actual expression */
78  expr = ExecBuildGroupingEqual(desc, desc, NULL, NULL,
79  numCols, keyColIdx, eqFunctions, collations,
80  parent);
81 
82  return expr;
83 }
ExprState * ExecBuildGroupingEqual(TupleDesc ldesc, TupleDesc rdesc, const TupleTableSlotOps *lops, const TupleTableSlotOps *rops, int numCols, const AttrNumber *keyColIdx, const Oid *eqfunctions, const Oid *collations, PlanState *parent)
Definition: execExpr.c:3331
unsigned int Oid
Definition: postgres_ext.h:31
RegProcedure get_opcode(Oid opno)
Definition: lsyscache.c:1092
void * palloc(Size size)
Definition: mcxt.c:949
int i

◆ FindTupleHashEntry()

TupleHashEntry FindTupleHashEntry ( TupleHashTable  hashtable,
TupleTableSlot slot,
ExprState eqcomp,
FmgrInfo hashfunctions 
)

Definition at line 358 of file execGrouping.c.

References TupleHashTableData::cur_eq_func, TupleHashTableData::hashtab, TupleHashTableData::in_hash_funcs, TupleHashTableData::inputslot, sort-test::key, MemoryContextSwitchTo(), and TupleHashTableData::tempcxt.

Referenced by ExecHashSubPlan().

361 {
362  TupleHashEntry entry;
363  MemoryContext oldContext;
365 
366  /* Need to run the hash functions in short-lived context */
367  oldContext = MemoryContextSwitchTo(hashtable->tempcxt);
368 
369  /* Set up data needed by hash and match functions */
370  hashtable->inputslot = slot;
371  hashtable->in_hash_funcs = hashfunctions;
372  hashtable->cur_eq_func = eqcomp;
373 
374  /* Search the hash table */
375  key = NULL; /* flag to reference inputslot */
376  entry = tuplehash_lookup(hashtable->hashtab, key);
377  MemoryContextSwitchTo(oldContext);
378 
379  return entry;
380 }
TupleTableSlot * inputslot
Definition: execnodes.h:704
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
ExprState * cur_eq_func
Definition: execnodes.h:706
FmgrInfo * in_hash_funcs
Definition: execnodes.h:705
tuplehash_hash * hashtab
Definition: execnodes.h:693
MemoryContext tempcxt
Definition: execnodes.h:700

◆ LookupTupleHashEntry()

TupleHashEntry LookupTupleHashEntry ( TupleHashTable  hashtable,
TupleTableSlot slot,
bool isnew 
)

Definition at line 300 of file execGrouping.c.

References TupleHashEntryData::additional, TupleHashTableData::cur_eq_func, ExecCopySlotMinimalTuple(), TupleHashEntryData::firstTuple, TupleHashTableData::hashtab, TupleHashTableData::in_hash_funcs, TupleHashTableData::inputslot, sort-test::key, MemoryContextSwitchTo(), TupleHashTableData::tab_eq_func, TupleHashTableData::tab_hash_funcs, TupleHashTableData::tablecxt, and TupleHashTableData::tempcxt.

Referenced by buildSubPlanHash(), ExecRecursiveUnion(), lookup_hash_entry(), and setop_fill_hash_table().

302 {
303  TupleHashEntryData *entry;
304  MemoryContext oldContext;
305  bool found;
307 
308  /* Need to run the hash functions in short-lived context */
309  oldContext = MemoryContextSwitchTo(hashtable->tempcxt);
310 
311  /* set up data needed by hash and match functions */
312  hashtable->inputslot = slot;
313  hashtable->in_hash_funcs = hashtable->tab_hash_funcs;
314  hashtable->cur_eq_func = hashtable->tab_eq_func;
315 
316  key = NULL; /* flag to reference inputslot */
317 
318  if (isnew)
319  {
320  entry = tuplehash_insert(hashtable->hashtab, key, &found);
321 
322  if (found)
323  {
324  /* found pre-existing entry */
325  *isnew = false;
326  }
327  else
328  {
329  /* created new entry */
330  *isnew = true;
331  /* zero caller data */
332  entry->additional = NULL;
333  MemoryContextSwitchTo(hashtable->tablecxt);
334  /* Copy the first tuple into the table context */
335  entry->firstTuple = ExecCopySlotMinimalTuple(slot);
336  }
337  }
338  else
339  {
340  entry = tuplehash_lookup(hashtable->hashtab, key);
341  }
342 
343  MemoryContextSwitchTo(oldContext);
344 
345  return entry;
346 }
TupleTableSlot * inputslot
Definition: execnodes.h:704
MinimalTuple firstTuple
Definition: execnodes.h:677
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
ExprState * tab_eq_func
Definition: execnodes.h:697
ExprState * cur_eq_func
Definition: execnodes.h:706
FmgrInfo * tab_hash_funcs
Definition: execnodes.h:696
FmgrInfo * in_hash_funcs
Definition: execnodes.h:705
static MinimalTuple ExecCopySlotMinimalTuple(TupleTableSlot *slot)
Definition: tuptable.h:464
MemoryContext tablecxt
Definition: execnodes.h:699
tuplehash_hash * hashtab
Definition: execnodes.h:693
MemoryContext tempcxt
Definition: execnodes.h:700

◆ ResetTupleHashTable()

void ResetTupleHashTable ( TupleHashTable  hashtable)

Definition at line 282 of file execGrouping.c.

References TupleHashTableData::hashtab.

Referenced by build_hash_table(), buildSubPlanHash(), ExecReScanRecursiveUnion(), and ExecReScanSetOp().

283 {
284  tuplehash_reset(hashtable->hashtab);
285 }
tuplehash_hash * hashtab
Definition: execnodes.h:693

◆ TupleHashTableHash()

static uint32 TupleHashTableHash ( struct tuplehash_hash *  tb,
const MinimalTuple  tuple 
)
static

Definition at line 396 of file execGrouping.c.

References DatumGetUInt32, ExecStoreMinimalTuple(), FunctionCall1Coll(), TupleHashTableData::hash_iv, i, TupleHashTableData::in_hash_funcs, TupleHashTableData::inputslot, TupleHashTableData::keyColIdx, murmurhash32(), TupleHashTableData::numCols, slot_getattr(), TupleHashTableData::tab_collations, TupleHashTableData::tab_hash_funcs, and TupleHashTableData::tableslot.

397 {
398  TupleHashTable hashtable = (TupleHashTable) tb->private_data;
399  int numCols = hashtable->numCols;
400  AttrNumber *keyColIdx = hashtable->keyColIdx;
401  uint32 hashkey = hashtable->hash_iv;
402  TupleTableSlot *slot;
403  FmgrInfo *hashfunctions;
404  int i;
405 
406  if (tuple == NULL)
407  {
408  /* Process the current input tuple for the table */
409  slot = hashtable->inputslot;
410  hashfunctions = hashtable->in_hash_funcs;
411  }
412  else
413  {
414  /*
415  * Process a tuple already stored in the table.
416  *
417  * (this case never actually occurs due to the way simplehash.h is
418  * used, as the hash-value is stored in the entries)
419  */
420  slot = hashtable->tableslot;
421  ExecStoreMinimalTuple(tuple, slot, false);
422  hashfunctions = hashtable->tab_hash_funcs;
423  }
424 
425  for (i = 0; i < numCols; i++)
426  {
427  AttrNumber att = keyColIdx[i];
428  Datum attr;
429  bool isNull;
430 
431  /* rotate hashkey left 1 bit at each step */
432  hashkey = (hashkey << 1) | ((hashkey & 0x80000000) ? 1 : 0);
433 
434  attr = slot_getattr(slot, att, &isNull);
435 
436  if (!isNull) /* treat nulls as having hash key 0 */
437  {
438  uint32 hkey;
439 
440  hkey = DatumGetUInt32(FunctionCall1Coll(&hashfunctions[i],
441  hashtable->tab_collations[i],
442  attr));
443  hashkey ^= hkey;
444  }
445  }
446 
447  /*
448  * The way hashes are combined above, among each other and with the IV,
449  * doesn't lead to good bit perturbation. As the IV's goal is to lead to
450  * achieve that, perform a round of hashing of the combined hash -
451  * resulting in near perfect perturbation.
452  */
453  return murmurhash32(hashkey);
454 }
#define DatumGetUInt32(X)
Definition: postgres.h:486
Definition: fmgr.h:56
TupleTableSlot * ExecStoreMinimalTuple(MinimalTuple mtup, TupleTableSlot *slot, bool shouldFree)
Definition: execTuples.c:1411
TupleTableSlot * inputslot
Definition: execnodes.h:704
AttrNumber * keyColIdx
Definition: execnodes.h:695
FmgrInfo * tab_hash_funcs
Definition: execnodes.h:696
FmgrInfo * in_hash_funcs
Definition: execnodes.h:705
struct TupleHashTableData * TupleHashTable
Definition: execnodes.h:673
unsigned int uint32
Definition: c.h:358
uintptr_t Datum
Definition: postgres.h:367
Datum FunctionCall1Coll(FmgrInfo *flinfo, Oid collation, Datum arg1)
Definition: fmgr.c:1130
static Datum slot_getattr(TupleTableSlot *slot, int attnum, bool *isnull)
Definition: tuptable.h:382
TupleTableSlot * tableslot
Definition: execnodes.h:702
int i
static uint32 murmurhash32(uint32 data)
Definition: hashutils.h:60
int16 AttrNumber
Definition: attnum.h:21

◆ TupleHashTableMatch()

static int TupleHashTableMatch ( struct tuplehash_hash *  tb,
const MinimalTuple  tuple1,
const MinimalTuple  tuple2 
)
static

Definition at line 462 of file execGrouping.c.

References Assert, TupleHashTableData::cur_eq_func, ExecQualAndReset(), ExecStoreMinimalTuple(), TupleHashTableData::exprcontext, TupleHashTableData::inputslot, and TupleHashTableData::tableslot.

463 {
464  TupleTableSlot *slot1;
465  TupleTableSlot *slot2;
466  TupleHashTable hashtable = (TupleHashTable) tb->private_data;
467  ExprContext *econtext = hashtable->exprcontext;
468 
469  /*
470  * We assume that simplehash.h will only ever call us with the first
471  * argument being an actual table entry, and the second argument being
472  * LookupTupleHashEntry's dummy TupleHashEntryData. The other direction
473  * could be supported too, but is not currently required.
474  */
475  Assert(tuple1 != NULL);
476  slot1 = hashtable->tableslot;
477  ExecStoreMinimalTuple(tuple1, slot1, false);
478  Assert(tuple2 == NULL);
479  slot2 = hashtable->inputslot;
480 
481  /* For crosstype comparisons, the inputslot must be first */
482  econtext->ecxt_innertuple = slot2;
483  econtext->ecxt_outertuple = slot1;
484  return !ExecQualAndReset(hashtable->cur_eq_func, econtext);
485 }
ExprContext * exprcontext
Definition: execnodes.h:708
TupleTableSlot * ExecStoreMinimalTuple(MinimalTuple mtup, TupleTableSlot *slot, bool shouldFree)
Definition: execTuples.c:1411
TupleTableSlot * inputslot
Definition: execnodes.h:704
ExprState * cur_eq_func
Definition: execnodes.h:706
struct TupleHashTableData * TupleHashTable
Definition: execnodes.h:673
static bool ExecQualAndReset(ExprState *state, ExprContext *econtext)
Definition: executor.h:392
#define Assert(condition)
Definition: c.h:732
TupleTableSlot * tableslot
Definition: execnodes.h:702