Skip to content

Commit 05eca95

Browse files
committed
Use VacuumHorizonHook in more places
1 parent cc268d6 commit 05eca95

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

src/backend/storage/ipc/procarray.c

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include <signal.h>
4949

5050
#include "access/clog.h"
51+
#include "access/heapam.h"
5152
#include "access/subtrans.h"
5253
#include "access/transam.h"
5354
#include "access/twophase.h"
@@ -2004,23 +2005,36 @@ TransactionId
20042005
GetOldestNonRemovableTransactionId(Relation rel)
20052006
{
20062007
ComputeXidHorizonsResult horizons;
2008+
TransactionId result = InvalidTransactionId;
20072009

20082010
ComputeXidHorizons(&horizons);
20092011

20102012
switch (GlobalVisHorizonKindForRel(rel))
20112013
{
20122014
case VISHORIZON_SHARED:
2013-
return horizons.shared_oldest_nonremovable;
2015+
result = horizons.shared_oldest_nonremovable;
2016+
break;
20142017
case VISHORIZON_CATALOG:
2015-
return horizons.catalog_oldest_nonremovable;
2018+
result = horizons.catalog_oldest_nonremovable;
2019+
break;
20162020
case VISHORIZON_DATA:
2017-
return horizons.data_oldest_nonremovable;
2021+
result = horizons.data_oldest_nonremovable;
2022+
break;
20182023
case VISHORIZON_TEMP:
2019-
return horizons.temp_oldest_nonremovable;
2024+
result = horizons.temp_oldest_nonremovable;
2025+
break;
20202026
}
20212027

2022-
/* just to prevent compiler warnings */
2023-
return InvalidTransactionId;
2028+
if (VacuumHorizonHook)
2029+
{
2030+
TransactionId horizon = VacuumHorizonHook();
2031+
2032+
if (TransactionIdIsValid(horizon) &&
2033+
TransactionIdFollows(result, horizon))
2034+
result = horizon;
2035+
}
2036+
2037+
return result;
20242038
}
20252039

20262040
/*
@@ -4109,6 +4123,20 @@ GlobalVisTestFor(Relation rel)
41094123
break;
41104124
}
41114125

4126+
if (VacuumHorizonHook)
4127+
{
4128+
TransactionId horizon = VacuumHorizonHook();
4129+
if (TransactionIdIsValid(horizon))
4130+
{
4131+
FullTransactionId fullHorizon = FullXidRelativeTo(state->definitely_needed, horizon);
4132+
4133+
if (FullTransactionIdFollows(state->definitely_needed, fullHorizon))
4134+
state->definitely_needed = fullHorizon;
4135+
if (FullTransactionIdFollows(state->maybe_needed, fullHorizon))
4136+
state->maybe_needed = fullHorizon;
4137+
}
4138+
}
4139+
41124140
Assert(FullTransactionIdIsValid(state->definitely_needed) &&
41134141
FullTransactionIdIsValid(state->maybe_needed));
41144142

0 commit comments

Comments
 (0)