summaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands')
-rw-r--r--src/backend/commands/analyze.c10
-rw-r--r--src/backend/commands/async.c29
-rw-r--r--src/backend/commands/comment.c14
-rw-r--r--src/backend/commands/dbcommands.c32
-rw-r--r--src/backend/commands/functioncmds.c12
-rw-r--r--src/backend/commands/opclasscmds.c30
-rw-r--r--src/backend/commands/proclang.c11
-rw-r--r--src/backend/commands/tablecmds.c126
-rw-r--r--src/backend/commands/trigger.c26
-rw-r--r--src/backend/commands/user.c62
10 files changed, 65 insertions, 287 deletions
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
index 9844a5df0a..5cabe21d5f 100644
--- a/src/backend/commands/analyze.c
+++ b/src/backend/commands/analyze.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.40 2002/08/02 18:15:05 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.41 2002/08/05 03:29:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1670,7 +1670,6 @@ update_attstats(Oid relid, int natts, VacAttrStats **vacattrstats)
Datum values[Natts_pg_statistic];
char nulls[Natts_pg_statistic];
char replaces[Natts_pg_statistic];
- Relation irelations[Num_pg_statistic_indices];
/* Ignore attr if we weren't able to collect stats */
if (!stats->stats_valid)
@@ -1784,11 +1783,8 @@ update_attstats(Oid relid, int natts, VacAttrStats **vacattrstats)
simple_heap_insert(sd, stup);
}
- /* update indices too */
- CatalogOpenIndices(Num_pg_statistic_indices, Name_pg_statistic_indices,
- irelations);
- CatalogIndexInsert(irelations, Num_pg_statistic_indices, sd, stup);
- CatalogCloseIndices(Num_pg_statistic_indices, irelations);
+ /* update indexes too */
+ CatalogUpdateIndexes(sd, stup);
heap_freetuple(stup);
}
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 5f40f1617b..4c7c5f2110 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.87 2002/06/20 20:29:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.88 2002/08/05 03:29:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -245,14 +245,7 @@ Async_Listen(char *relname, int pid)
simple_heap_insert(lRel, tuple);
#ifdef NOT_USED /* currently there are no indexes */
- if (RelationGetForm(lRel)->relhasindex)
- {
- Relation idescs[Num_pg_listener_indices];
-
- CatalogOpenIndices(Num_pg_listener_indices, Name_pg_listener_indices, idescs);
- CatalogIndexInsert(idescs, Num_pg_listener_indices, lRel, tuple);
- CatalogCloseIndices(Num_pg_listener_indices, idescs);
- }
+ CatalogUpdateIndexes(lRel, tuple);
#endif
heap_freetuple(tuple);
@@ -529,14 +522,7 @@ AtCommit_Notify(void)
simple_heap_update(lRel, &lTuple->t_self, rTuple);
#ifdef NOT_USED /* currently there are no indexes */
- if (RelationGetForm(lRel)->relhasindex)
- {
- Relation idescs[Num_pg_listener_indices];
-
- CatalogOpenIndices(Num_pg_listener_indices, Name_pg_listener_indices, idescs);
- CatalogIndexInsert(idescs, Num_pg_listener_indices, lRel, rTuple);
- CatalogCloseIndices(Num_pg_listener_indices, idescs);
- }
+ CatalogUpdateIndexes(lRel, rTuple);
#endif
}
}
@@ -802,14 +788,7 @@ ProcessIncomingNotify(void)
simple_heap_update(lRel, &lTuple->t_self, rTuple);
#ifdef NOT_USED /* currently there are no indexes */
- if (RelationGetForm(lRel)->relhasindex)
- {
- Relation idescs[Num_pg_listener_indices];
-
- CatalogOpenIndices(Num_pg_listener_indices, Name_pg_listener_indices, idescs);
- CatalogIndexInsert(idescs, Num_pg_listener_indices, lRel, rTuple);
- CatalogCloseIndices(Num_pg_listener_indices, idescs);
- }
+ CatalogUpdateIndexes(lRel, rTuple);
#endif
}
}
diff --git a/src/backend/commands/comment.c b/src/backend/commands/comment.c
index 118c2c4b77..e244a82d1a 100644
--- a/src/backend/commands/comment.c
+++ b/src/backend/commands/comment.c
@@ -7,7 +7,7 @@
* Copyright (c) 1996-2001, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/comment.c,v 1.54 2002/08/02 18:15:05 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/comment.c,v 1.55 2002/08/05 03:29:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -206,19 +206,9 @@ CreateComments(Oid oid, Oid classoid, int32 subid, char *comment)
}
/* Update indexes, if necessary */
-
if (newtuple != NULL)
{
- if (RelationGetForm(description)->relhasindex)
- {
- Relation idescs[Num_pg_description_indices];
-
- CatalogOpenIndices(Num_pg_description_indices,
- Name_pg_description_indices, idescs);
- CatalogIndexInsert(idescs, Num_pg_description_indices, description,
- newtuple);
- CatalogCloseIndices(Num_pg_description_indices, idescs);
- }
+ CatalogUpdateIndexes(description, newtuple);
heap_freetuple(newtuple);
}
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 2c401a6dbd..d043d95b78 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);
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c
index ea858d5571..944ae192a0 100644
--- a/src/backend/commands/functioncmds.c
+++ b/src/backend/commands/functioncmds.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/functioncmds.c,v 1.15 2002/07/29 23:44:44 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/functioncmds.c,v 1.16 2002/08/05 03:29:16 tgl Exp $
*
* DESCRIPTION
* These routines take the parse tree and pick out the
@@ -685,16 +685,10 @@ CreateCast(CreateCastStmt *stmt)
nulls[i] = ' ';
tuple = heap_formtuple(RelationGetDescr(relation), values, nulls);
- simple_heap_insert(relation, tuple);
- if (RelationGetForm(relation)->relhasindex)
- {
- Relation idescs[Num_pg_cast_indices];
+ simple_heap_insert(relation, tuple);
- CatalogOpenIndices(Num_pg_cast_indices, Name_pg_cast_indices, idescs);
- CatalogIndexInsert(idescs, Num_pg_cast_indices, relation, tuple);
- CatalogCloseIndices(Num_pg_cast_indices, idescs);
- }
+ CatalogUpdateIndexes(relation, tuple);
myself.classId = RelationGetRelid(relation);
myself.objectId = HeapTupleGetOid(tuple);
diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c
index c56b0e1fa8..f544dc9886 100644
--- a/src/backend/commands/opclasscmds.c
+++ b/src/backend/commands/opclasscmds.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/opclasscmds.c,v 1.2 2002/07/29 23:46:35 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/opclasscmds.c,v 1.3 2002/08/05 03:29:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -286,15 +286,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
opclassoid = simple_heap_insert(rel, tup);
- if (RelationGetForm(rel)->relhasindex)
- {
- Relation idescs[Num_pg_opclass_indices];
-
- CatalogOpenIndices(Num_pg_opclass_indices, Name_pg_opclass_indices,
- idescs);
- CatalogIndexInsert(idescs, Num_pg_opclass_indices, rel, tup);
- CatalogCloseIndices(Num_pg_opclass_indices, idescs);
- }
+ CatalogUpdateIndexes(rel, tup);
heap_freetuple(tup);
@@ -395,15 +387,8 @@ storeOperators(Oid opclassoid, int numOperators,
simple_heap_insert(rel, tup);
- if (RelationGetForm(rel)->relhasindex)
- {
- Relation idescs[Num_pg_amop_indices];
+ CatalogUpdateIndexes(rel, tup);
- CatalogOpenIndices(Num_pg_amop_indices, Name_pg_amop_indices,
- idescs);
- CatalogIndexInsert(idescs, Num_pg_amop_indices, rel, tup);
- CatalogCloseIndices(Num_pg_amop_indices, idescs);
- }
heap_freetuple(tup);
}
@@ -444,15 +429,8 @@ storeProcedures(Oid opclassoid, int numProcs, Oid *procedures)
simple_heap_insert(rel, tup);
- if (RelationGetForm(rel)->relhasindex)
- {
- Relation idescs[Num_pg_amproc_indices];
+ CatalogUpdateIndexes(rel, tup);
- CatalogOpenIndices(Num_pg_amproc_indices, Name_pg_amproc_indices,
- idescs);
- CatalogIndexInsert(idescs, Num_pg_amproc_indices, rel, tup);
- CatalogCloseIndices(Num_pg_amproc_indices, idescs);
- }
heap_freetuple(tup);
}
diff --git a/src/backend/commands/proclang.c b/src/backend/commands/proclang.c
index 567b59dae8..0c28dea731 100644
--- a/src/backend/commands/proclang.c
+++ b/src/backend/commands/proclang.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/proclang.c,v 1.38 2002/07/24 19:11:09 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/proclang.c,v 1.39 2002/08/05 03:29:17 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -119,14 +119,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
simple_heap_insert(rel, tup);
- if (RelationGetForm(rel)->relhasindex)
- {
- Relation idescs[Num_pg_language_indices];
-
- CatalogOpenIndices(Num_pg_language_indices, Name_pg_language_indices, idescs);
- CatalogIndexInsert(idescs, Num_pg_language_indices, rel, tup);
- CatalogCloseIndices(Num_pg_language_indices, idescs);
- }
+ CatalogUpdateIndexes(rel, tup);
/*
* Create dependencies for language
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 4972c09b4a..eedc1a9dad 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.26 2002/08/02 18:15:06 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.27 2002/08/05 03:29:17 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -325,7 +325,7 @@ RemoveRelation(const RangeVar *relation, DropBehavior behavior)
* BadArg if name is invalid
*
* Note:
- * Rows are removed, indices are truncated and reconstructed.
+ * Rows are removed, indexes are truncated and reconstructed.
*/
void
TruncateRelation(const RangeVar *relation)
@@ -832,14 +832,7 @@ StoreCatalogInheritance(Oid relationId, List *supers)
simple_heap_insert(relation, tuple);
- if (RelationGetForm(relation)->relhasindex)
- {
- Relation idescs[Num_pg_inherits_indices];
-
- CatalogOpenIndices(Num_pg_inherits_indices, Name_pg_inherits_indices, idescs);
- CatalogIndexInsert(idescs, Num_pg_inherits_indices, relation, tuple);
- CatalogCloseIndices(Num_pg_inherits_indices, idescs);
- }
+ CatalogUpdateIndexes(relation, tuple);
heap_freetuple(tuple);
@@ -969,7 +962,6 @@ setRelhassubclassInRelation(Oid relationId, bool relhassubclass)
{
Relation relationRelation;
HeapTuple tuple;
- Relation idescs[Num_pg_class_indices];
/*
* Fetch a modifiable copy of the tuple, modify it, update pg_class.
@@ -984,10 +976,8 @@ setRelhassubclassInRelation(Oid relationId, bool relhassubclass)
((Form_pg_class) GETSTRUCT(tuple))->relhassubclass = relhassubclass;
simple_heap_update(relationRelation, &tuple->t_self, tuple);
- /* keep the catalog indices up to date */
- CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, idescs);
- CatalogIndexInsert(idescs, Num_pg_class_indices, relationRelation, tuple);
- CatalogCloseIndices(Num_pg_class_indices, idescs);
+ /* keep the catalog indexes up to date */
+ CatalogUpdateIndexes(relationRelation, tuple);
heap_freetuple(tuple);
heap_close(relationRelation, RowExclusiveLock);
@@ -1097,14 +1087,8 @@ renameatt(Oid relid,
simple_heap_update(attrelation, &atttup->t_self, atttup);
- /* keep system catalog indices current */
- {
- Relation irelations[Num_pg_attr_indices];
-
- CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, irelations);
- CatalogIndexInsert(irelations, Num_pg_attr_indices, attrelation, atttup);
- CatalogCloseIndices(Num_pg_attr_indices, irelations);
- }
+ /* keep system catalog indexes current */
+ CatalogUpdateIndexes(attrelation, atttup);
heap_freetuple(atttup);
@@ -1151,14 +1135,9 @@ renameatt(Oid relid,
simple_heap_update(attrelation, &atttup->t_self, atttup);
- /* keep system catalog indices current */
- {
- Relation irelations[Num_pg_attr_indices];
+ /* keep system catalog indexes current */
+ CatalogUpdateIndexes(attrelation, atttup);
- CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, irelations);
- CatalogIndexInsert(irelations, Num_pg_attr_indices, attrelation, atttup);
- CatalogCloseIndices(Num_pg_attr_indices, irelations);
- }
heap_freetuple(atttup);
}
@@ -1203,7 +1182,6 @@ renamerel(Oid relid, const char *newrelname)
char *oldrelname;
char relkind;
bool relhastriggers;
- Relation irelations[Num_pg_class_indices];
/*
* Grab an exclusive lock on the target table or index, which we will
@@ -1247,10 +1225,8 @@ renamerel(Oid relid, const char *newrelname)
simple_heap_update(relrelation, &reltup->t_self, reltup);
- /* keep the system catalog indices current */
- CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, irelations);
- CatalogIndexInsert(irelations, Num_pg_class_indices, relrelation, reltup);
- CatalogCloseIndices(Num_pg_class_indices, irelations);
+ /* keep the system catalog indexes current */
+ CatalogUpdateIndexes(relrelation, reltup);
heap_close(relrelation, NoLock);
heap_freetuple(reltup);
@@ -1481,13 +1457,7 @@ update_ri_trigger_args(Oid relid,
*/
simple_heap_update(tgrel, &tuple->t_self, tuple);
- {
- Relation irelations[Num_pg_attr_indices];
-
- CatalogOpenIndices(Num_pg_trigger_indices, Name_pg_trigger_indices, irelations);
- CatalogIndexInsert(irelations, Num_pg_trigger_indices, tgrel, tuple);
- CatalogCloseIndices(Num_pg_trigger_indices, irelations);
- }
+ CatalogUpdateIndexes(tgrel, tuple);
/* free up our scratch memory */
pfree(newtgargs);
@@ -1703,14 +1673,7 @@ AlterTableAddColumn(Oid myrelid,
simple_heap_insert(attrdesc, attributeTuple);
/* Update indexes on pg_attribute */
- if (RelationGetForm(attrdesc)->relhasindex)
- {
- Relation idescs[Num_pg_attr_indices];
-
- CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, idescs);
- CatalogIndexInsert(idescs, Num_pg_attr_indices, attrdesc, attributeTuple);
- CatalogCloseIndices(Num_pg_attr_indices, idescs);
- }
+ CatalogUpdateIndexes(attrdesc, attributeTuple);
heap_close(attrdesc, RowExclusiveLock);
@@ -1723,15 +1686,8 @@ AlterTableAddColumn(Oid myrelid,
AssertTupleDescHasOid(pgclass->rd_att);
simple_heap_update(pgclass, &newreltup->t_self, newreltup);
- /* keep catalog indices current */
- if (RelationGetForm(pgclass)->relhasindex)
- {
- Relation ridescs[Num_pg_class_indices];
-
- CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, ridescs);
- CatalogIndexInsert(ridescs, Num_pg_class_indices, pgclass, newreltup);
- CatalogCloseIndices(Num_pg_class_indices, ridescs);
- }
+ /* keep catalog indexes current */
+ CatalogUpdateIndexes(pgclass, newreltup);
heap_freetuple(newreltup);
ReleaseSysCache(reltup);
@@ -1850,7 +1806,7 @@ AlterTableAlterColumnDropNotNull(Oid myrelid,
* Check that the attribute is not in a primary key
*/
- /* Loop over all indices on the relation */
+ /* Loop over all indexes on the relation */
indexoidlist = RelationGetIndexList(rel);
foreach(indexoidscan, indexoidlist)
@@ -1902,15 +1858,8 @@ AlterTableAlterColumnDropNotNull(Oid myrelid,
simple_heap_update(attr_rel, &tuple->t_self, tuple);
- /* keep the system catalog indices current */
- if (RelationGetForm(attr_rel)->relhasindex)
- {
- Relation idescs[Num_pg_attr_indices];
-
- CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, idescs);
- CatalogIndexInsert(idescs, Num_pg_attr_indices, attr_rel, tuple);
- CatalogCloseIndices(Num_pg_attr_indices, idescs);
- }
+ /* keep the system catalog indexes current */
+ CatalogUpdateIndexes(attr_rel, tuple);
heap_close(attr_rel, RowExclusiveLock);
@@ -2023,15 +1972,8 @@ AlterTableAlterColumnSetNotNull(Oid myrelid,
simple_heap_update(attr_rel, &tuple->t_self, tuple);
- /* keep the system catalog indices current */
- if (RelationGetForm(attr_rel)->relhasindex)
- {
- Relation idescs[Num_pg_attr_indices];
-
- CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, idescs);
- CatalogIndexInsert(idescs, Num_pg_attr_indices, attr_rel, tuple);
- CatalogCloseIndices(Num_pg_attr_indices, idescs);
- }
+ /* keep the system catalog indexes current */
+ CatalogUpdateIndexes(attr_rel, tuple);
heap_close(attr_rel, RowExclusiveLock);
@@ -2278,16 +2220,11 @@ AlterTableAlterColumnFlags(Oid myrelid,
simple_heap_update(attrelation, &tuple->t_self, tuple);
- /* keep system catalog indices current */
- {
- Relation irelations[Num_pg_attr_indices];
-
- CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, irelations);
- CatalogIndexInsert(irelations, Num_pg_attr_indices, attrelation, tuple);
- CatalogCloseIndices(Num_pg_attr_indices, irelations);
- }
+ /* keep system catalog indexes current */
+ CatalogUpdateIndexes(attrelation, tuple);
heap_freetuple(tuple);
+
heap_close(attrelation, NoLock);
heap_close(rel, NoLock); /* close rel, but keep lock! */
}
@@ -3200,7 +3137,6 @@ AlterTableOwner(Oid relationOid, int32 newOwnerSysId)
Relation target_rel;
Relation class_rel;
HeapTuple tuple;
- Relation idescs[Num_pg_class_indices];
Form_pg_class tuple_class;
/* Get exclusive lock till end of transaction on the target table */
@@ -3227,10 +3163,8 @@ AlterTableOwner(Oid relationOid, int32 newOwnerSysId)
tuple_class->relowner = newOwnerSysId;
simple_heap_update(class_rel, &tuple->t_self, tuple);
- /* Keep the catalog indices up to date */
- CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, idescs);
- CatalogIndexInsert(idescs, Num_pg_class_indices, class_rel, tuple);
- CatalogCloseIndices(Num_pg_class_indices, idescs);
+ /* Keep the catalog indexes up to date */
+ CatalogUpdateIndexes(class_rel, tuple);
/*
* If we are operating on a table, also change the ownership of any
@@ -3299,7 +3233,6 @@ AlterTableCreateToastTable(Oid relOid, bool silent)
bool shared_relation;
Relation class_rel;
Buffer buffer;
- Relation ridescs[Num_pg_class_indices];
Oid toast_relid;
Oid toast_idxid;
char toast_relname[NAMEDATALEN];
@@ -3481,14 +3414,11 @@ AlterTableCreateToastTable(Oid relOid, bool silent)
* Store the toast table's OID in the parent relation's tuple
*/
((Form_pg_class) GETSTRUCT(reltup))->reltoastrelid = toast_relid;
+
simple_heap_update(class_rel, &reltup->t_self, reltup);
- /*
- * Keep catalog indices current
- */
- CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, ridescs);
- CatalogIndexInsert(ridescs, Num_pg_class_indices, class_rel, reltup);
- CatalogCloseIndices(Num_pg_class_indices, ridescs);
+ /* Keep catalog indexes current */
+ CatalogUpdateIndexes(class_rel, reltup);
heap_freetuple(reltup);
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index 353d684d90..7fa570890d 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
diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c
index d464b5588c..60fc4b733c 100644
--- a/src/backend/commands/user.c
+++ b/src/backend/commands/user.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.106 2002/07/24 19:11:09 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.107 2002/08/05 03:29:17 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -597,19 +597,8 @@ CreateUser(CreateUserStmt *stmt)
*/
simple_heap_insert(pg_shadow_rel, tuple);
- /*
- * Update indexes
- */
- if (RelationGetForm(pg_shadow_rel)->relhasindex)
- {
- Relation idescs[Num_pg_shadow_indices];
-
- CatalogOpenIndices(Num_pg_shadow_indices,
- Name_pg_shadow_indices, idescs);
- CatalogIndexInsert(idescs, Num_pg_shadow_indices, pg_shadow_rel,
- tuple);
- CatalogCloseIndices(Num_pg_shadow_indices, idescs);
- }
+ /* Update indexes */
+ CatalogUpdateIndexes(pg_shadow_rel, tuple);
/*
* Add the user to the groups specified. We'll just call the below
@@ -809,16 +798,7 @@ AlterUser(AlterUserStmt *stmt)
simple_heap_update(pg_shadow_rel, &tuple->t_self, new_tuple);
/* Update indexes */
- if (RelationGetForm(pg_shadow_rel)->relhasindex)
- {
- Relation idescs[Num_pg_shadow_indices];
-
- CatalogOpenIndices(Num_pg_shadow_indices,
- Name_pg_shadow_indices, idescs);
- CatalogIndexInsert(idescs, Num_pg_shadow_indices, pg_shadow_rel,
- new_tuple);
- CatalogCloseIndices(Num_pg_shadow_indices, idescs);
- }
+ CatalogUpdateIndexes(pg_shadow_rel, new_tuple);
ReleaseSysCache(tuple);
heap_freetuple(new_tuple);
@@ -898,13 +878,7 @@ AlterUserSet(AlterUserSetStmt *stmt)
newtuple = heap_modifytuple(oldtuple, rel, repl_val, repl_null, repl_repl);
simple_heap_update(rel, &oldtuple->t_self, newtuple);
- {
- Relation idescs[Num_pg_shadow_indices];
-
- CatalogOpenIndices(Num_pg_shadow_indices, Name_pg_shadow_indices, idescs);
- CatalogIndexInsert(idescs, Num_pg_shadow_indices, rel, newtuple);
- CatalogCloseIndices(Num_pg_shadow_indices, idescs);
- }
+ CatalogUpdateIndexes(rel, newtuple);
ReleaseSysCache(oldtuple);
heap_close(rel, RowExclusiveLock);
@@ -1216,19 +1190,8 @@ CreateGroup(CreateGroupStmt *stmt)
*/
simple_heap_insert(pg_group_rel, tuple);
- /*
- * Update indexes
- */
- if (RelationGetForm(pg_group_rel)->relhasindex)
- {
- Relation idescs[Num_pg_group_indices];
-
- CatalogOpenIndices(Num_pg_group_indices,
- Name_pg_group_indices, idescs);
- CatalogIndexInsert(idescs, Num_pg_group_indices, pg_group_rel,
- tuple);
- CatalogCloseIndices(Num_pg_group_indices, idescs);
- }
+ /* Update indexes */
+ CatalogUpdateIndexes(pg_group_rel, tuple);
heap_close(pg_group_rel, NoLock);
@@ -1417,16 +1380,7 @@ UpdateGroupMembership(Relation group_rel, HeapTuple group_tuple,
simple_heap_update(group_rel, &group_tuple->t_self, tuple);
/* Update indexes */
- if (RelationGetForm(group_rel)->relhasindex)
- {
- Relation idescs[Num_pg_group_indices];
-
- CatalogOpenIndices(Num_pg_group_indices,
- Name_pg_group_indices, idescs);
- CatalogIndexInsert(idescs, Num_pg_group_indices, group_rel,
- tuple);
- CatalogCloseIndices(Num_pg_group_indices, idescs);
- }
+ CatalogUpdateIndexes(group_rel, tuple);
}