Skip to content

Commit d1c6416

Browse files
committed
Update with newer version of CLUSTER patch posted August 8.
> Looks like Alvaro got sideswiped by the system catalog indexing changes > I made over the weekend. It's a simple change, just reduce the whole > mess to a "CatalogUpdateIndexes()" call. I update two tuples, so I manually CatalogOpenIndexes() and CatalogIndexInsert() two times, as per comments in CatalogUpdateIndexes(). I also removed a couple of useless CommandCounterIncrement(), some useless definitions in src/include/commands/cluster.h and useless includes in src/backend/commands/cluster.c. This version passes the regression test I had made for previous versions. Alvaro Herrera
1 parent 8db20b4 commit d1c6416

File tree

2 files changed

+7
-23
lines changed

2 files changed

+7
-23
lines changed

src/backend/commands/cluster.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.84 2002/08/10 20:43:46 momjian Exp $
18+
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.85 2002/08/10 21:00:34 momjian Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -29,12 +29,9 @@
2929
#include "catalog/index.h"
3030
#include "catalog/indexing.h"
3131
#include "catalog/catname.h"
32-
#include "catalog/pg_index.h"
33-
#include "catalog/pg_proc.h"
3432
#include "commands/cluster.h"
3533
#include "commands/tablecmds.h"
3634
#include "miscadmin.h"
37-
#include "utils/builtins.h"
3835
#include "utils/fmgroids.h"
3936
#include "utils/lsyscache.h"
4037
#include "utils/syscache.h"
@@ -81,8 +78,6 @@ Relation RelationIdGetRelation(Oid relationId);
8178
* AccessExclusiveLock right before swapping the filenodes.
8279
* This would allow users to CLUSTER on a regular basis,
8380
* practically eliminating the need for auto-clustered indexes.
84-
*
85-
* Preserve constraint bit for the indexes.
8681
*/
8782
void
8883
cluster(RangeVar *oldrelation, char *oldindexname)
@@ -349,9 +344,6 @@ recreate_indexattr(Oid OIDOldHeap, List *indexes)
349344
swap_relfilenodes(newIndexOID, attrs->indexOID);
350345
setRelhasindex(OIDOldHeap, true, attrs->isPrimary, InvalidOid);
351346

352-
/* I'm not sure this one is needed, but let's be safe. */
353-
CommandCounterIncrement();
354-
355347
/* Destroy new index with old filenode */
356348
object.classId = RelOid_pg_class;
357349
object.objectId = newIndexOID;
@@ -380,11 +372,11 @@ swap_relfilenodes(Oid r1, Oid r2)
380372
* it every time.
381373
*/
382374
Relation relRelation,
383-
irels[Num_pg_class_indices],
384375
rel;
385376
HeapTuple reltup[2];
386377
Oid tempRFNode;
387378
int i;
379+
CatalogIndexState indstate;
388380

389381
/* We need both RelationRelationName tuples. */
390382
relRelation = heap_openr(RelationRelationName, RowExclusiveLock);
@@ -429,11 +421,10 @@ swap_relfilenodes(Oid r1, Oid r2)
429421
simple_heap_update(relRelation, &reltup[0]->t_self, reltup[0]);
430422

431423
/* To keep system catalogs current. */
432-
CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, irels);
433-
CatalogIndexInsert(irels, Num_pg_class_indices, relRelation, reltup[1]);
434-
CatalogIndexInsert(irels, Num_pg_class_indices, relRelation, reltup[0]);
435-
CatalogCloseIndices(Num_pg_class_indices, irels);
436-
CommandCounterIncrement();
424+
indstate = CatalogOpenIndexes(relRelation);
425+
CatalogIndexInsert(indstate, reltup[1]);
426+
CatalogIndexInsert(indstate, reltup[0]);
427+
CatalogCloseIndexes(indstate);
437428

438429
heap_close(relRelation, NoLock);
439430
heap_freetuple(reltup[0]);

src/include/commands/cluster.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,13 @@
66
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994-5, Regents of the University of California
88
*
9-
* $Id: cluster.h,v 1.14 2002/06/20 20:29:49 momjian Exp $
9+
* $Id: cluster.h,v 1.15 2002/08/10 21:00:34 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
1313
#ifndef CLUSTER_H
1414
#define CLUSTER_H
1515

16-
/*
17-
* defines for contant stuff
18-
*/
19-
#define _TEMP_RELATION_KEY_ "clXXXXXXXX"
20-
#define _SIZE_OF_TEMP_RELATION_KEY_ 11
21-
22-
2316
/*
2417
* functions
2518
*/

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