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

Commitaae5023

Browse files
committed
Pass ItemPointer not HeapTuple to IndexBuildCallback.
Not all AMs use HeapTuples internally, making it inconvenient to passa HeapTuple. As the index callbacks really only need the TID, not thefull tuple, modify callback to only take ItemPointer.Author: Ashwin AgrawalReviewed-By: Andres FreundDiscussion:https://postgr.es/m/CALfoeis6=8ehuR=VNtHvj3z16cYfCwPdTcpaxU+sfSUJ5QgR3g@mail.gmail.com
1 parent71a8a4f commitaae5023

File tree

10 files changed

+29
-32
lines changed

10 files changed

+29
-32
lines changed

‎contrib/amcheck/verify_nbtree.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static BTScanInsert bt_right_page_check_scankey(BtreeCheckState *state);
140140
staticvoidbt_downlink_check(BtreeCheckState*state,BTScanInserttargetkey,
141141
BlockNumberchildblock);
142142
staticvoidbt_downlink_missing_check(BtreeCheckState*state);
143-
staticvoidbt_tuple_present_callback(Relationindex,HeapTuplehtup,
143+
staticvoidbt_tuple_present_callback(Relationindex,ItemPointertid,
144144
Datum*values,bool*isnull,
145145
booltupleIsAlive,void*checkstate);
146146
staticIndexTuplebt_normalize_tuple(BtreeCheckState*state,
@@ -1890,7 +1890,7 @@ bt_downlink_missing_check(BtreeCheckState *state)
18901890
* also allows us to detect the corruption in many cases.
18911891
*/
18921892
staticvoid
1893-
bt_tuple_present_callback(Relationindex,HeapTuplehtup,Datum*values,
1893+
bt_tuple_present_callback(Relationindex,ItemPointertid,Datum*values,
18941894
bool*isnull,booltupleIsAlive,void*checkstate)
18951895
{
18961896
BtreeCheckState*state= (BtreeCheckState*)checkstate;
@@ -1901,7 +1901,7 @@ bt_tuple_present_callback(Relation index, HeapTuple htup, Datum *values,
19011901

19021902
/* Generate a normalized index tuple for fingerprinting */
19031903
itup=index_form_tuple(RelationGetDescr(index),values,isnull);
1904-
itup->t_tid=htup->t_self;
1904+
itup->t_tid=*tid;
19051905
norm=bt_normalize_tuple(state,itup);
19061906

19071907
/* Probe Bloom filter -- tuple should be present */

‎contrib/bloom/blinsert.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ initCachedPage(BloomBuildState *buildstate)
7272
* Per-tuple callback for table_index_build_scan.
7373
*/
7474
staticvoid
75-
bloomBuildCallback(Relationindex,HeapTuplehtup,Datum*values,
75+
bloomBuildCallback(Relationindex,ItemPointertid,Datum*values,
7676
bool*isnull,booltupleIsAlive,void*state)
7777
{
7878
BloomBuildState*buildstate= (BloomBuildState*)state;
@@ -81,7 +81,7 @@ bloomBuildCallback(Relation index, HeapTuple htup, Datum *values,
8181

8282
oldCtx=MemoryContextSwitchTo(buildstate->tmpCtx);
8383

84-
itup=BloomFormTuple(&buildstate->blstate,&htup->t_self,values,isnull);
84+
itup=BloomFormTuple(&buildstate->blstate,tid,values,isnull);
8585

8686
/* Try to add next item to cached page */
8787
if (BloomPageAddItem(&buildstate->blstate,buildstate->data.data,itup))

‎src/backend/access/brin/brin.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ brinendscan(IndexScanDesc scan)
597597
*/
598598
staticvoid
599599
brinbuildCallback(Relationindex,
600-
HeapTuplehtup,
600+
ItemPointertid,
601601
Datum*values,
602602
bool*isnull,
603603
booltupleIsAlive,
@@ -607,7 +607,7 @@ brinbuildCallback(Relation index,
607607
BlockNumberthisblock;
608608
inti;
609609

610-
thisblock=ItemPointerGetBlockNumber(&htup->t_self);
610+
thisblock=ItemPointerGetBlockNumber(tid);
611611

612612
/*
613613
* If we're in a block that belongs to a future range, summarize what

‎src/backend/access/gin/gininsert.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ ginHeapTupleBulkInsert(GinBuildState *buildstate, OffsetNumber attnum,
276276
}
277277

278278
staticvoid
279-
ginBuildCallback(Relationindex,HeapTuplehtup,Datum*values,
279+
ginBuildCallback(Relationindex,ItemPointertid,Datum*values,
280280
bool*isnull,booltupleIsAlive,void*state)
281281
{
282282
GinBuildState*buildstate= (GinBuildState*)state;
@@ -287,8 +287,7 @@ ginBuildCallback(Relation index, HeapTuple htup, Datum *values,
287287

288288
for (i=0;i<buildstate->ginstate.origTupdesc->natts;i++)
289289
ginHeapTupleBulkInsert(buildstate, (OffsetNumber) (i+1),
290-
values[i],isnull[i],
291-
&htup->t_self);
290+
values[i],isnull[i],tid);
292291

293292
/* If we've maxed out our available memory, dump everything to the index */
294293
if (buildstate->accum.allocatedMemory >= (Size)maintenance_work_mem*1024L)

‎src/backend/access/gist/gistbuild.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ typedef struct
8080
staticvoidgistInitBuffering(GISTBuildState*buildstate);
8181
staticintcalculatePagesPerBuffer(GISTBuildState*buildstate,intlevelStep);
8282
staticvoidgistBuildCallback(Relationindex,
83-
HeapTuplehtup,
83+
ItemPointertid,
8484
Datum*values,
8585
bool*isnull,
8686
booltupleIsAlive,
@@ -440,7 +440,7 @@ calculatePagesPerBuffer(GISTBuildState *buildstate, int levelStep)
440440
*/
441441
staticvoid
442442
gistBuildCallback(Relationindex,
443-
HeapTuplehtup,
443+
ItemPointertid,
444444
Datum*values,
445445
bool*isnull,
446446
booltupleIsAlive,
@@ -454,7 +454,7 @@ gistBuildCallback(Relation index,
454454

455455
/* form an index tuple and point it at the heap tuple */
456456
itup=gistFormTuple(buildstate->giststate,index,values,isnull, true);
457-
itup->t_tid=htup->t_self;
457+
itup->t_tid=*tid;
458458

459459
if (buildstate->bufferingMode==GIST_BUFFERING_ACTIVE)
460460
{

‎src/backend/access/hash/hash.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ typedef struct
4343
}HashBuildState;
4444

4545
staticvoidhashbuildCallback(Relationindex,
46-
HeapTuplehtup,
46+
ItemPointertid,
4747
Datum*values,
4848
bool*isnull,
4949
booltupleIsAlive,
@@ -201,7 +201,7 @@ hashbuildempty(Relation index)
201201
*/
202202
staticvoid
203203
hashbuildCallback(Relationindex,
204-
HeapTuplehtup,
204+
ItemPointertid,
205205
Datum*values,
206206
bool*isnull,
207207
booltupleIsAlive,
@@ -220,14 +220,13 @@ hashbuildCallback(Relation index,
220220

221221
/* Either spool the tuple for sorting, or just put it into the index */
222222
if (buildstate->spool)
223-
_h_spool(buildstate->spool,&htup->t_self,
224-
index_values,index_isnull);
223+
_h_spool(buildstate->spool,tid,index_values,index_isnull);
225224
else
226225
{
227226
/* form an index tuple and point it at the heap tuple */
228227
itup=index_form_tuple(RelationGetDescr(index),
229228
index_values,index_isnull);
230-
itup->t_tid=htup->t_self;
229+
itup->t_tid=*tid;
231230
_hash_doinsert(index,itup,buildstate->heapRel);
232231
pfree(itup);
233232
}

‎src/backend/access/heap/heapam_handler.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,10 +1636,9 @@ heapam_index_build_range_scan(Relation heapRelation,
16361636
* For a heap-only tuple, pretend its TID is that of the root. See
16371637
* src/backend/access/heap/README.HOT for discussion.
16381638
*/
1639-
HeapTupleDatarootTuple;
1639+
ItemPointerDatatid;
16401640
OffsetNumberoffnum;
16411641

1642-
rootTuple=*heapTuple;
16431642
offnum=ItemPointerGetOffsetNumber(&heapTuple->t_self);
16441643

16451644
if (!OffsetNumberIsValid(root_offsets[offnum-1]))
@@ -1650,18 +1649,18 @@ heapam_index_build_range_scan(Relation heapRelation,
16501649
offnum,
16511650
RelationGetRelationName(heapRelation))));
16521651

1653-
ItemPointerSetOffsetNumber(&rootTuple.t_self,
1654-
root_offsets[offnum-1]);
1652+
ItemPointerSet(&tid,ItemPointerGetBlockNumber(&heapTuple->t_self),
1653+
root_offsets[offnum-1]);
16551654

16561655
/* Call the AM's callback routine to process the tuple */
1657-
callback(indexRelation,&rootTuple,values,isnull,tupleIsAlive,
1656+
callback(indexRelation,&tid,values,isnull,tupleIsAlive,
16581657
callback_state);
16591658
}
16601659
else
16611660
{
16621661
/* Call the AM's callback routine to process the tuple */
1663-
callback(indexRelation,heapTuple,values,isnull,tupleIsAlive,
1664-
callback_state);
1662+
callback(indexRelation,&heapTuple->t_self,values,isnull,
1663+
tupleIsAlive,callback_state);
16651664
}
16661665
}
16671666

‎src/backend/access/nbtree/nbtsort.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ static void _bt_spooldestroy(BTSpool *btspool);
269269
staticvoid_bt_spool(BTSpool*btspool,ItemPointerself,
270270
Datum*values,bool*isnull);
271271
staticvoid_bt_leafbuild(BTSpool*btspool,BTSpool*btspool2);
272-
staticvoid_bt_build_callback(Relationindex,HeapTuplehtup,Datum*values,
272+
staticvoid_bt_build_callback(Relationindex,ItemPointertid,Datum*values,
273273
bool*isnull,booltupleIsAlive,void*state);
274274
staticPage_bt_blnewpage(uint32level);
275275
staticBTPageState*_bt_pagestate(BTWriteState*wstate,uint32level);
@@ -585,7 +585,7 @@ _bt_leafbuild(BTSpool *btspool, BTSpool *btspool2)
585585
*/
586586
staticvoid
587587
_bt_build_callback(Relationindex,
588-
HeapTuplehtup,
588+
ItemPointertid,
589589
Datum*values,
590590
bool*isnull,
591591
booltupleIsAlive,
@@ -598,12 +598,12 @@ _bt_build_callback(Relation index,
598598
* processing
599599
*/
600600
if (tupleIsAlive||buildstate->spool2==NULL)
601-
_bt_spool(buildstate->spool,&htup->t_self,values,isnull);
601+
_bt_spool(buildstate->spool,tid,values,isnull);
602602
else
603603
{
604604
/* dead tuples are put into spool2 */
605605
buildstate->havedead= true;
606-
_bt_spool(buildstate->spool2,&htup->t_self,values,isnull);
606+
_bt_spool(buildstate->spool2,tid,values,isnull);
607607
}
608608

609609
buildstate->indtuples+=1;

‎src/backend/access/spgist/spginsert.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ typedef struct
4040

4141
/* Callback to process one heap tuple during table_index_build_scan */
4242
staticvoid
43-
spgistBuildCallback(Relationindex,HeapTuplehtup,Datum*values,
43+
spgistBuildCallback(Relationindex,ItemPointertid,Datum*values,
4444
bool*isnull,booltupleIsAlive,void*state)
4545
{
4646
SpGistBuildState*buildstate= (SpGistBuildState*)state;
@@ -55,7 +55,7 @@ spgistBuildCallback(Relation index, HeapTuple htup, Datum *values,
5555
* lock on some buffer. So we need to be willing to retry. We can flush
5656
* any temp data when retrying.
5757
*/
58-
while (!spgdoinsert(index,&buildstate->spgstate,&htup->t_self,
58+
while (!spgdoinsert(index,&buildstate->spgstate,tid,
5959
*values,*isnull))
6060
{
6161
MemoryContextReset(buildstate->tmpCtx);

‎src/include/access/tableam.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ typedef struct TM_FailureData
141141

142142
/* Typedef for callback function for table_index_build_scan */
143143
typedefvoid (*IndexBuildCallback) (Relationindex,
144-
HeapTuplehtup,
144+
ItemPointertid,
145145
Datum*values,
146146
bool*isnull,
147147
booltupleIsAlive,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp