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

Commit61b313e

Browse files
committed
Pass down table relation into more index relation functions
This is done in preparation for logical decoding on standby, which needs toinclude whether visibility affecting WAL records are about a (user) catalogtable. Which is only known for the table, not the indexes.It's also nice to be able to pass the heap relation to GlobalVisTestFor() invacuumRedirectAndPlaceholder().Author: "Drouvot, Bertrand" <bertranddrouvot.pg@gmail.com>Discussion:https://postgr.es/m/21b700c3-eecf-2e05-a699-f8c78dd31ec7@gmail.com
1 parenta88a18b commit61b313e

File tree

26 files changed

+214
-170
lines changed

26 files changed

+214
-170
lines changed

‎contrib/amcheck/verify_nbtree.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ static inline bool invariant_l_nontarget_offset(BtreeCheckState *state,
183183
OffsetNumberupperbound);
184184
staticPagepalloc_btree_page(BtreeCheckState*state,BlockNumberblocknum);
185185
staticinlineBTScanInsertbt_mkscankey_pivotsearch(Relationrel,
186+
Relationheaprel,
186187
IndexTupleitup);
187188
staticItemIdPageGetItemIdCareful(BtreeCheckState*state,BlockNumberblock,
188189
Pagepage,OffsetNumberoffset);
@@ -331,7 +332,7 @@ bt_index_check_internal(Oid indrelid, bool parentcheck, bool heapallindexed,
331332
RelationGetRelationName(indrel))));
332333

333334
/* Extract metadata from metapage, and sanitize it in passing */
334-
_bt_metaversion(indrel,&heapkeyspace,&allequalimage);
335+
_bt_metaversion(indrel,heaprel,&heapkeyspace,&allequalimage);
335336
if (allequalimage&& !heapkeyspace)
336337
ereport(ERROR,
337338
(errcode(ERRCODE_INDEX_CORRUPTED),
@@ -1258,7 +1259,7 @@ bt_target_page_check(BtreeCheckState *state)
12581259
}
12591260

12601261
/* Build insertion scankey for current page offset */
1261-
skey=bt_mkscankey_pivotsearch(state->rel,itup);
1262+
skey=bt_mkscankey_pivotsearch(state->rel,state->heaprel,itup);
12621263

12631264
/*
12641265
* Make sure tuple size does not exceed the relevant BTREE_VERSION
@@ -1768,7 +1769,7 @@ bt_right_page_check_scankey(BtreeCheckState *state)
17681769
* memory remaining allocated.
17691770
*/
17701771
firstitup= (IndexTuple)PageGetItem(rightpage,rightitem);
1771-
returnbt_mkscankey_pivotsearch(state->rel,firstitup);
1772+
returnbt_mkscankey_pivotsearch(state->rel,state->heaprel,firstitup);
17721773
}
17731774

17741775
/*
@@ -2681,7 +2682,7 @@ bt_rootdescend(BtreeCheckState *state, IndexTuple itup)
26812682
Bufferlbuf;
26822683
boolexists;
26832684

2684-
key=_bt_mkscankey(state->rel,itup);
2685+
key=_bt_mkscankey(state->rel,state->heaprel,itup);
26852686
Assert(key->heapkeyspace&&key->scantid!=NULL);
26862687

26872688
/*
@@ -2694,7 +2695,7 @@ bt_rootdescend(BtreeCheckState *state, IndexTuple itup)
26942695
*/
26952696
Assert(state->readonly&&state->rootdescend);
26962697
exists= false;
2697-
stack=_bt_search(state->rel,key,&lbuf,BT_READ,NULL);
2698+
stack=_bt_search(state->rel,state->heaprel,key,&lbuf,BT_READ,NULL);
26982699

