From 34822e517ab8642cd7427d8f848a5fb0c98c6a0c Mon Sep 17 00:00:00 2001 From: Hiroshi Inoue Date: Fri, 23 Feb 2001 09:26:14 +0000 Subject: [PATCH] Reindex of shared system indexes must be overwrite mode. --- src/backend/catalog/index.c | 23 +++++++++++++++++++++-- src/backend/commands/indexcmds.c | 7 +++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index 1c2d6324cf..4d35ddeee8 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.140 2001/01/29 00:39:16 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.141 2001/02/23 09:26:14 inoue Exp $ * * * INTERFACE ROUTINES @@ -2087,7 +2087,12 @@ reindex_index(Oid indexId, bool force, bool inplace) #ifndef OLD_FILE_NAMING if (!inplace) - setNewRelfilenode(iRel); + { + inplace = IsSharedSystemRelationName(NameStr(iRel->rd_rel->relna +me)); + if (!inplace) + setNewRelfilenode(iRel); + } #endif /* OLD_FILE_NAMING */ /* Obtain exclusive lock on it, just to be sure */ LockRelation(iRel, AccessExclusiveLock); @@ -2196,6 +2201,20 @@ reindex_relation(Oid relid, bool force) elog(ERROR, "the target relation %u is nailed", relid); } #endif /* ENABLE_REINDEX_NAILED_RELATIONS */ + /* + * Shared system indexes must be overwritten because it's + * impossible to update pg_class tuples of all databases. + */ + if (IsSharedSystemRelationName(NameStr(rel->rd_rel->relname))) + { + if (IsIgnoringSystemIndexes()) + { + overwrite = true; + deactivate_needed = true; + } + else + elog(ERROR, "the target relation %u is shared", relid); + } RelationClose(rel); #endif /* OLD_FILE_NAMING */ old = SetReindexProcessing(true); diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 173c3a3d55..6497da615b 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.44 2001/01/24 19:42:52 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.45 2001/02/23 09:26:14 inoue Exp $ * *------------------------------------------------------------------------- */ @@ -633,6 +633,7 @@ void ReindexIndex(const char *name, bool force /* currently unused */ ) { HeapTuple tuple; + bool overwrite = false; /* ---------------- * REINDEX within a transaction block is dangerous, because @@ -656,7 +657,9 @@ ReindexIndex(const char *name, bool force /* currently unused */ ) #ifdef OLD_FILE_NAMING if (!reindex_index(tuple->t_data->t_oid, force, false)) #else - if (!reindex_index(tuple->t_data->t_oid, force, false)) + if (IsIgnoringSystemIndexes()) + overwrite = true; + if (!reindex_index(tuple->t_data->t_oid, force, overwrite)) #endif /* OLD_FILE_NAMING */ elog(NOTICE, "index \"%s\" wasn't reindexed", name); -- 2.40.0