Change reindex command to work properly with gist/hash/rtree

This commit is contained in:
Hiroshi Inoue 2000-03-01 05:39:24 +00:00
parent ab3dc66426
commit a50aaa7289
4 changed files with 19 additions and 17 deletions

View File

@ -6,7 +6,7 @@
* *
* *
* IDENTIFICATION * 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 hrelid = RelationGetRelid(heap);
Oid irelid = RelationGetRelid(index); Oid irelid = RelationGetRelid(index);
bool inplace = IsReindexProcessing();
heap_close(heap, NoLock); heap_close(heap, NoLock);
index_close(index); index_close(index);
UpdateStats(hrelid, nh, true); UpdateStats(hrelid, nh, inplace);
UpdateStats(irelid, ni, false); UpdateStats(irelid, ni, inplace);
if (oldPred != NULL) if (oldPred != NULL && !inplace)
{ {
if (ni == nh) if (ni == nh)
pred = NULL; pred = NULL;

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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 * NOTES
* This file contains only the public interface routines. * This file contains only the public interface routines.
@ -242,12 +242,13 @@ hashbuild(Relation heap,
{ {
Oid hrelid = RelationGetRelid(heap); Oid hrelid = RelationGetRelid(heap);
Oid irelid = RelationGetRelid(index); Oid irelid = RelationGetRelid(index);
bool inplace = IsReindexProcessing();
heap_close(heap, NoLock); heap_close(heap, NoLock);
index_close(index); index_close(index);
UpdateStats(hrelid, nhtups, true); UpdateStats(hrelid, nhtups, inplace);
UpdateStats(irelid, nitups, false); UpdateStats(irelid, nitups, inplace);
if (oldPred != NULL) if (oldPred != NULL && !inplace)
{ {
if (nitups == nhtups) if (nitups == nhtups)
pred = NULL; pred = NULL;

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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 hrelid = RelationGetRelid(heap);
Oid irelid = RelationGetRelid(index); Oid irelid = RelationGetRelid(index);
bool inplace = IsReindexProcessing();
heap_close(heap, NoLock); heap_close(heap, NoLock);
index_close(index); index_close(index);
UpdateStats(hrelid, nh, true); UpdateStats(hrelid, nh, inplace);
UpdateStats(irelid, ni, false); UpdateStats(irelid, ni, inplace);
if (oldPred != NULL) if (oldPred != NULL && !inplace)
{ {
if (ni == nh) if (ni == nh)
pred = NULL; pred = NULL;

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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 * INTERFACE ROUTINES
@ -2057,7 +2057,6 @@ reindex_index(Oid indexId, bool force)
Oid heapId, procId, accessMethodId; Oid heapId, procId, accessMethodId;
Node *oldPred = NULL; Node *oldPred = NULL;
PredInfo *predInfo; PredInfo *predInfo;
List *cnfPred = NULL;
AttrNumber *attributeNumberA; AttrNumber *attributeNumberA;
FuncIndexInfo fInfo, *funcInfo = NULL; FuncIndexInfo fInfo, *funcInfo = NULL;
int i, numberOfAttributes; int i, numberOfAttributes;
@ -2096,8 +2095,8 @@ reindex_index(Oid indexId, bool force)
pfree(predString); pfree(predString);
} }
predInfo = (PredInfo *) palloc(sizeof(PredInfo)); predInfo = (PredInfo *) palloc(sizeof(PredInfo));
predInfo->pred = (Node *) cnfPred; predInfo->pred = (Node *) oldPred;
predInfo->oldPred = oldPred; predInfo->oldPred = NULL;
/* Assign Index keys to attributes array */ /* Assign Index keys to attributes array */
attributeNumberA = (AttrNumber *) palloc(numberOfAttributes * sizeof(AttrNumber)); attributeNumberA = (AttrNumber *) palloc(numberOfAttributes * sizeof(AttrNumber));
@ -2247,5 +2246,5 @@ reindex_relation(Oid relid, bool force)
setRelhasindexInplace(relid, true, false); setRelhasindexInplace(relid, true, false);
} }
SetReindexProcessing(old); SetReindexProcessing(old);
return true; return reindexed;
} }