Skip to content

Commit a50aaa7

Browse files
author
Hiroshi Inoue
committed
Change reindex command to work properly with gist/hash/rtree
1 parent ab3dc66 commit a50aaa7

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

src/backend/access/gist/gist.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.50 2000/01/19 23:54:46 tgl Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.51 2000/03/01 05:39:20 inoue Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -284,12 +284,13 @@ gistbuild(Relation heap,
284284
{
285285
Oid hrelid = RelationGetRelid(heap);
286286
Oid irelid = RelationGetRelid(index);
287+
bool inplace = IsReindexProcessing();
287288

288289
heap_close(heap, NoLock);
289290
index_close(index);
290-
UpdateStats(hrelid, nh, true);
291-
UpdateStats(irelid, ni, false);
292-
if (oldPred != NULL)
291+
UpdateStats(hrelid, nh, inplace);
292+
UpdateStats(irelid, ni, inplace);
293+
if (oldPred != NULL && !inplace)
293294
{
294295
if (ni == nh)
295296
pred = NULL;

src/backend/access/hash/hash.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.35 2000/01/26 05:55:55 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.36 2000/03/01 05:39:22 inoue Exp $
1212
*
1313
* NOTES
1414
* This file contains only the public interface routines.
@@ -242,12 +242,13 @@ hashbuild(Relation heap,
242242
{
243243
Oid hrelid = RelationGetRelid(heap);
244244
Oid irelid = RelationGetRelid(index);
245+
bool inplace = IsReindexProcessing();
245246

246247
heap_close(heap, NoLock);
247248
index_close(index);
248-
UpdateStats(hrelid, nhtups, true);
249-
UpdateStats(irelid, nitups, false);
250-
if (oldPred != NULL)
249+
UpdateStats(hrelid, nhtups, inplace);
250+
UpdateStats(irelid, nitups, inplace);
251+
if (oldPred != NULL && !inplace)
251252
{
252253
if (nitups == nhtups)
253254
pred = NULL;

src/backend/access/rtree/rtree.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.43 2000/01/26 05:56:00 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.44 2000/03/01 05:39:23 inoue Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -261,12 +261,13 @@ rtbuild(Relation heap,
261261
{
262262
Oid hrelid = RelationGetRelid(heap);
263263
Oid irelid = RelationGetRelid(index);
264+
bool inplace = IsReindexProcessing();
264265

265266
heap_close(heap, NoLock);
266267
index_close(index);
267-
UpdateStats(hrelid, nh, true);
268-
UpdateStats(irelid, ni, false);
269-
if (oldPred != NULL)
268+
UpdateStats(hrelid, nh, inplace);
269+
UpdateStats(irelid, ni, inplace);
270+
if (oldPred != NULL && !inplace)
270271
{
271272
if (ni == nh)
272273
pred = NULL;

src/backend/catalog/index.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.106 2000/02/25 02:58:47 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.107 2000/03/01 05:39:24 inoue Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -2057,7 +2057,6 @@ reindex_index(Oid indexId, bool force)
20572057
Oid heapId, procId, accessMethodId;
20582058
Node *oldPred = NULL;
20592059
PredInfo *predInfo;
2060-
List *cnfPred = NULL;
20612060
AttrNumber *attributeNumberA;
20622061
FuncIndexInfo fInfo, *funcInfo = NULL;
20632062
int i, numberOfAttributes;
@@ -2096,8 +2095,8 @@ reindex_index(Oid indexId, bool force)
20962095
pfree(predString);
20972096
}
20982097
predInfo = (PredInfo *) palloc(sizeof(PredInfo));
2099-
predInfo->pred = (Node *) cnfPred;
2100-
predInfo->oldPred = oldPred;
2098+
predInfo->pred = (Node *) oldPred;
2099+
predInfo->oldPred = NULL;
21012100

21022101
/* Assign Index keys to attributes array */
21032102
attributeNumberA = (AttrNumber *) palloc(numberOfAttributes * sizeof(AttrNumber));
@@ -2247,5 +2246,5 @@ reindex_relation(Oid relid, bool force)
22472246
setRelhasindexInplace(relid, true, false);
22482247
}
22492248
SetReindexProcessing(old);
2250-
return true;
2249+
return reindexed;
22512250
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy