From 15fe086fba52bbac7560151e06d1efb3daa69e4a Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 5 Aug 2002 03:29:17 +0000 Subject: Restructure system-catalog index updating logic. Instead of having hardwired lists of index names for each catalog, use the relcache's mechanism for caching lists of OIDs of indexes of any table. This reduces the common case of updating system catalog indexes to a single line, makes it much easier to add a new system index (in fact, you can now do so on-the-fly if you want to), and as a nice side benefit improves performance a little. Per recent pghackers discussion. --- src/backend/commands/trigger.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) (limited to 'src/backend/commands/trigger.c') diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index 353d684d903..7fa570890d5 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.123 2002/07/20 19:55:38 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.124 2002/08/05 03:29:17 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -72,8 +72,6 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint) ScanKeyData key; Relation pgrel; HeapTuple tuple; - Relation idescs[Num_pg_trigger_indices]; - Relation ridescs[Num_pg_class_indices]; Oid fargtypes[FUNC_MAX_ARGS]; Oid funcoid; Oid funclang; @@ -302,9 +300,7 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint) */ simple_heap_insert(tgrel, tuple); - CatalogOpenIndices(Num_pg_trigger_indices, Name_pg_trigger_indices, idescs); - CatalogIndexInsert(idescs, Num_pg_trigger_indices, tgrel, tuple); - CatalogCloseIndices(Num_pg_trigger_indices, idescs); + CatalogUpdateIndexes(tgrel, tuple); myself.classId = RelationGetRelid(tgrel); myself.objectId = trigoid; @@ -333,9 +329,7 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint) simple_heap_update(pgrel, &tuple->t_self, tuple); - CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, ridescs); - CatalogIndexInsert(ridescs, Num_pg_class_indices, pgrel, tuple); - CatalogCloseIndices(Num_pg_class_indices, ridescs); + CatalogUpdateIndexes(pgrel, tuple); heap_freetuple(tuple); heap_close(pgrel, RowExclusiveLock); @@ -447,7 +441,6 @@ RemoveTriggerById(Oid trigOid) Relation pgrel; HeapTuple tuple; Form_pg_class classForm; - Relation ridescs[Num_pg_class_indices]; tgrel = heap_openr(TriggerRelationName, RowExclusiveLock); @@ -514,9 +507,7 @@ RemoveTriggerById(Oid trigOid) simple_heap_update(pgrel, &tuple->t_self, tuple); - CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, ridescs); - CatalogIndexInsert(ridescs, Num_pg_class_indices, pgrel, tuple); - CatalogCloseIndices(Num_pg_class_indices, ridescs); + CatalogUpdateIndexes(pgrel, tuple); heap_freetuple(tuple); @@ -549,7 +540,6 @@ renametrig(Oid relid, HeapTuple tuple; SysScanDesc tgscan; ScanKeyData key[2]; - Relation idescs[Num_pg_trigger_indices]; /* * Grab an exclusive lock on the target table, which we will NOT @@ -610,12 +600,8 @@ renametrig(Oid relid, simple_heap_update(tgrel, &tuple->t_self, tuple); - /* - * keep system catalog indices current - */ - CatalogOpenIndices(Num_pg_trigger_indices, Name_pg_trigger_indices, idescs); - CatalogIndexInsert(idescs, Num_pg_trigger_indices, tgrel, tuple); - CatalogCloseIndices(Num_pg_trigger_indices, idescs); + /* keep system catalog indexes current */ + CatalogUpdateIndexes(tgrel, tuple); /* * Invalidate relation's relcache entry so that other backends (and -- cgit v1.2.3