mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
Fix CatalogTupleInsert/Update abstraction for case of shared indstate.
Add CatalogTupleInsertWithInfo and CatalogTupleUpdateWithInfo to let callers use the CatalogTupleXXX abstraction layer even in cases where we want to share the results of CatalogOpenIndexes across multiple inserts/updates for efficiency. This finishes the job begun in commit2f5c9d9c9
, by allowing some remaining simple_heap_insert/update calls to be replaced. The abstraction layer is now complete enough that we don't have to export CatalogIndexInsert at all anymore. Also, this fixes several places in which2f5c9d9c9
introduced performance regressions by using retail CatalogTupleInsert or CatalogTupleUpdate even though the previous coding had been able to amortize CatalogOpenIndexes work across multiple tuples. A possible future improvement is to arrange for the indexing.c functions to cache the CatalogIndexState somewhere, maybe in the relcache, in which case we could get rid of CatalogTupleInsertWithInfo and CatalogTupleUpdateWithInfo again. But that's a task for another day. Discussion: https://postgr.es/m/27502.1485981379@sss.pgh.pa.us
This commit is contained in:
@ -1141,7 +1141,6 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class,
|
||||
relfilenode2;
|
||||
Oid swaptemp;
|
||||
char swptmpchr;
|
||||
CatalogIndexState indstate;
|
||||
|
||||
/* We need writable copies of both pg_class tuples. */
|
||||
relRelation = heap_open(RelationRelationId, RowExclusiveLock);
|
||||
@ -1285,13 +1284,13 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class,
|
||||
*/
|
||||
if (!target_is_pg_class)
|
||||
{
|
||||
simple_heap_update(relRelation, &reltup1->t_self, reltup1);
|
||||
simple_heap_update(relRelation, &reltup2->t_self, reltup2);
|
||||
CatalogIndexState indstate;
|
||||
|
||||
/* Keep system catalogs current */
|
||||
indstate = CatalogOpenIndexes(relRelation);
|
||||
CatalogIndexInsert(indstate, reltup1);
|
||||
CatalogIndexInsert(indstate, reltup2);
|
||||
CatalogTupleUpdateWithInfo(relRelation, &reltup1->t_self, reltup1,
|
||||
indstate);
|
||||
CatalogTupleUpdateWithInfo(relRelation, &reltup2->t_self, reltup2,
|
||||
indstate);
|
||||
CatalogCloseIndexes(indstate);
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user