PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
execGrouping.c File Reference
#include "postgres.h"
#include "access/parallel.h"
#include "common/hashfn.h"
#include "executor/executor.h"
#include "miscadmin.h"
#include "utils/lsyscache.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_internal(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 int TupleHashTableMatch (struct tuplehash_hash *tb, const MinimalTuple tuple1, const MinimalTuple tuple2)
 
static uint32 TupleHashTableHash_internal (struct tuplehash_hash *tb, const MinimalTuple tuple)
 
static TupleHashEntry LookupTupleHashEntry_internal (TupleHashTable hashtable, TupleTableSlot *slot, bool *isnew, uint32 hash)
 
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 BuildTupleHashTable (PlanState *parent, TupleDesc inputDesc, const TupleTableSlotOps *inputOps, 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)
 
void ResetTupleHashTable (TupleHashTable hashtable)
 
TupleHashEntry LookupTupleHashEntry (TupleHashTable hashtable, TupleTableSlot *slot, bool *isnew, uint32 *hash)
 
uint32 TupleHashTableHash (TupleHashTable hashtable, TupleTableSlot *slot)
 
TupleHashEntry LookupTupleHashEntryHash (TupleHashTable hashtable, TupleTableSlot *slot, bool *isnew, uint32 hash)
 
TupleHashEntry FindTupleHashEntry (TupleHashTable hashtable, TupleTableSlot *slot, ExprState *eqcomp, ExprState *hashexpr)
 

Macro Definition Documentation

◆ SH_DEFINE

#define SH_DEFINE

Definition at line 44 of file execGrouping.c.

◆ SH_ELEMENT_TYPE

#define SH_ELEMENT_TYPE   TupleHashEntryData

Definition at line 36 of file execGrouping.c.

◆ SH_EQUAL

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

Definition at line 40 of file execGrouping.c.

◆ SH_GET_HASH

#define SH_GET_HASH (   tb,
  a 
)    a->hash

Definition at line 43 of file execGrouping.c.

◆ SH_HASH_KEY

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

Definition at line 39 of file execGrouping.c.

◆ SH_KEY

#define SH_KEY   firstTuple

Definition at line 38 of file execGrouping.c.

◆ SH_KEY_TYPE

#define SH_KEY_TYPE   MinimalTuple

Definition at line 37 of file execGrouping.c.

◆ SH_PREFIX

#define SH_PREFIX   tuplehash

Definition at line 35 of file execGrouping.c.

◆ SH_SCOPE

#define SH_SCOPE   extern

Definition at line 41 of file execGrouping.c.

◆ SH_STORE_HASH

#define SH_STORE_HASH

Definition at line 42 of file execGrouping.c.

Function Documentation

◆ BuildTupleHashTable()

