Skip to content

Commit aca5477

Browse files
melanieplagemanCommitfest Bot
authored andcommitted
Rename GlobalVisTestIsRemovableXid() to GlobalVisXidVisibleToAll()
The function is currently only used to check whether a tuple’s xmax is visible to all transactions (and thus removable). Upcoming changes will also use it to test whether a tuple’s xmin is visible to all to decide if a page can be marked all-visible in the visibility map. The new name, GlobalVisXidVisibleToAll(), better reflects this broader purpose. Reviewed-by: Kirill Reshke <[email protected]>
1 parent 13a2b85 commit aca5477

File tree

5 files changed

+22
-23
lines changed

5 files changed

+22
-23
lines changed

src/backend/access/heap/heapam_visibility.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,7 @@ HeapTupleSatisfiesNonVacuumable(HeapTuple htup, Snapshot snapshot,
14471447
{
14481448
Assert(TransactionIdIsValid(dead_after));
14491449

1450-
if (GlobalVisTestIsRemovableXid(snapshot->vistest, dead_after))
1450+
if (GlobalVisXidVisibleToAll(snapshot->vistest, dead_after))
14511451
res = HEAPTUPLE_DEAD;
14521452
}
14531453
else
@@ -1512,8 +1512,8 @@ HeapTupleIsSurelyDead(HeapTuple htup, GlobalVisState *vistest)
15121512
return false;
15131513

15141514
/* Deleter committed, so tuple is dead if the XID is old enough. */
1515-
return GlobalVisTestIsRemovableXid(vistest,
1516-
HeapTupleHeaderGetRawXmax(tuple));
1515+
return GlobalVisXidVisibleToAll(vistest,
1516+
HeapTupleHeaderGetRawXmax(tuple));
15171517
}
15181518

15191519
/*

src/backend/access/heap/pruneheap.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ heap_page_prune_opt(Relation relation, Buffer buffer)
235235
*/
236236
vistest = GlobalVisTestFor(relation);
237237

238-
if (!GlobalVisTestIsRemovableXid(vistest, prune_xid))
238+
if (!GlobalVisXidVisibleToAll(vistest, prune_xid))
239239
return;
240240

241241
/*
@@ -730,9 +730,9 @@ heap_page_prune_and_freeze(PruneFreezeParams *params,
730730
* Determining HTSV only once for each tuple is required for correctness,
731731
* to deal with cases where running HTSV twice could result in different
732732
* results. For example, RECENTLY_DEAD can turn to DEAD if another
733-
* checked item causes GlobalVisTestIsRemovableFullXid() to update the
734-
* horizon, or INSERT_IN_PROGRESS can change to DEAD if the inserting
735-
* transaction aborts.
733+
* checked item causes GlobalVisXidVisibleToAll() to update the horizon,
734+
* or INSERT_IN_PROGRESS can change to DEAD if the inserting transaction
735+
* aborts.
736736
*
737737
* It's also good for performance. Most commonly tuples within a page are
738738
* stored at decreasing offsets (while the items are stored at increasing
@@ -1157,11 +1157,11 @@ heap_prune_satisfies_vacuum(PruneState *prstate, HeapTuple tup, Buffer buffer)
11571157
* Determine whether or not the tuple is considered dead when compared
11581158
* with the provided GlobalVisState. On-access pruning does not provide
11591159
* VacuumCutoffs. And for vacuum, even if the tuple's xmax is not older
1160-
* than OldestXmin, GlobalVisTestIsRemovableXid() could find the row dead
1161-
* if the GlobalVisState has been updated since the beginning of vacuuming
1160+
* than OldestXmin, GlobalVisXidVisibleToAll() could find the row dead if
1161+
* the GlobalVisState has been updated since the beginning of vacuuming
11621162
* the relation.
11631163
*/
1164-
if (GlobalVisTestIsRemovableXid(prstate->vistest, dead_after))
1164+
if (GlobalVisXidVisibleToAll(prstate->vistest, dead_after))
11651165
return HEAPTUPLE_DEAD;
11661166

