aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-04-20 19:01:30 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2011-04-20 19:01:30 -0400
commit61a26671c6dc52d212789497252de2af89ce95b5 (patch)
tree5dfe663e13a342d0c6d6990f980fa57cbd2cc4e2 /src
parenta58396d79e6519afd53914ff762a84097b45020d (diff)
downloadpostgresql-61a26671c6dc52d212789497252de2af89ce95b5.tar.gz
postgresql-61a26671c6dc52d212789497252de2af89ce95b5.zip
Set indcheckxmin true when REINDEX fixes an invalid or not-ready index.
Per comment from Greg Stark, it's less clear that HOT chains don't conflict with the index than it would be for a valid index. So, let's preserve the former behavior that indcheckxmin does get set when there are potentially-broken HOT chains in this case. This change does not cause any pg_index update that wouldn't have happened anyway, so we're not re-introducing the previous bug with pg_index updates, and surely the case is not significant from a performance standpoint; so let's be as conservative as possible.
Diffstat (limited to 'src')
-rw-r--r--src/backend/catalog/index.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index a074150b630..178f6288bbf 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -2365,7 +2365,12 @@ reindex_index(Oid indexId)
*
* We can also reset indcheckxmin, because we have now done a
* non-concurrent index build, *except* in the case where index_build
- * found some still-broken HOT chains.
+ * found some still-broken HOT chains. If it did, we normally leave
+ * indcheckxmin alone (note that index_build won't have changed it,
+ * because this is a reindex). But if the index was invalid or not ready
+ * and there were broken HOT chains, it seems best to force indcheckxmin
+ * true, because the normal argument that the HOT chains couldn't conflict
+ * with the index is suspect for an invalid index.
*
* Note that it is important to not update the pg_index entry if we don't
* have to, because updating it will move the index's usability horizon
@@ -2389,10 +2394,12 @@ reindex_index(Oid indexId)
if (!indexForm->indisvalid || !indexForm->indisready ||
(indexForm->indcheckxmin && !indexInfo->ii_BrokenHotChain))
{
- indexForm->indisvalid = true;
- indexForm->indisready = true;
if (!indexInfo->ii_BrokenHotChain)
indexForm->indcheckxmin = false;
+ else if (!indexForm->indisvalid || !indexForm->indisready)
+ indexForm->indcheckxmin = true;
+ indexForm->indisvalid = true;
+ indexForm->indisready = true;
simple_heap_update(pg_index, &indexTuple->t_self, indexTuple);
CatalogUpdateIndexes(pg_index, indexTuple);
}