TupleHashTable BuildTupleHashTable ( PlanState parent,
TupleDesc  inputDesc,
const TupleTableSlotOps inputOps,
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 161 of file execGrouping.c.

175{
176 TupleHashTable hashtable;
177 Size entrysize;
178 Size hash_mem_limit;
179 MemoryContext oldcontext;
180 bool allow_jit;
181 uint32 hash_iv = 0;
182
183 Assert(nbuckets > 0);
184 additionalsize = MAXALIGN(additionalsize);
185 entrysize = sizeof(TupleHashEntryData) + additionalsize;
186
187 /* Limit initial table size request to not more than hash_mem */
188 hash_mem_limit = get_hash_memory_limit() / entrysize;
189 if (nbuckets > hash_mem_limit)
190 nbuckets = hash_mem_limit;
191
192 oldcontext = MemoryContextSwitchTo(metacxt);
193
194 hashtable = (TupleHashTable) palloc(sizeof(TupleHashTableData));
195
196 hashtable->numCols = numCols;
197 hashtable->keyColIdx = keyColIdx;
198 hashtable->tab_collations = collations;
199 hashtable->tablecxt = tablecxt;
200 hashtable->tempcxt = tempcxt;
201 hashtable->additionalsize = additionalsize;
202 hashtable->tableslot = NULL; /* will be made on first lookup */
203 hashtable->inputslot = NULL;
204 hashtable->in_hash_expr = NULL;
205 hashtable->cur_eq_func = NULL;
206
207 /*
208 * If parallelism is in use, even if the leader backend is performing the
209 * scan itself, we don't want to create the hashtable exactly the same way
210 * in all workers. As hashtables are iterated over in keyspace-order,
211 * doing so in all processes in the same way is likely to lead to
212 * "unbalanced" hashtables when the table size initially is
213 * underestimated.
214 */
215 if (use_variable_hash_iv)
217
218 hashtable->hashtab = tuplehash_create(metacxt, nbuckets, hashtable);
219
220 /*
221 * We copy the input tuple descriptor just for safety --- we assume all
222 * input tuples will have equivalent descriptors.
223 */
226
227 /*
228 * If the caller fails to make the metacxt different from the tablecxt,
229 * allowing JIT would lead to the generated functions to a) live longer
230 * than the query or b) be re-generated each time the table is being
231 * reset. Therefore prevent JIT from being used in that case, by not
232 * providing a parent node (which prevents accessing the JitContext in the
233 * EState).
234 */
235 allow_jit = (metacxt != tablecxt);
236
237 /* build hash ExprState for all columns */
238 hashtable->tab_hash_expr = ExecBuildHash32FromAttrs(inputDesc,
239 inputOps,
240 hashfunctions,
241 collations,
242 numCols,
243 keyColIdx,
244 allow_jit ? parent : NULL,
245 hash_iv);
246
247 /* build comparator for all columns */
248 hashtable->tab_eq_func = ExecBuildGroupingEqual(inputDesc, inputDesc,
249 inputOps,
251 numCols,
252 keyColIdx, eqfuncoids, collations,
253 allow_jit ? parent : NULL);
254
255 /*
256 * While not pretty, it's ok to not shut down this context, but instead
257 * rely on the containing memory context being reset, as
258 * ExecBuildGroupingEqual() only builds a very simple expression calling
259 * functions (i.e. nothing that'd employ RegisterExprContextCallback()).
260 */
262
263 MemoryContextSwitchTo(oldcontext);
264
265 return hashtable;
266}
int ParallelWorkerNumber
Definition: parallel.c:115
#define MAXALIGN(LEN)
Definition: c.h:782
uint32_t uint32
Definition: c.h:502
size_t Size
Definition: c.h:576
ExprState * ExecBuildHash32FromAttrs(TupleDesc desc, const TupleTableSlotOps *ops, FmgrInfo *hashfunctions, Oid *collations, int numCols, AttrNumber *keyColIdx, PlanState *parent, uint32 init_value)
Definition: execExpr.c:4141
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:4465
TupleTableSlot * MakeSingleTupleTableSlot(TupleDesc tupdesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1427
const TupleTableSlotOps TTSOpsMinimalTuple
Definition: execTuples.c:86
ExprContext * CreateStandaloneExprContext(void)
Definition: execUtils.c:358
struct TupleHashTableData * TupleHashTable
Definition: execnodes.h:844
struct TupleHashEntryData TupleHashEntryData
static uint32 murmurhash32(uint32 data)
Definition: hashfn.h:92
Assert(PointerIsAligned(start, uint64))
void * palloc(Size size)
Definition: mcxt.c:1943
size_t get_hash_memory_limit(void)
Definition: nodeHash.c:3616
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:124
AttrNumber * keyColIdx
Definition: execnodes.h:865
tuplehash_hash * hashtab
Definition: execnodes.h:863
ExprState * in_hash_expr
Definition: execnodes.h:875
ExprState * tab_hash_expr
Definition: execnodes.h:866
MemoryContext tempcxt
Definition: execnodes.h:870
ExprState * tab_eq_func
Definition: execnodes.h:867
TupleTableSlot * tableslot
Definition: execnodes.h:872
ExprContext * exprcontext
Definition: execnodes.h:877
MemoryContext tablecxt
Definition: execnodes.h:869
TupleTableSlot * inputslot
Definition: execnodes.h:874
ExprState * cur_eq_func
Definition: execnodes.h:876
TupleDesc CreateTupleDescCopy(TupleDesc tupdesc)
Definition: tupdesc.c:245

References TupleHashTableData::additionalsize, Assert(), CreateStandaloneExprContext(), CreateTupleDescCopy(), TupleHashTableData::cur_eq_func, ExecBuildGroupingEqual(), ExecBuildHash32FromAttrs(), TupleHashTableData::exprcontext, get_hash_memory_limit(), TupleHashTableData::hashtab, TupleHashTableData::in_hash_expr, TupleHashTableData::inputslot, TupleHashTableData::keyColIdx, MakeSingleTupleTableSlot(), MAXALIGN, MemoryContextSwitchTo(), murmurhash32(), TupleHashTableData::numCols, palloc(), ParallelWorkerNumber, TupleHashTableData::tab_collations, TupleHashTableData::tab_eq_func, TupleHashTableData::tab_hash_expr, TupleHashTableData::tablecxt, TupleHashTableData::tableslot, TupleHashTableData::tempcxt, and TTSOpsMinimalTuple.

Referenced by build_hash_table(), and buildSubPlanHash().

◆ execTuplesHashPrepare()

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

Definition at line 97 of file execGrouping.c.

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

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

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

◆ execTuplesMatchPrepare()

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

Definition at line 58 of file execGrouping.c.

64{
65 Oid *eqFunctions;
66 int i;
67 ExprState *expr;
68
69 if (numCols == 0)
70 return NULL;
71
72 eqFunctions = (Oid *) palloc(numCols * sizeof(Oid));
73
74 /* lookup equality functions */
75 for (i = 0; i < numCols; i++)
76 eqFunctions[i] = get_opcode(eqOperators[i]);
77
78 /* build actual expression */
79 expr = ExecBuildGroupingEqual(desc, desc, NULL, NULL,
80 numCols, keyColIdx, eqFunctions, collations,
81 parent);
82
83 return expr;
84}

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

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

◆ FindTupleHashEntry()

TupleHashEntry FindTupleHashEntry ( TupleHashTable  hashtable,
TupleTableSlot slot,
ExprState eqcomp,
ExprState hashexpr 
)

Definition at line 382 of file execGrouping.c.

385{
386 TupleHashEntry entry;
387 MemoryContext oldContext;
389
390 /* Need to run the hash functions in short-lived context */
391 oldContext = MemoryContextSwitchTo(hashtable->tempcxt);
392
393 /* Set up data needed by hash and match functions */
394 hashtable->inputslot = slot;
395 hashtable->in_hash_expr = hashexpr;
396 hashtable->cur_eq_func = eqcomp;
397
398 /* Search the hash table */
399 key = NULL; /* flag to reference inputslot */
400 entry = tuplehash_lookup(hashtable->hashtab, key);
401 MemoryContextSwitchTo(oldContext);
402
403 return entry;
404}

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

Referenced by ExecHashSubPlan().

◆ LookupTupleHashEntry()

TupleHashEntry LookupTupleHashEntry ( TupleHashTable  hashtable,
TupleTableSlot slot,
bool *  isnew,
uint32 hash 
)

Definition at line 295 of file execGrouping.c.

297{
298 TupleHashEntry entry;
299 MemoryContext oldContext;
300 uint32 local_hash;
301
302 /* Need to run the hash functions in short-lived context */
303 oldContext = MemoryContextSwitchTo(hashtable->tempcxt);
304
305 /* set up data needed by hash and match functions */
306 hashtable->inputslot = slot;
307 hashtable->in_hash_expr = hashtable->tab_hash_expr;
308 hashtable->cur_eq_func = hashtable->tab_eq_func;
309
310 local_hash = TupleHashTableHash_internal(hashtable->hashtab, NULL);
311 entry = LookupTupleHashEntry_internal(hashtable, slot, isnew, local_hash);
312
313 if (hash != NULL)
314 *hash = local_hash;
315
316 Assert(entry == NULL || entry->hash == local_hash);
317
318 MemoryContextSwitchTo(oldContext);
319
320 return entry;
321}
static uint32 TupleHashTableHash_internal(struct tuplehash_hash *tb, const MinimalTuple tuple)
Definition: execGrouping.c:415
static TupleHashEntry LookupTupleHashEntry_internal(TupleHashTable hashtable, TupleTableSlot *slot, bool *isnew, uint32 hash)
Definition: execGrouping.c:463
static unsigned hash(unsigned *uv, int n)
Definition: rege_dfa.c:715

References Assert(), TupleHashTableData::cur_eq_func, hash(), TupleHashEntryData::hash, TupleHashTableData::hashtab, TupleHashTableData::in_hash_expr, TupleHashTableData::inputslot, LookupTupleHashEntry_internal(), MemoryContextSwitchTo(), TupleHashTableData::tab_eq_func, TupleHashTableData::tab_hash_expr, TupleHashTableData::tempcxt, and TupleHashTableHash_internal().

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

◆ LookupTupleHashEntry_internal()

static TupleHashEntry LookupTupleHashEntry_internal ( TupleHashTable  hashtable,
TupleTableSlot slot,
bool *  isnew,
uint32  hash 
)
inlinestatic

Definition at line 463 of file execGrouping.c.

465{
466 TupleHashEntryData *entry;
467 bool found;
469
470 key = NULL; /* flag to reference inputslot */
471
472 if (isnew)
473 {
474 entry = tuplehash_insert_hash(hashtable->hashtab, key, hash, &found);
475
476 if (found)
477 {
478 /* found pre-existing entry */
479 *isnew = false;
480 }
481 else
482 {
483 /* created new entry */
484 *isnew = true;
485
487
488 /*
489 * Copy the first tuple into the table context, and request
490 * additionalsize extra bytes before the allocation.
491 *
492 * The caller can get a pointer to the additional data with
493 * TupleHashEntryGetAdditional(), and store arbitrary data there.
494 * Placing both the tuple and additional data in the same
495 * allocation avoids the need to store an extra pointer in
496 * TupleHashEntryData or allocate an additional chunk.
497 */
499 hashtable->additionalsize);
500 }
501 }
502 else
503 {
504 entry = tuplehash_lookup_hash(hashtable->hashtab, key, hash);
505 }
506
507 return entry;
508}
MinimalTuple firstTuple
Definition: execnodes.h:848
static MinimalTuple ExecCopySlotMinimalTupleExtra(TupleTableSlot *slot, Size extra)
Definition: tuptable.h:508

References TupleHashTableData::additionalsize, ExecCopySlotMinimalTupleExtra(), TupleHashEntryData::firstTuple, hash(), TupleHashTableData::hashtab, sort-test::key, MemoryContextSwitchTo(), and TupleHashTableData::tablecxt.

Referenced by LookupTupleHashEntry(), and LookupTupleHashEntryHash().

◆ LookupTupleHashEntryHash()

TupleHashEntry LookupTupleHashEntryHash ( TupleHashTable  hashtable,
TupleTableSlot slot,
bool *  isnew,
uint32  hash 
)

Definition at line 350 of file execGrouping.c.

352{
353 TupleHashEntry entry;
354 MemoryContext oldContext;
355
356 /* Need to run the hash functions in short-lived context */
357 oldContext = MemoryContextSwitchTo(hashtable->tempcxt);
358
359 /* set up data needed by hash and match functions */
360 hashtable->inputslot = slot;
361 hashtable->in_hash_expr = hashtable->tab_hash_expr;
362 hashtable->cur_eq_func = hashtable->tab_eq_func;
363
364 entry = LookupTupleHashEntry_internal(hashtable, slot, isnew, hash);
365 Assert(entry == NULL || entry->hash == hash);
366
367 MemoryContextSwitchTo(oldContext);
368
369 return entry;
370}

References Assert(), TupleHashTableData::cur_eq_func, hash(), TupleHashEntryData::hash, TupleHashTableData::in_hash_expr, TupleHashTableData::inputslot, LookupTupleHashEntry_internal(), MemoryContextSwitchTo(), TupleHashTableData::tab_eq_func, TupleHashTableData::tab_hash_expr, and TupleHashTableData::tempcxt.

Referenced by agg_refill_hash_table().

◆ ResetTupleHashTable()

void ResetTupleHashTable ( TupleHashTable  hashtable)

Definition at line 274 of file execGrouping.c.

275{
276 tuplehash_reset(hashtable->hashtab);
277}

References TupleHashTableData::hashtab.

Referenced by agg_refill_hash_table(), build_hash_tables(), buildSubPlanHash(), ExecReScanRecursiveUnion(), and ExecReScanSetOp().

◆ TupleHashTableHash()

uint32 TupleHashTableHash ( TupleHashTable  hashtable,
TupleTableSlot slot 
)

Definition at line 327 of file execGrouping.c.

328{
329 MemoryContext oldContext;
330 uint32 hash;
331
332 hashtable->inputslot = slot;
333 hashtable->in_hash_expr = hashtable->tab_hash_expr;
334
335 /* Need to run the hash functions in short-lived context */
336 oldContext = MemoryContextSwitchTo(hashtable->tempcxt);
337
338 hash = TupleHashTableHash_internal(hashtable->hashtab, NULL);
339
340 MemoryContextSwitchTo(oldContext);
341
342 return hash;
343}

References hash(), TupleHashTableData::hashtab, TupleHashTableData::in_hash_expr, TupleHashTableData::inputslot, MemoryContextSwitchTo(), TupleHashTableData::tab_hash_expr, TupleHashTableData::tempcxt, and TupleHashTableHash_internal().

◆ TupleHashTableHash_internal()

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

Definition at line 415 of file execGrouping.c.

417{
418 TupleHashTable hashtable = (TupleHashTable) tb->private_data;
419 uint32 hashkey;
420 TupleTableSlot *slot;
421 bool isnull;
422
423 if (tuple == NULL)
424 {
425 /* Process the current input tuple for the table */
426 hashtable->exprcontext->ecxt_innertuple = hashtable->inputslot;
427 hashkey = DatumGetUInt32(ExecEvalExpr(hashtable->in_hash_expr,
428 hashtable->exprcontext,
429 &isnull));
430 }
431 else
432 {
433 /*
434 * Process a tuple already stored in the table.
435 *
436 * (this case never actually occurs due to the way simplehash.h is
437 * used, as the hash-value is stored in the entries)
438 */
439 slot = hashtable->exprcontext->ecxt_innertuple = hashtable->tableslot;
440 ExecStoreMinimalTuple(tuple, slot, false);
441 hashkey = DatumGetUInt32(ExecEvalExpr(hashtable->tab_hash_expr,
442 hashtable->exprcontext,
443 &isnull));
444 }
445
446 /*
447 * The hashing done above, even with an initial value, doesn't tend to
448 * result in good hash perturbation. Running the value produced above
449 * through murmurhash32 leads to near perfect hash perturbation.
450 */
451 return murmurhash32(hashkey);
452}
TupleTableSlot * ExecStoreMinimalTuple(MinimalTuple mtup, TupleTableSlot *slot, bool shouldFree)
Definition: execTuples.c:1635
static Datum ExecEvalExpr(ExprState *state, ExprContext *econtext, bool *isNull)
Definition: executor.h:415
if(TABLE==NULL||TABLE_index==NULL)
Definition: isn.c:81
static uint32 DatumGetUInt32(Datum X)
Definition: postgres.h:227
TupleTableSlot * ecxt_innertuple
Definition: execnodes.h:270

References DatumGetUInt32(), ExprContext::ecxt_innertuple, ExecEvalExpr(), ExecStoreMinimalTuple(), TupleHashTableData::exprcontext, if(), TupleHashTableData::in_hash_expr, TupleHashTableData::inputslot, murmurhash32(), TupleHashTableData::tab_hash_expr, and TupleHashTableData::tableslot.

Referenced by LookupTupleHashEntry(), and TupleHashTableHash().

◆ TupleHashTableMatch()

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

Definition at line 514 of file execGrouping.c.

515{
516 TupleTableSlot *slot1;
517 TupleTableSlot *slot2;
518 TupleHashTable hashtable = (TupleHashTable) tb->private_data;
519 ExprContext *econtext = hashtable->exprcontext;
520
521 /*
522 * We assume that simplehash.h will only ever call us with the first
523 * argument being an actual table entry, and the second argument being
524 * LookupTupleHashEntry's dummy TupleHashEntryData. The other direction
525 * could be supported too, but is not currently required.
526 */
527 Assert(tuple1 != NULL);
528 slot1 = hashtable->tableslot;
529 ExecStoreMinimalTuple(tuple1, slot1, false);
530 Assert(tuple2 == NULL);
531 slot2 = hashtable->inputslot;
532
533 /* For crosstype comparisons, the inputslot must be first */
534 econtext->ecxt_innertuple = slot2;
535 econtext->ecxt_outertuple = slot1;
536 return !ExecQualAndReset(hashtable->cur_eq_func, econtext);
537}
static bool ExecQualAndReset(ExprState *state, ExprContext *econtext)
Definition: executor.h:568

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