Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite0a2721

Browse files
committed
Get rid of old version of BuildTupleHashTable().
It was reasonable to preserve the old API of BuildTupleHashTable()in the back branches, but in HEAD we should actively discourage useof that version. There are no remaining callers in core, so justget rid of it. Then rename BuildTupleHashTableExt() back toBuildTupleHashTable().While at it, fix up the miserably-poorly-maintained header commentfor BuildTupleHashTable[Ext]. It looks like more than one patch inthis area has had the opinion that updating comments is beneath them.Discussion:https://postgr.es/m/538343.1734646986@sss.pgh.pa.us
1 parentf0b9000 commite0a2721

File tree

6 files changed

+115
-146
lines changed

6 files changed

+115
-146
lines changed

‎src/backend/executor/execGrouping.c

Lines changed: 34 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -135,36 +135,43 @@ execTuplesHashPrepare(int numCols,
135135
/*
136136
* Construct an empty TupleHashTable
137137
*
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
142146
*nbuckets: initial estimate of hashtable size
143147
*additionalsize: size of data stored in ->additional
144148
*metacxt: memory context for long-lived allocation, but not per-entry data
145149
*tablecxt: memory context in which to store table entries
146150
*tempcxt: short-lived context for evaluation hash and comparison functions
151+
*use_variable_hash_iv: if true, adjust hash IV per-parallel-worker
147152
*
148-
* Thefunction arrays may be made with execTuplesHashPrepare(). Note they
153+
* Thehashfunctions array may be made with execTuplesHashPrepare(). Note they
149154
* are not cross-type functions, but expect to see the table datatype(s)
150155
* on both sides.
151156
*
152-
* Note that keyColIdx,eqfunctions, andhashfunctionsmust be allocated in
153-
* storage that will live as long as the hashtable does.
157+
* Note thatthekeyColIdx,hashfunctions, andcollations arraysmust be
158+
*allocated instorage that will live as long as the hashtable does.
154159
*/
155160
TupleHashTable
156-
BuildTupleHashTableExt(PlanState*parent,
157-
TupleDescinputDesc,
158-
constTupleTableSlotOps*inputOps,
159-
intnumCols,AttrNumber*keyColIdx,
160-
constOid*eqfuncoids,
161-
FmgrInfo*hashfunctions,
162-
Oid*collations,
163-
longnbuckets,Sizeadditionalsize,
164-
MemoryContextmetacxt,
165-
MemoryContexttablecxt,
166-
MemoryContexttempcxt,
167-
booluse_variable_hash_iv)
161+
BuildTupleHashTable(PlanState*parent,
162+
TupleDescinputDesc,
163+
constTupleTableSlotOps*inputOps,
164+
intnumCols,
165+
AttrNumber*keyColIdx,
166+
constOid*eqfuncoids,
167+
FmgrInfo*hashfunctions,
168+
Oid*collations,
169+
longnbuckets,
170+
Sizeadditionalsize,
171+
MemoryContextmetacxt,
172+
MemoryContexttablecxt,
173+
MemoryContexttempcxt,
174+
booluse_variable_hash_iv)
168175
{
169176
TupleHashTablehashtable;
170177
Sizeentrysize=sizeof(TupleHashEntryData)+additionalsize;
@@ -216,14 +223,14 @@ BuildTupleHashTableExt(PlanState *parent,
216223
&TTSOpsMinimalTuple);
217224

218225
/*
219-
* If theold reset interface is used (i.e. BuildTupleHashTable, rather
220-
*than BuildTupleHashTableExt),allowing JIT would lead to the generated
221-
*functions to a) live longerthan the query b) be re-generated each time
222-
*the table is beingreset. Therefore prevent JIT from being used in that
223-
*case, by notproviding a parent node (which prevents accessing the
224-
*JitContext in theEState).
226+
* If thecaller 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 queryorb) 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).
225232
*/
226-
allow_jit=metacxt!=tablecxt;
233+
allow_jit=(metacxt!=tablecxt);
227234

228235
/* build hash ExprState for all columns */
229236
hashtable->tab_hash_expr=ExecBuildHash32FromAttrs(inputDesc,
@@ -256,41 +263,9 @@ BuildTupleHashTableExt(PlanState *parent,
256263
returnhashtable;
257264
}
258265

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-
TupleDescinputDesc,
268-
intnumCols,AttrNumber*keyColIdx,
269-
constOid*eqfuncoids,
270-
FmgrInfo*hashfunctions,
271-
Oid*collations,
272-
longnbuckets,Sizeadditionalsize,
273-
MemoryContexttablecxt,
274-
MemoryContexttempcxt,
275-
booluse_variable_hash_iv)
276-
{
277-
returnBuildTupleHashTableExt(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-
291266
/*
292267
* Reset contents of the hashtable to be empty, preserving all the non-content
293-
* state. Note that the tablecxt passed toBuildTupleHashTableExt() should
268+
* state. Note that the tablecxt passed toBuildTupleHashTable() should
294269
* also be reset, otherwise there will be leaks.
295270
*/
296271
void

‎src/backend/executor/nodeAgg.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,20 +1518,20 @@ build_hash_table(AggState *aggstate, int setno, long nbuckets)
15181518
*/
15191519
additionalsize=aggstate->numtrans*sizeof(AggStatePerGroupData);
15201520

1521-
perhash->hashtable=BuildTupleHashTableExt(&aggstate->ss.ps,
1522-
perhash->hashslot->tts_tupleDescriptor,
1523-
perhash->hashslot->tts_ops,
1524-
perhash->numCols,
1525-
perhash->hashGrpColIdxHash,
1526-
perhash->eqfuncoids,
1527-
perhash->hashfunctions,
1528-
perhash->aggnode->grpCollations,
1529-
nbuckets,
1530-
additionalsize,
1531-
metacxt,
1532-
hashcxt,
1533-
tmpcxt,
1534-
DO_AGGSPLIT_SKIPFINAL(aggstate->aggsplit));
1521+
perhash->hashtable=BuildTupleHashTable(&aggstate->ss.ps,
1522+
perhash->hashslot->tts_tupleDescriptor,
1523+
perhash->hashslot->tts_ops,
1524+
perhash->numCols,
1525+
perhash->hashGrpColIdxHash,
1526+
perhash->eqfuncoids,
1527+
perhash->hashfunctions,
1528+
perhash->aggnode->grpCollations,
1529+
nbuckets,
1530+
additionalsize,
1531+
metacxt,
1532+
hashcxt,
1533+
tmpcxt,
1534+
DO_AGGSPLIT_SKIPFINAL(aggstate->aggsplit));
15351535
}
15361536

15371537
/*

‎src/backend/executor/nodeRecursiveunion.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,23 @@ build_hash_table(RecursiveUnionState *rustate)
3939

4040
/*
4141
* If both child plans deliver the same fixed tuple slot type, we can tell
42-
*BuildTupleHashTableExt to expect that slot type as input. Otherwise,
42+
*BuildTupleHashTable to expect that slot type as input. Otherwise,
4343
* we'll pass NULL denoting that any slot type is possible.
4444
*/
45-
rustate->hashtable=BuildTupleHashTableExt(&rustate->ps,
46-
desc,
47-
ExecGetCommonChildSlotOps(&rustate->ps),
48-
node->numCols,
49-
node->dupColIdx,
50-
rustate->eqfuncoids,
51-
rustate->hashfunctions,
52-
node->dupCollations,
53-
node->numGroups,
54-
0,
55-
rustate->ps.state->es_query_cxt,
56-
rustate->tableContext,
57-
rustate->tempContext,
58-
false);
45+
rustate->hashtable=BuildTupleHashTable(&rustate->ps,
46+
desc,
47+
ExecGetCommonChildSlotOps(&rustate->ps),
48+
node->numCols,
49+
node->dupColIdx,
50+
rustate->eqfuncoids,
51+
rustate->hashfunctions,
52+
node->dupCollations,
53+
node->numGroups,
54+
0,
55+
rustate->ps.state->es_query_cxt,
56+
rustate->tableContext,
57+
rustate->tempContext,
58+
false);
5959
}
6060

6161

‎src/backend/executor/nodeSetOp.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,23 +92,23 @@ build_hash_table(SetOpState *setopstate)
9292

9393
/*
9494
* If both child plans deliver the same fixed tuple slot type, we can tell
95-
*BuildTupleHashTableExt to expect that slot type as input. Otherwise,
95+
*BuildTupleHashTable to expect that slot type as input. Otherwise,
9696
* we'll pass NULL denoting that any slot type is possible.
9797
*/
98-
setopstate->hashtable=BuildTupleHashTableExt(&setopstate->ps,
99-
desc,
100-
ExecGetCommonChildSlotOps(&setopstate->ps),
101-
node->numCols,
102-
node->cmpColIdx,
103-
setopstate->eqfuncoids,
104-
setopstate->hashfunctions,
105-
node->cmpCollations,
106-
node->numGroups,
107-
0,
108-
setopstate->ps.state->es_query_cxt,
109-
setopstate->tableContext,
110-
econtext->ecxt_per_tuple_memory,
111-
false);
98+
setopstate->hashtable=BuildTupleHashTable(&setopstate->ps,
99+
desc,
100+
ExecGetCommonChildSlotOps(&setopstate->ps),
101+
node->numCols,
102+
node->cmpColIdx,
103+
setopstate->eqfuncoids,
104+
setopstate->hashfunctions,
105+
node->cmpCollations,
106+
node->numGroups,
107+
0,
108+
setopstate->ps.state->es_query_cxt,
109+
setopstate->tableContext,
110+
econtext->ecxt_per_tuple_memory,
111+
false);
112112
}
113113

114114
/*

‎src/backend/executor/nodeSubplan.c

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ buildSubPlanHash(SubPlanState *node, ExprContext *econtext)
523523
* Because the input slot for each hash table is always the slot resulting
524524
* from an ExecProject(), we can use TTSOpsVirtual for the input ops. This
525525
* saves a needless fetch inner op step for the hashing ExprState created
526-
* inBuildTupleHashTableExt().
526+
* inBuildTupleHashTable().
527527
*/
528528
MemoryContextReset(node->hashtablecxt);
529529
node->havehashrows= false;
@@ -536,20 +536,20 @@ buildSubPlanHash(SubPlanState *node, ExprContext *econtext)
536536
if (node->hashtable)
537537
ResetTupleHashTable(node->hashtable);
538538
else
539-
node->hashtable=BuildTupleHashTableExt(node->parent,
540-
node->descRight,
541-
&TTSOpsVirtual,
542-
ncols,
543-
node->keyColIdx,
544-
node->tab_eq_funcoids,
545-
node->tab_hash_funcs,
546-
node->tab_collations,
547-
nbuckets,
548-
0,
549-
node->planstate->state->es_query_cxt,
550-
node->hashtablecxt,
551-
node->hashtempcxt,
552-
false);
539+
node->hashtable=BuildTupleHashTable(node->parent,
540+
node->descRight,
541+
&TTSOpsVirtual,
542+
ncols,
543+
node->keyColIdx,
544+
node->tab_eq_funcoids,
545+
node->tab_hash_funcs,
546+
node->tab_collations,
547+
nbuckets,
548+
0,
549+
node->planstate->state->es_query_cxt,
550+
node->hashtablecxt,
551+
node->hashtempcxt,
552+
false);
553553

554554
if (!subplan->unknownEqFalse)
555555
{
@@ -565,20 +565,20 @@ buildSubPlanHash(SubPlanState *node, ExprContext *econtext)
565565
if (node->hashnulls)
566566
ResetTupleHashTable(node->hashnulls);
567567
else
568-
node->hashnulls=BuildTupleHashTableExt(node->parent,
569-
node->descRight,
570-
&TTSOpsVirtual,
571-
ncols,
572-
node->keyColIdx,
573-
node->tab_eq_funcoids,
574-
node->tab_hash_funcs,
575-
node->tab_collations,
576-
nbuckets,
577-
0,
578-
node->planstate->state->es_query_cxt,
579-
node->hashtablecxt,
580-
node->hashtempcxt,
581-
false);
568+
node->hashnulls=BuildTupleHashTable(node->parent,
569+
node->descRight,
570+
&TTSOpsVirtual,
571+
ncols,
572+
node->keyColIdx,
573+
node->tab_eq_funcoids,
574+
node->tab_hash_funcs,
575+
node->tab_collations,
576+
nbuckets,
577+
0,
578+
node->planstate->state->es_query_cxt,
579+
node->hashtablecxt,
580+
node->hashtempcxt,
581+
false);
582582
}
583583
else
584584
node->hashnulls=NULL;

‎src/include/executor/executor.h

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -131,24 +131,18 @@ extern void execTuplesHashPrepare(int numCols,
131131
FmgrInfo**hashFunctions);
132132
externTupleHashTableBuildTupleHashTable(PlanState*parent,
133133
TupleDescinputDesc,
134-
intnumCols,AttrNumber*keyColIdx,
134+
constTupleTableSlotOps*inputOps,
135+
intnumCols,
136+
AttrNumber*keyColIdx,
135137
constOid*eqfuncoids,
136138
FmgrInfo*hashfunctions,
137139
Oid*collations,
138-
longnbuckets,Sizeadditionalsize,
140+
longnbuckets,
141+
Sizeadditionalsize,
142+
MemoryContextmetacxt,
139143
MemoryContexttablecxt,
140-
MemoryContexttempcxt,booluse_variable_hash_iv);
141-
externTupleHashTableBuildTupleHashTableExt(PlanState*parent,
142-
TupleDescinputDesc,
143-
constTupleTableSlotOps*inputOps,
144-
intnumCols,AttrNumber*keyColIdx,
145-
constOid*eqfuncoids,
146-
FmgrInfo*hashfunctions,
147-
Oid*collations,
148-
longnbuckets,Sizeadditionalsize,
149-
MemoryContextmetacxt,
150-
MemoryContexttablecxt,
151-
MemoryContexttempcxt,booluse_variable_hash_iv);
144+
MemoryContexttempcxt,
145+
booluse_variable_hash_iv);
152146
externTupleHashEntryLookupTupleHashEntry(TupleHashTablehashtable,
153147
TupleTableSlot*slot,
154148
bool*isnew,uint32*hash);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp