index 5b49cc5a098968a6c058eabd436f5da705bf555e..bdd413f01b057875a391f9f0a46049c5bb307e7b 100644 (file)
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);
}
index ff1354812bdd4e237b2cc3be026427f349be4002..bf0ec8b37442be40919b982d44b40abfb501940e 100644 (file)
@@ -1624,6 +1624,7 @@ update_attstats(Oid relid, bool inh, int natts, VacAttrStats **vacattrstats)
{
Relation sd;
int attno;
+ CatalogIndexState indstate = NULL;
if (natts <= 0)
return; /* nothing to do */
@@ -1725,6 +1726,10 @@ update_attstats(Oid relid, bool inh, int natts, VacAttrStats **vacattrstats)
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 */
@@ -1734,18 +1739,20 @@ update_attstats(Oid relid, bool inh, int natts, VacAttrStats **vacattrstats)
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);
}