26992700
if (BufferIsValid(lbuf))
27002701
{
@@ -3133,11 +3134,11 @@ palloc_btree_page(BtreeCheckState *state, BlockNumber blocknum)
31333134
* the scankey is greater.
31343135
*/
31353136
staticinlineBTScanInsert
3136-
bt_mkscankey_pivotsearch(Relationrel,IndexTupleitup)
3137+
bt_mkscankey_pivotsearch(Relationrel,Relationheaprel,IndexTupleitup)
31373138
{
31383139
BTScanInsertskey;
31393140

3140-
skey=_bt_mkscankey(rel,itup);
3141+
skey=_bt_mkscankey(rel,heaprel,itup);
31413142
skey->pivotsearch= true;
31423143

31433144
returnskey;

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate,
349349
for (;ptr;ptr=ptr->next)
350350
{
351351
/* Allocate new page */
352-
ptr->buffer=gistNewBuffer(rel);
352+
ptr->buffer=gistNewBuffer(rel,heapRel);
353353
GISTInitBuffer(ptr->buffer, (is_leaf) ?F_LEAF :0);
354354
ptr->page=BufferGetPage(ptr->buffer);
355355
ptr->block.blkno=BufferGetBlockNumber(ptr->buffer);
@@ -1695,7 +1695,8 @@ gistprunepage(Relation rel, Page page, Buffer buffer, Relation heapRel)
16951695

16961696
recptr=gistXLogDelete(buffer,
16971697
deletable,ndeletable,
1698-
snapshotConflictHorizon);
1698+
snapshotConflictHorizon,
1699+
heapRel);
16991700

17001701
PageSetLSN(page,recptr);
17011702
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ gistbuild(Relation heap, Relation index, IndexInfo *indexInfo)
298298
Pagepage;
299299

300300
/* initialize the root page */
301-
buffer=gistNewBuffer(index);
301+
buffer=gistNewBuffer(index,heap);
302302
Assert(BufferGetBlockNumber(buffer)==GIST_ROOT_BLKNO);
303303
page=BufferGetPage(buffer);
304304

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ gistcheckpage(Relation rel, Buffer buf)
821821
* Caller is responsible for initializing the page by calling GISTInitBuffer
822822
*/
823823
Buffer
824-
gistNewBuffer(Relationr)
824+
gistNewBuffer(Relationr,Relationheaprel)
825825
{
826826
Bufferbuffer;
827827
boolneedLock;
@@ -865,7 +865,7 @@ gistNewBuffer(Relation r)
865865
* page's deleteXid.
866866
*/
867867
if (XLogStandbyInfoActive()&&RelationNeedsWAL(r))
868-
gistXLogPageReuse(r,blkno,GistPageGetDeleteXid(page));
868+
gistXLogPageReuse(r,heaprel,blkno,GistPageGetDeleteXid(page));
869869

870870
returnbuffer;
871871
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,8 @@ gistXLogAssignLSN(void)
597597
* Write XLOG record about reuse of a deleted page.
598598
*/
599599
void
600-
gistXLogPageReuse(Relationrel,BlockNumberblkno,FullTransactionIddeleteXid)
600+
gistXLogPageReuse(Relationrel,Relationheaprel,
601+
BlockNumberblkno,FullTransactionIddeleteXid)
601602
{
602603
gistxlogPageReusexlrec_reuse;
603604

@@ -672,7 +673,7 @@ gistXLogUpdate(Buffer buffer,
672673
*/
673674
XLogRecPtr
674675
gistXLogDelete(Bufferbuffer,OffsetNumber*todelete,intntodelete,
675-
TransactionIdsnapshotConflictHorizon)
676+
TransactionIdsnapshotConflictHorizon,Relationheaprel)
676677
{
677678
gistxlogDeletexlrec;
678679
XLogRecPtrrecptr;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8268,7 +8268,7 @@ bottomup_sort_and_shrink(TM_IndexDeleteOp *delstate)
82688268
* update the heap page's LSN.
82698269
*/
82708270
XLogRecPtr
8271-
log_heap_visible(RelFileLocatorrlocator,Bufferheap_buffer,Buffervm_buffer,
8271+
log_heap_visible(Relationrel,Bufferheap_buffer,Buffervm_buffer,
82728272
TransactionIdsnapshotConflictHorizon,uint8vmflags)
82738273
{
82748274
xl_heap_visiblexlrec;

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -822,9 +822,14 @@ heapam_relation_copy_for_cluster(Relation OldHeap, Relation NewHeap,
822822
*multi_cutoff);
823823

824824

825-
/* Set up sorting if wanted */
825+
/*
826+
* Set up sorting if wanted. NewHeap is being passed to
827+
* tuplesort_begin_cluster(), it could have been OldHeap too. It does not
828+
* really matter, as the goal is to have a heap relation being passed to
829+
* _bt_log_reuse_page() (which should not be called from this code path).
830+
*/
826831
if (use_sort)
827-
tuplesort=tuplesort_begin_cluster(oldTupDesc,OldIndex,
832+
tuplesort=tuplesort_begin_cluster(oldTupDesc,OldIndex,NewHeap,
828833
maintenance_work_mem,
829834
NULL,TUPLESORT_NONE);
830835
else

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2710,6 +2710,7 @@ lazy_vacuum_one_index(Relation indrel, IndexBulkDeleteResult *istat,
27102710
ivinfo.message_level=DEBUG2;
27112711
ivinfo.num_heap_tuples=reltuples;
27122712
ivinfo.strategy=vacrel->bstrategy;
2713+
ivinfo.heaprel=vacrel->rel;
27132714

27142715
/*
27152716
* Update error traceback information.
@@ -2759,6 +2760,7 @@ lazy_cleanup_one_index(Relation indrel, IndexBulkDeleteResult *istat,
27592760

27602761
ivinfo.num_heap_tuples=reltuples;
27612762
ivinfo.strategy=vacrel->bstrategy;
2763+
ivinfo.heaprel=vacrel->rel;
27622764

27632765
/*
27642766
* Update error traceback information.

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,7 @@ visibilitymap_set(Relation rel, BlockNumber heapBlk, Buffer heapBuf,
288288
if (XLogRecPtrIsInvalid(recptr))
289289
{
290290
Assert(!InRecovery);
291-
recptr=log_heap_visible(rel->rd_locator,heapBuf,vmBuf,
292-
cutoff_xid,flags);
291+
recptr=log_heap_visible(rel,heapBuf,vmBuf,cutoff_xid,flags);
293292

294293
/*
295294
* If data checksums are enabled (or wal_log_hints=on), we

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp