@@ -135,36 +135,43 @@ execTuplesHashPrepare(int numCols,
135
135
/*
136
136
* Construct an empty TupleHashTable
137
137
*
138
- * inputOps: slot ops for input hash values, or NULL if unknown or not fixed
139
- * numCols, keyColIdx: identify the tuple fields to use as lookup key
140
- * eqfunctions: equality comparison functions to use
141
- * hashfunctions: datatype-specific hashing functions to use
138
+ * parent: PlanState node that will own this hash table
139
+ * inputDesc: tuple descriptor for input tuples
140
+ * inputOps: slot ops for input tuples, or NULL if unknown or not fixed
141
+ * numCols: number of columns to be compared (length of next 4 arrays)
142
+ * keyColIdx: indexes of tuple columns to compare
143
+ * eqfuncoids: OIDs of equality comparison functions to use
144
+ * hashfunctions: FmgrInfos of datatype-specific hashing functions to use
145
+ * collations: collations to use in comparisons
142
146
* nbuckets: initial estimate of hashtable size
143
147
* additionalsize: size of data stored in ->additional
144
148
* metacxt: memory context for long-lived allocation, but not per-entry data
145
149
* tablecxt: memory context in which to store table entries
146
150
* tempcxt: short-lived context for evaluation hash and comparison functions
151
+ * use_variable_hash_iv: if true, adjust hash IV per-parallel-worker
147
152
*
148
- * The function arrays may be made with execTuplesHashPrepare(). Note they
153
+ * The hashfunctions array may be made with execTuplesHashPrepare(). Note they
149
154
* are not cross-type functions, but expect to see the table datatype(s)
150
155
* on both sides.
151
156
*
152
- * Note that keyColIdx, eqfunctions , and hashfunctions must be allocated in
153
- * storage that will live as long as the hashtable does.
157
+ * Note that the keyColIdx, hashfunctions , and collations arrays must be
158
+ * allocated in storage that will live as long as the hashtable does.
154
159
*/
155
160
TupleHashTable
156
- BuildTupleHashTableExt (PlanState * parent ,
157
- TupleDesc inputDesc ,
158
- const TupleTableSlotOps * inputOps ,
159
- int numCols , AttrNumber * keyColIdx ,
160
- const Oid * eqfuncoids ,
161
- FmgrInfo * hashfunctions ,
162
- Oid * collations ,
163
- long nbuckets , Size additionalsize ,
164
- MemoryContext metacxt ,
165
- MemoryContext tablecxt ,
166
- MemoryContext tempcxt ,
167
- bool use_variable_hash_iv )
161
+ BuildTupleHashTable (PlanState * parent ,
162
+ TupleDesc inputDesc ,
163
+ const TupleTableSlotOps * inputOps ,
164
+ int numCols ,
165
+ AttrNumber * keyColIdx ,
166
+ const Oid * eqfuncoids ,
167
+ FmgrInfo * hashfunctions ,
168
+ Oid * collations ,
169
+ long nbuckets ,
170
+ Size additionalsize ,
171
+ MemoryContext metacxt ,
172
+ MemoryContext tablecxt ,
173
+ MemoryContext tempcxt ,
174
+ bool use_variable_hash_iv )
168
175
{
169
176
TupleHashTable hashtable ;
170
177
Size entrysize = sizeof (TupleHashEntryData ) + additionalsize ;
@@ -216,14 +223,14 @@ BuildTupleHashTableExt(PlanState *parent,
216
223
& TTSOpsMinimalTuple );
217
224
218
225
/*
219
- * If the old reset interface is used (i.e. BuildTupleHashTable, rather
220
- * than BuildTupleHashTableExt), allowing JIT would lead to the generated
221
- * functions to a) live longer than the query b) be re-generated each time
222
- * the table is being reset. Therefore prevent JIT from being used in that
223
- * case, by not providing a parent node (which prevents accessing the
224
- * JitContext in the EState).
226
+ * If the caller fails to make the metacxt different from the tablecxt,
227
+ * allowing JIT would lead to the generated functions to a) live longer
228
+ * than the query or b) be re-generated each time the table is being
229
+ * reset. Therefore prevent JIT from being used in that case, by not
230
+ * providing a parent node (which prevents accessing the JitContext in the
231
+ * EState).
225
232
*/
226
- allow_jit = metacxt != tablecxt ;
233
+ allow_jit = ( metacxt != tablecxt ) ;
227
234
228
235
/* build hash ExprState for all columns */
229
236
hashtable -> tab_hash_expr = ExecBuildHash32FromAttrs (inputDesc ,
@@ -256,41 +263,9 @@ BuildTupleHashTableExt(PlanState *parent,
256
263
return hashtable ;
257
264
}
258
265
259
- /*
260
- * BuildTupleHashTable is a backwards-compatibility wrapper for
261
- * BuildTupleHashTableExt(), that allocates the hashtable's metadata in
262
- * tablecxt. Note that hashtables created this way cannot be reset leak-free
263
- * with ResetTupleHashTable().
264
- */
265
- TupleHashTable
266
- BuildTupleHashTable (PlanState * parent ,
267
- TupleDesc inputDesc ,
268
- int numCols , AttrNumber * keyColIdx ,
269
- const Oid * eqfuncoids ,
270
- FmgrInfo * hashfunctions ,
271
- Oid * collations ,
272
- long nbuckets , Size additionalsize ,
273
- MemoryContext tablecxt ,
274
- MemoryContext tempcxt ,
275
- bool use_variable_hash_iv )
276
- {
277
- return BuildTupleHashTableExt (parent ,
278
- inputDesc ,
279
- NULL ,
280
- numCols , keyColIdx ,
281
- eqfuncoids ,
282
- hashfunctions ,
283
- collations ,
284
- nbuckets , additionalsize ,
285
- tablecxt ,
286
- tablecxt ,
287
- tempcxt ,
288
- use_variable_hash_iv );
289
- }
290
-
291
266
/*
292
267
* Reset contents of the hashtable to be empty, preserving all the non-content
293
- * state. Note that the tablecxt passed to BuildTupleHashTableExt () should
268
+ * state. Note that the tablecxt passed to BuildTupleHashTable () should
294
269
* also be reset, otherwise there will be leaks.
295
270
*/
296
271
void
0 commit comments