SysScanDesc scan;
ScanKeyData key[1];
Relation statrel;
+ CatalogIndexState indstate = NULL;
statrel = table_open(StatisticRelationId, RowExclusiveLock);
/* update the copy of the tuple and insert it */
statform->starelid = torelid;
- CatalogTupleInsert(statrel, tup);
+
+ /* fetch index information when we know we need it */
+ if (indstate == NULL)
+ indstate = CatalogOpenIndexes(statrel);
+
+ CatalogTupleInsertWithInfo(statrel, tup, indstate);
heap_freetuple(tup);
}
systable_endscan(scan);
+ if (indstate != NULL)
+ CatalogCloseIndexes(indstate);
table_close(statrel, RowExclusiveLock);
}
{
Relation sd;
int attno;
+ CatalogIndexState indstate = NULL;
if (natts <= 0)
return; /* nothing to do */
Int16GetDatum(stats->attr->attnum),
BoolGetDatum(inh));
+ /* Open index information when we know we need it */
+ if (indstate == NULL)
+ indstate = CatalogOpenIndexes(sd);
+
if (HeapTupleIsValid(oldtup))
{
/* Yes, replace it */
nulls,
replaces);
ReleaseSysCache(oldtup);
- CatalogTupleUpdate(sd, &stup->t_self, stup);
+ CatalogTupleUpdateWithInfo(sd, &stup->t_self, stup, indstate);
}
else
{
/* No, insert new tuple */
stup = heap_form_tuple(RelationGetDescr(sd), values, nulls);
- CatalogTupleInsert(sd, stup);
+ CatalogTupleInsertWithInfo(sd, stup, indstate);
}
heap_freetuple(stup);
}
+ if (indstate != NULL)
+ CatalogCloseIndexes(indstate);
table_close(sd, RowExclusiveLock);
}