aboutsummaryrefslogtreecommitdiff
path: root/src/backend/catalog/indexing.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/catalog/indexing.c')
-rw-r--r--src/backend/catalog/indexing.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/src/backend/catalog/indexing.c b/src/backend/catalog/indexing.c
index bb7cc3601c7..feddff654e6 100644
--- a/src/backend/catalog/indexing.c
+++ b/src/backend/catalog/indexing.c
@@ -72,7 +72,8 @@ CatalogCloseIndexes(CatalogIndexState indstate)
* This is effectively a cut-down version of ExecInsertIndexTuples.
*/
static void
-CatalogIndexInsert(CatalogIndexState indstate, HeapTuple heapTuple)
+CatalogIndexInsert(CatalogIndexState indstate, HeapTuple heapTuple,
+ TU_UpdateIndexes updateIndexes)
{
int i;
int numIndexes;
@@ -82,6 +83,7 @@ CatalogIndexInsert(CatalogIndexState indstate, HeapTuple heapTuple)
IndexInfo **indexInfoArray;
Datum values[INDEX_MAX_KEYS];
bool isnull[INDEX_MAX_KEYS];
+ bool onlySummarized = (updateIndexes == TU_Summarizing);
/*
* HOT update does not require index inserts. But with asserts enabled we
@@ -89,10 +91,13 @@ CatalogIndexInsert(CatalogIndexState indstate, HeapTuple heapTuple)
* table/index.
*/
#ifndef USE_ASSERT_CHECKING
- if (HeapTupleIsHeapOnly(heapTuple))
+ if (HeapTupleIsHeapOnly(heapTuple) && !onlySummarized)
return;
#endif
+ /* When only updating summarized indexes, the tuple has to be HOT. */
+ Assert((!onlySummarized) || HeapTupleIsHeapOnly(heapTuple));
+
/*
* Get information from the state structure. Fall out if nothing to do.
*/
@@ -135,7 +140,7 @@ CatalogIndexInsert(CatalogIndexState indstate, HeapTuple heapTuple)
/* see earlier check above */
#ifdef USE_ASSERT_CHECKING
- if (HeapTupleIsHeapOnly(heapTuple))
+ if (HeapTupleIsHeapOnly(heapTuple) && !onlySummarized)
{
Assert(!ReindexIsProcessingIndex(RelationGetRelid(index)));
continue;
@@ -143,6 +148,13 @@ CatalogIndexInsert(CatalogIndexState indstate, HeapTuple heapTuple)
#endif /* USE_ASSERT_CHECKING */
/*
+ * Skip insertions into non-summarizing indexes if we only need
+ * to update summarizing indexes.
+ */
+ if (onlySummarized && !indexInfo->ii_Summarizing)
+ continue;
+
+ /*
* FormIndexDatum fills in its values and isnull parameters with the
* appropriate values for the column(s) of the index.
*/
@@ -228,7 +240,7 @@ CatalogTupleInsert(Relation heapRel, HeapTuple tup)
simple_heap_insert(heapRel, tup);
- CatalogIndexInsert(indstate, tup);
+ CatalogIndexInsert(indstate, tup, TU_All);
CatalogCloseIndexes(indstate);
}
@@ -248,7 +260,7 @@ CatalogTupleInsertWithInfo(Relation heapRel, HeapTuple tup,
simple_heap_insert(heapRel, tup);
- CatalogIndexInsert(indstate, tup);
+ CatalogIndexInsert(indstate, tup, TU_All);
}
/*
@@ -279,7 +291,7 @@ CatalogTuplesMultiInsertWithInfo(Relation heapRel, TupleTableSlot **slot,
tuple = ExecFetchSlotHeapTuple(slot[i], true, &should_free);
tuple->t_tableOid = slot[i]->tts_tableOid;
- CatalogIndexInsert(indstate, tuple);
+ CatalogIndexInsert(indstate, tuple, TU_All);
if (should_free)
heap_freetuple(tuple);
@@ -301,14 +313,15 @@ void
CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
{
CatalogIndexState indstate;
+ TU_UpdateIndexes updateIndexes = TU_All;
CatalogTupleCheckConstraints(heapRel, tup);
indstate = CatalogOpenIndexes(heapRel);
- simple_heap_update(heapRel, otid, tup);
+ simple_heap_update(heapRel, otid, tup, &updateIndexes);
- CatalogIndexInsert(indstate, tup);
+ CatalogIndexInsert(indstate, tup, updateIndexes);
CatalogCloseIndexes(indstate);
}
@@ -324,11 +337,13 @@ void
CatalogTupleUpdateWithInfo(Relation heapRel, ItemPointer otid, HeapTuple tup,
CatalogIndexState indstate)
{
+ TU_UpdateIndexes updateIndexes = TU_All;
+
CatalogTupleCheckConstraints(heapRel, tup);
- simple_heap_update(heapRel, otid, tup);
+ simple_heap_update(heapRel, otid, tup, &updateIndexes);
- CatalogIndexInsert(indstate, tup);
+ CatalogIndexInsert(indstate, tup, updateIndexes);
}
/*