Change reindex command to work properly with gist/hash/rtree
authorHiroshi Inoue
Wed, 1 Mar 2000 05:39:24 +0000 (05:39 +0000)
committerHiroshi Inoue
Wed, 1 Mar 2000 05:39:24 +0000 (05:39 +0000)
src/backend/access/gist/gist.c
src/backend/access/hash/hash.c
src/backend/access/rtree/rtree.c
src/backend/catalog/index.c

index edebfcbebe3799b4446bfb1865952362da709aec..78a41dbb8ff5719ed3995a5ec12b5b4189adb4c6 100644 (file)
@@ -6,7 +6,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.50 2000/01/19 23:54:46 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.51 2000/03/01 05:39:20 inoue Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -284,12 +284,13 @@ gistbuild(Relation heap,
    {
        Oid     hrelid = RelationGetRelid(heap);
        Oid     irelid = RelationGetRelid(index);
+       bool        inplace = IsReindexProcessing();
 
        heap_close(heap, NoLock);
        index_close(index);
-       UpdateStats(hrelid, nh, true);
-       UpdateStats(irelid, ni, false);
-       if (oldPred != NULL)
+       UpdateStats(hrelid, nh, inplace);
+       UpdateStats(irelid, ni, inplace);
+       if (oldPred != NULL && !inplace)
        {
            if (ni == nh)
                pred = NULL;
index a35cd86845e8750d1b602c091ad16503d02cd309..d116aa1a4997131f44738527c1d180c45cfb6c50 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.35 2000/01/26 05:55:55 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.36 2000/03/01 05:39:22 inoue Exp $
  *
  * NOTES
  *   This file contains only the public interface routines.
@@ -242,12 +242,13 @@ hashbuild(Relation heap,
    {
        Oid     hrelid = RelationGetRelid(heap);
        Oid     irelid = RelationGetRelid(index);
+       bool        inplace = IsReindexProcessing();
 
        heap_close(heap, NoLock);
        index_close(index);
-       UpdateStats(hrelid, nhtups, true);
-       UpdateStats(irelid, nitups, false);
-       if (oldPred != NULL)
+       UpdateStats(hrelid, nhtups, inplace);
+       UpdateStats(irelid, nitups, inplace);
+       if (oldPred != NULL && !inplace)
        {
            if (nitups == nhtups)
                pred = NULL;
index 53c9d7946bfbd02fd933f44bfd9b21bbc59ef6c8..34cf0b6c9370e1d038d232b744871a2fdfda717e 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.43 2000/01/26 05:56:00 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.44 2000/03/01 05:39:23 inoue Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -261,12 +261,13 @@ rtbuild(Relation heap,
    {
        Oid     hrelid = RelationGetRelid(heap);
        Oid     irelid = RelationGetRelid(index);
+       bool        inplace = IsReindexProcessing();
 
        heap_close(heap, NoLock);
        index_close(index);
-       UpdateStats(hrelid, nh, true);
-       UpdateStats(irelid, ni, false);
-       if (oldPred != NULL)
+       UpdateStats(hrelid, nh, inplace);
+       UpdateStats(irelid, ni, inplace);
+       if (oldPred != NULL && !inplace)
        {
            if (ni == nh)
                pred = NULL;
index 5bfc332f0dbebd5659d151eda3884df2f3a0db6e..2a4cd3e6c5efcb5c2e880a49c87da825e93327f0 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.106 2000/02/25 02:58:47 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.107 2000/03/01 05:39:24 inoue Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -2057,7 +2057,6 @@ reindex_index(Oid indexId, bool force)
    Oid     heapId, procId, accessMethodId;
    Node        *oldPred = NULL;
    PredInfo    *predInfo;
-   List        *cnfPred = NULL;
    AttrNumber  *attributeNumberA;
    FuncIndexInfo   fInfo, *funcInfo = NULL;
    int     i, numberOfAttributes;
@@ -2096,8 +2095,8 @@ reindex_index(Oid indexId, bool force)
        pfree(predString);
    }
    predInfo = (PredInfo *) palloc(sizeof(PredInfo));
-   predInfo->pred = (Node *) cnfPred;
-   predInfo->oldPred = oldPred;
+   predInfo->pred = (Node *) oldPred;
+   predInfo->oldPred = NULL;
 
    /* Assign Index keys to attributes array */
    attributeNumberA = (AttrNumber *) palloc(numberOfAttributes * sizeof(AttrNumber));
@@ -2247,5 +2246,5 @@ reindex_relation(Oid relid, bool force)
        setRelhasindexInplace(relid, true, false);
    }
    SetReindexProcessing(old);
-   return true;
+   return reindexed;
 }