|
48 | 48 | #include <signal.h>
|
49 | 49 |
|
50 | 50 | #include "access/clog.h"
|
| 51 | +#include "access/heapam.h" |
51 | 52 | #include "access/subtrans.h"
|
52 | 53 | #include "access/transam.h"
|
53 | 54 | #include "access/twophase.h"
|
@@ -2004,23 +2005,36 @@ TransactionId
|
2004 | 2005 | GetOldestNonRemovableTransactionId(Relation rel)
|
2005 | 2006 | {
|
2006 | 2007 | ComputeXidHorizonsResult horizons;
|
| 2008 | + TransactionId result = InvalidTransactionId; |
2007 | 2009 |
|
2008 | 2010 | ComputeXidHorizons(&horizons);
|
2009 | 2011 |
|
2010 | 2012 | switch (GlobalVisHorizonKindForRel(rel))
|
2011 | 2013 | {
|
2012 | 2014 | case VISHORIZON_SHARED:
|
2013 |
| - return horizons.shared_oldest_nonremovable; |
| 2015 | + result = horizons.shared_oldest_nonremovable; |
| 2016 | + break; |
2014 | 2017 | case VISHORIZON_CATALOG:
|
2015 |
| - return horizons.catalog_oldest_nonremovable; |
| 2018 | + result = horizons.catalog_oldest_nonremovable; |
| 2019 | + break; |
2016 | 2020 | case VISHORIZON_DATA:
|
2017 |
| - return horizons.data_oldest_nonremovable; |
| 2021 | + result = horizons.data_oldest_nonremovable; |
| 2022 | + break; |
2018 | 2023 | case VISHORIZON_TEMP:
|
2019 |
| - return horizons.temp_oldest_nonremovable; |
| 2024 | + result = horizons.temp_oldest_nonremovable; |
| 2025 | + break; |
2020 | 2026 | }
|
2021 | 2027 |
|
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; |
2024 | 2038 | }
|
2025 | 2039 |
|
2026 | 2040 | /*
|
@@ -4109,6 +4123,20 @@ GlobalVisTestFor(Relation rel)
|
4109 | 4123 | break;
|
4110 | 4124 | }
|
4111 | 4125 |
|
| 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 | + |
4112 | 4140 | Assert(FullTransactionIdIsValid(state->definitely_needed) &&
|
4113 | 4141 | FullTransactionIdIsValid(state->maybe_needed));
|
4114 | 4142 |
|
|
0 commit comments