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/dbcommands.c | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) (limited to 'src/backend/commands/dbcommands.c') diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index 2c401a6dbdc..d043d95b784 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.97 2002/07/20 05:16:57 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.98 2002/08/05 03:29:16 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -347,19 +347,8 @@ createdb(const CreatedbStmt *stmt) simple_heap_insert(pg_database_rel, tuple); - /* - * Update indexes - */ - if (RelationGetForm(pg_database_rel)->relhasindex) - { - Relation idescs[Num_pg_database_indices]; - - CatalogOpenIndices(Num_pg_database_indices, - Name_pg_database_indices, idescs); - CatalogIndexInsert(idescs, Num_pg_database_indices, pg_database_rel, - tuple); - CatalogCloseIndices(Num_pg_database_indices, idescs); - } + /* Update indexes */ + CatalogUpdateIndexes(pg_database_rel, tuple); /* Close pg_database, but keep lock till commit */ heap_close(pg_database_rel, NoLock); @@ -562,19 +551,8 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt) newtuple = heap_modifytuple(tuple, rel, repl_val, repl_null, repl_repl); simple_heap_update(rel, &tuple->t_self, newtuple); - /* - * Update indexes - */ - if (RelationGetForm(rel)->relhasindex) - { - Relation idescs[Num_pg_database_indices]; - - CatalogOpenIndices(Num_pg_database_indices, - Name_pg_database_indices, idescs); - CatalogIndexInsert(idescs, Num_pg_database_indices, rel, - newtuple); - CatalogCloseIndices(Num_pg_database_indices, idescs); - } + /* Update indexes */ + CatalogUpdateIndexes(rel, newtuple); heap_endscan(scan); heap_close(rel, RowExclusiveLock); -- cgit v1.2.3