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

Commit3d0f730

Browse files
committed
Introduce 'options' argument to heap_page_prune()
Currently there is only one option, HEAP_PAGE_PRUNE_MARK_UNUSED_NOWwhich replaces the old boolean argument, but upcoming patches willintroduce at least one more. Having a lot of boolean arguments makesit hard to see at the call sites what the arguments mean, so prefer abitmask of options with human-readable names.Author: Melanie Plageman <melanieplageman@gmail.com>Author: Heikki Linnakangas <heikki.linnakangas@iki.fi>Discussion:https://www.postgresql.org/message-id/20240401172219.fngjosaqdgqqvg4e@liskov
1 parent959b38d commit3d0f730

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ heap_page_prune_opt(Relation relation, Buffer buffer)
166166
* not the relation has indexes, since we cannot safely determine
167167
* that during on-access pruning with the current implementation.
168168
*/
169-
heap_page_prune(relation,buffer,vistest,false,
169+
heap_page_prune(relation,buffer,vistest,0,
170170
&presult,PRUNE_ON_ACCESS,&dummy_off_loc);
171171

172172
/*
@@ -211,8 +211,9 @@ heap_page_prune_opt(Relation relation, Buffer buffer)
211211
* vistest is used to distinguish whether tuples are DEAD or RECENTLY_DEAD
212212
* (see heap_prune_satisfies_vacuum).
213213
*
214-
* mark_unused_now indicates whether or not dead items can be set LP_UNUSED
215-
* during pruning.
214+
* options:
215+
* MARK_UNUSED_NOW indicates that dead items can be set LP_UNUSED during
216+
* pruning.
216217
*
217218
* presult contains output parameters needed by callers such as the number of
218219
* tuples removed and the number of line pointers newly marked LP_DEAD.
@@ -227,7 +228,7 @@ heap_page_prune_opt(Relation relation, Buffer buffer)
227228
void
228229
heap_page_prune(Relationrelation,Bufferbuffer,
229230
GlobalVisState*vistest,
230-
boolmark_unused_now,
231+
intoptions,
231232
PruneResult*presult,
232233
PruneReasonreason,
233234
OffsetNumber*off_loc)
@@ -252,7 +253,7 @@ heap_page_prune(Relation relation, Buffer buffer,
252253
*/
253254
prstate.new_prune_xid=InvalidTransactionId;
254255
prstate.vistest=vistest;
255-
prstate.mark_unused_now=mark_unused_now;
256+
prstate.mark_unused_now=(options&HEAP_PAGE_PRUNE_MARK_UNUSED_NOW)!=0;
256257
prstate.snapshotConflictHorizon=InvalidTransactionId;
257258
prstate.nredirected=prstate.ndead=prstate.nunused=0;
258259
prstate.ndeleted=0;

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,6 +1425,7 @@ lazy_scan_prune(LVRelState *vacrel,
14251425
boolall_visible,
14261426
all_frozen;
14271427
TransactionIdvisibility_cutoff_xid;
1428+
intprune_options=0;
14281429
int64fpi_before=pgWalUsage.wal_fpi;
14291430
OffsetNumberdeadoffsets[MaxHeapTuplesPerPage];
14301431
HeapTupleFreezefrozen[MaxHeapTuplesPerPage];
@@ -1458,10 +1459,12 @@ lazy_scan_prune(LVRelState *vacrel,
14581459
* that were deleted from indexes.
14591460
*
14601461
* If the relation has no indexes, we can immediately mark would-be dead
1461-
* items LP_UNUSED, so mark_unused_now should be true if no indexes and
1462-
* false otherwise.
1462+
* items LP_UNUSED.
14631463
*/
1464-
heap_page_prune(rel,buf,vacrel->vistest,vacrel->nindexes==0,
1464+
prune_options=0;
1465+
if (vacrel->nindexes==0)
1466+
prune_options=HEAP_PAGE_PRUNE_MARK_UNUSED_NOW;
1467+
heap_page_prune(rel,buf,vacrel->vistest,prune_options,
14651468
&presult,PRUNE_VACUUM_SCAN,&vacrel->offnum);
14661469

14671470
/*

‎src/include/access/heapam.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
#defineHEAP_INSERT_NO_LOGICALTABLE_INSERT_NO_LOGICAL
3737
#defineHEAP_INSERT_SPECULATIVE 0x0010
3838

39+
/* "options" flag bits for heap_page_prune */
40+
#defineHEAP_PAGE_PRUNE_MARK_UNUSED_NOW(1 << 0)
41+
3942
typedefstructBulkInsertStateData*BulkInsertState;
4043
structTupleTableSlot;
4144
structVacuumCutoffs;
@@ -331,7 +334,7 @@ struct GlobalVisState;
331334
externvoidheap_page_prune_opt(Relationrelation,Bufferbuffer);
332335
externvoidheap_page_prune(Relationrelation,Bufferbuffer,
333336
structGlobalVisState*vistest,
334-
boolmark_unused_now,
337+
intoptions,
335338
PruneResult*presult,
336339
PruneReasonreason,
337340
OffsetNumber*off_loc);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp