mirror of
https://github.com/postgres/postgres.git
synced 2025-07-17 06:41:09 +03:00
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.
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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];
|
||||
|
||||
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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user