11671167
return res;
@@ -1618,7 +1618,7 @@ heap_prune_record_unchanged_lp_normal(Page page, PruneState *prstate, OffsetNumb
16181618
/*
16191619
* For now always use prstate->cutoffs for this test, because
16201620
* we only update 'all_visible' when freezing is requested. We
1621-
* could use GlobalVisTestIsRemovableXid instead, if a
1621+
* could use GlobalVisXidVisibleToAll() instead, if a
16221622
* non-freezing caller wanted to set the VM bit.
16231623
*/
16241624
Assert(prstate->cutoffs);

src/backend/access/spgist/spgvacuum.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ vacuumRedirectAndPlaceholder(Relation index, Relation heaprel, Buffer buffer)
536536
*/
537537
if (dt->tupstate == SPGIST_REDIRECT &&
538538
(!TransactionIdIsValid(dt->xid) ||
539-
GlobalVisTestIsRemovableXid(vistest, dt->xid)))
539+
GlobalVisXidVisibleToAll(vistest, dt->xid)))
540540
{
541541
dt->tupstate = SPGIST_PLACEHOLDER;
542542
Assert(opaque->nRedirection > 0);

src/backend/storage/ipc/procarray.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4181,8 +4181,7 @@ GlobalVisUpdate(void)
41814181
* See comment for GlobalVisState for details.
41824182
*/
41834183
bool
4184-
GlobalVisTestIsRemovableFullXid(GlobalVisState *state,
4185-
FullTransactionId fxid)
4184+
GlobalVisFullXidVisibleToAll(GlobalVisState *state, FullTransactionId fxid)
41864185
{
41874186
/*
41884187
* If fxid is older than maybe_needed bound, it definitely is visible to
@@ -4216,14 +4215,14 @@ GlobalVisTestIsRemovableFullXid(GlobalVisState *state,
42164215
}
42174216

42184217
/*
4219-
* Wrapper around GlobalVisTestIsRemovableFullXid() for 32bit xids.
4218+
* Wrapper around GlobalVisFullXidVisibleToAll() for 32bit xids.
42204219
*
42214220
* It is crucial that this only gets called for xids from a source that
42224221
* protects against xid wraparounds (e.g. from a table and thus protected by
42234222
* relfrozenxid).
42244223
*/
42254224
bool
4226-
GlobalVisTestIsRemovableXid(GlobalVisState *state, TransactionId xid)
4225+
GlobalVisXidVisibleToAll(GlobalVisState *state, TransactionId xid)
42274226
{
42284227
FullTransactionId fxid;
42294228

@@ -4237,12 +4236,12 @@ GlobalVisTestIsRemovableXid(GlobalVisState *state, TransactionId xid)
42374236
*/
42384237
fxid = FullXidRelativeTo(state->definitely_needed, xid);
42394238

4240-
return GlobalVisTestIsRemovableFullXid(state, fxid);
4239+
return GlobalVisFullXidVisibleToAll(state, fxid);
42414240
}
42424241

42434242
/*
42444243
* Convenience wrapper around GlobalVisTestFor() and
4245-
* GlobalVisTestIsRemovableFullXid(), see their comments.
4244+
* GlobalVisFullXidVisibleToAll(), see their comments.
42464245
*/
42474246
bool
42484247
GlobalVisCheckRemovableFullXid(Relation rel, FullTransactionId fxid)
@@ -4251,12 +4250,12 @@ GlobalVisCheckRemovableFullXid(Relation rel, FullTransactionId fxid)
42514250

42524251
state = GlobalVisTestFor(rel);
42534252

4254-
return GlobalVisTestIsRemovableFullXid(state, fxid);
4253+
return GlobalVisFullXidVisibleToAll(state, fxid);
42554254
}
42564255

42574256
/*
42584257
* Convenience wrapper around GlobalVisTestFor() and
4259-
* GlobalVisTestIsRemovableXid(), see their comments.
4258+
* GlobalVisTestIsVisibleXid(), see their comments.
42604259
*/
42614260
bool
42624261
GlobalVisCheckRemovableXid(Relation rel, TransactionId xid)
@@ -4265,7 +4264,7 @@ GlobalVisCheckRemovableXid(Relation rel, TransactionId xid)
42654264

42664265
state = GlobalVisTestFor(rel);
42674266

4268-
return GlobalVisTestIsRemovableXid(state, xid);
4267+
return GlobalVisXidVisibleToAll(state, xid);
42694268
}
42704269

42714270
/*

src/include/utils/snapmgr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ extern char *ExportSnapshot(Snapshot snapshot);
100100
*/
101101
typedef struct GlobalVisState GlobalVisState;
102102
extern GlobalVisState *GlobalVisTestFor(Relation rel);
103-
extern bool GlobalVisTestIsRemovableXid(GlobalVisState *state, TransactionId xid);
104-
extern bool GlobalVisTestIsRemovableFullXid(GlobalVisState *state, FullTransactionId fxid);
103+
extern bool GlobalVisXidVisibleToAll(GlobalVisState *state, TransactionId xid);
104+
extern bool GlobalVisFullXidVisibleToAll(GlobalVisState *state, FullTransactionId fxid);
105105
extern bool GlobalVisCheckRemovableXid(Relation rel, TransactionId xid);
106106
extern bool GlobalVisCheckRemovableFullXid(Relation rel, FullTransactionId fxid);
107107

0 commit comments

Comments
 (0)