Hi all,
While working on REINDEX CONCURRENTLY, I have noticed that
index_build() does not need its argument isprimary. Perhaps it is
not worth bothering, but for the REINDEX CONCURRENTLY business this
removes the need to open an index when triggering a concurrent
build.
The flag was introduced in 3fdeb189, but f66e8bf actually forgot to
finish the cleanup as index_update_stats() has simplified its
interface.
Are there any objections if I cleanup that stuff as per the attached?
Thanks,
--
Michael
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index 6677926ae6..4d7ed8ad1a 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -1130,7 +1130,7 @@ build_indices(void)
heap = table_open(ILHead->il_heap, NoLock);
ind = index_open(ILHead->il_ind, NoLock);
- index_build(heap, ind, ILHead->il_info, false, false, false);
+ index_build(heap, ind, ILHead->il_info, false, false);
index_close(ind, NoLock);
table_close(heap, NoLock);
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index 1153688a1c..cc865de627 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -3063,7 +3063,7 @@ RelationTruncateIndexes(Relation heapRelation)
/* Initialize the index and rebuild */
/* Note: we do not need to re-establish pkey setting */
- index_build(heapRelation, currentIndex, indexInfo, false, true, false);
+ index_build(heapRelation, currentIndex, indexInfo, true, false);
/* We're done with this index */
index_close(currentIndex, NoLock);
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 5ca0b1eb96..225c078018 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -1189,8 +1189,7 @@ index_create(Relation heapRelation,
}
else
{
- index_build(heapRelation, indexRelation, indexInfo, isprimary, false,
- true);
+ index_build(heapRelation, indexRelation, indexInfo, false, true);
}
/*
@@ -2220,13 +2219,9 @@ index_update_stats(Relation rel,
* entries of the index and heap relation as needed, using statistics
* returned by ambuild as well as data passed by the caller.
*
- * isprimary tells whether to mark the index as a primary-key index.
* isreindex indicates we are recreating a previously-existing index.
* parallel indicates if parallelism may be useful.
*
- * Note: when reindexing an existing index, isprimary can be false even if
- * the index is a PK; it's already properly marked and need not be re-marked.
- *
* Note: before Postgres 8.2, the passed-in heap and index Relations
* were automatically closed by this routine. This is no longer the case.
* The caller opened 'em, and the caller should close 'em.
@@ -2235,7 +2230,6 @@ void
index_build(Relation heapRelation,
Relation indexRelation,
IndexInfo *indexInfo,
- bool isprimary,
bool isreindex,
bool parallel)
{
@@ -3702,7 +3696,7 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence,
/* Initialize the index and rebuild */
/* Note: we do not need to re-establish pkey setting */
- index_build(heapRelation, iRel, indexInfo, false, true, true);
+ index_build(heapRelation, iRel, indexInfo, true, true);
}
PG_CATCH();
{
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index 3edc94308e..5b2b8d2969 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -1168,7 +1168,7 @@ DefineIndex(Oid relationId,
indexInfo->ii_BrokenHotChain = false;
/* Now build the index */
- index_build(rel, indexRelation, indexInfo, stmt->primary, false, true);
+ index_build(rel, indexRelation, indexInfo, false, true);
/* Close both the relations, but keep the locks */
table_close(rel, NoLock);
diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h
index 8daac5663c..330c481a8b 100644
--- a/src/include/catalog/index.h
+++ b/src/include/catalog/index.h
@@ -107,7 +107,6 @@ extern void FormIndexDatum(IndexInfo *indexInfo,
extern void index_build(Relation heapRelation,
Relation indexRelation,
IndexInfo *indexInfo,
- bool isprimary,
bool isreindex,
bool parallel);
signature.asc
Description: PGP signature