Reindex of shared system indexes must be overwrite mode.
authorHiroshi Inoue <inoue@tpf.co.jp>
Fri, 23 Feb 2001 09:26:14 +0000 (09:26 +0000)
committerHiroshi Inoue <inoue@tpf.co.jp>
Fri, 23 Feb 2001 09:26:14 +0000 (09:26 +0000)
src/backend/catalog/index.c
src/backend/commands/indexcmds.c

index b172250d75e4d926c0ed420e8e2dc5c84ea81929..5accb47f884baec2978fd46fac6ca619f081e6f7 100644 (file)
@@ -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);
index 5b6f3410059cc49435cd7942857f4991c90b3bc0..3eeaad633f27cc5affeded357a5f1717db10a371 100644 (file)
@@ -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);