diff options
Diffstat (limited to 'src/backend/catalog/heap.c')
-rw-r--r-- | src/backend/catalog/heap.c | 46 |
1 files changed, 16 insertions, 30 deletions
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c index 7ce91158325..cb6b6eb46cd 100644 --- a/src/backend/catalog/heap.c +++ b/src/backend/catalog/heap.c @@ -635,7 +635,13 @@ InsertPgAttributeTuple(Relation pg_attribute_rel, if (indstate != NULL) CatalogIndexInsert(indstate, tup); else - CatalogUpdateIndexes(pg_attribute_rel, tup); + { + CatalogIndexState indstate; + + indstate = CatalogOpenIndexes(pg_attribute_rel); + CatalogIndexInsert(indstate, tup); + CatalogCloseIndexes(indstate); + } heap_freetuple(tup); } @@ -824,9 +830,7 @@ InsertPgClassTuple(Relation pg_class_desc, HeapTupleSetOid(tup, new_rel_oid); /* finally insert the new tuple, update the indexes, and clean up */ - simple_heap_insert(pg_class_desc, tup); - - CatalogUpdateIndexes(pg_class_desc, tup); + CatalogTupleInsert(pg_class_desc, tup); heap_freetuple(tup); } @@ -1599,10 +1603,7 @@ RemoveAttributeById(Oid relid, AttrNumber attnum) "........pg.dropped.%d........", attnum); namestrcpy(&(attStruct->attname), newattname); - simple_heap_update(attr_rel, &tuple->t_self, tuple); - - /* keep the system catalog indexes current */ - CatalogUpdateIndexes(attr_rel, tuple); + CatalogTupleUpdate(attr_rel, &tuple->t_self, tuple); } /* @@ -1731,10 +1732,7 @@ RemoveAttrDefaultById(Oid attrdefId) ((Form_pg_attribute) GETSTRUCT(tuple))->atthasdef = false; - simple_heap_update(attr_rel, &tuple->t_self, tuple); - - /* keep the system catalog indexes current */ - CatalogUpdateIndexes(attr_rel, tuple); + CatalogTupleUpdate(attr_rel, &tuple->t_self, tuple); /* * Our update of the pg_attribute row will force a relcache rebuild, so @@ -1932,9 +1930,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, adrel = heap_open(AttrDefaultRelationId, RowExclusiveLock); tuple = heap_form_tuple(adrel->rd_att, values, nulls); - attrdefOid = simple_heap_insert(adrel, tuple); - - CatalogUpdateIndexes(adrel, tuple); + attrdefOid = CatalogTupleInsert(adrel, tuple); defobject.classId = AttrDefaultRelationId; defobject.objectId = attrdefOid; @@ -1964,9 +1960,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, if (!attStruct->atthasdef) { attStruct->atthasdef = true; - simple_heap_update(attrrel, &atttup->t_self, atttup); - /* keep catalog indexes current */ - CatalogUpdateIndexes(attrrel, atttup); + CatalogTupleUpdate(attrrel, &atttup->t_self, atttup); } heap_close(attrrel, RowExclusiveLock); heap_freetuple(atttup); @@ -2561,8 +2555,7 @@ MergeWithExistingConstraint(Relation rel, char *ccname, Node *expr, Assert(is_local); con->connoinherit = true; } - simple_heap_update(conDesc, &tup->t_self, tup); - CatalogUpdateIndexes(conDesc, tup); + CatalogTupleUpdate(conDesc, &tup->t_self, tup); break; } } @@ -2602,10 +2595,7 @@ SetRelationNumChecks(Relation rel, int numchecks) { relStruct->relchecks = numchecks; - simple_heap_update(relrel, &reltup->t_self, reltup); - - /* keep catalog indexes current */ - CatalogUpdateIndexes(relrel, reltup); + CatalogTupleUpdate(relrel, &reltup->t_self, reltup); } else { @@ -3145,10 +3135,7 @@ StorePartitionKey(Relation rel, tuple = heap_form_tuple(RelationGetDescr(pg_partitioned_table), values, nulls); - simple_heap_insert(pg_partitioned_table, tuple); - - /* Update the indexes on pg_partitioned_table */ - CatalogUpdateIndexes(pg_partitioned_table, tuple); + CatalogTupleInsert(pg_partitioned_table, tuple); heap_close(pg_partitioned_table, RowExclusiveLock); /* Mark this relation as dependent on a few things as follows */ @@ -3265,8 +3252,7 @@ StorePartitionBound(Relation rel, Relation parent, Node *bound) new_val, new_null, new_repl); /* Also set the flag */ ((Form_pg_class) GETSTRUCT(newtuple))->relispartition = true; - simple_heap_update(classRel, &newtuple->t_self, newtuple); - CatalogUpdateIndexes(classRel, newtuple); + CatalogTupleUpdate(classRel, &newtuple->t_self, newtuple); heap_freetuple(newtuple); heap_close(classRel, RowExclusiveLock); |