Commit d1c64162 authored by Bruce Momjian's avatar Bruce Momjian

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
parent 8db20b4a
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.84 2002/08/10 20:43:46 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.85 2002/08/10 21:00:34 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -29,12 +29,9 @@ ...@@ -29,12 +29,9 @@
#include "catalog/index.h" #include "catalog/index.h"
#include "catalog/indexing.h" #include "catalog/indexing.h"
#include "catalog/catname.h" #include "catalog/catname.h"
#include "catalog/pg_index.h"
#include "catalog/pg_proc.h"
#include "commands/cluster.h" #include "commands/cluster.h"
#include "commands/tablecmds.h" #include "commands/tablecmds.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h" #include "utils/fmgroids.h"
#include "utils/lsyscache.h" #include "utils/lsyscache.h"
#include "utils/syscache.h" #include "utils/syscache.h"
...@@ -81,8 +78,6 @@ Relation RelationIdGetRelation(Oid relationId); ...@@ -81,8 +78,6 @@ Relation RelationIdGetRelation(Oid relationId);
* AccessExclusiveLock right before swapping the filenodes. * AccessExclusiveLock right before swapping the filenodes.
* This would allow users to CLUSTER on a regular basis, * This would allow users to CLUSTER on a regular basis,
* practically eliminating the need for auto-clustered indexes. * practically eliminating the need for auto-clustered indexes.
*
* Preserve constraint bit for the indexes.
*/ */
void void
cluster(RangeVar *oldrelation, char *oldindexname) cluster(RangeVar *oldrelation, char *oldindexname)
...@@ -349,9 +344,6 @@ recreate_indexattr(Oid OIDOldHeap, List *indexes) ...@@ -349,9 +344,6 @@ recreate_indexattr(Oid OIDOldHeap, List *indexes)
swap_relfilenodes(newIndexOID, attrs->indexOID); swap_relfilenodes(newIndexOID, attrs->indexOID);
setRelhasindex(OIDOldHeap, true, attrs->isPrimary, InvalidOid); setRelhasindex(OIDOldHeap, true, attrs->isPrimary, InvalidOid);
/* I'm not sure this one is needed, but let's be safe. */
CommandCounterIncrement();
/* Destroy new index with old filenode */ /* Destroy new index with old filenode */
object.classId = RelOid_pg_class; object.classId = RelOid_pg_class;
object.objectId = newIndexOID; object.objectId = newIndexOID;
...@@ -380,11 +372,11 @@ swap_relfilenodes(Oid r1, Oid r2) ...@@ -380,11 +372,11 @@ swap_relfilenodes(Oid r1, Oid r2)
* it every time. * it every time.
*/ */
Relation relRelation, Relation relRelation,
irels[Num_pg_class_indices],
rel; rel;
HeapTuple reltup[2]; HeapTuple reltup[2];
Oid tempRFNode; Oid tempRFNode;
int i; int i;
CatalogIndexState indstate;
/* We need both RelationRelationName tuples. */ /* We need both RelationRelationName tuples. */
relRelation = heap_openr(RelationRelationName, RowExclusiveLock); relRelation = heap_openr(RelationRelationName, RowExclusiveLock);
...@@ -429,11 +421,10 @@ swap_relfilenodes(Oid r1, Oid r2) ...@@ -429,11 +421,10 @@ swap_relfilenodes(Oid r1, Oid r2)
simple_heap_update(relRelation, &reltup[0]->t_self, reltup[0]); simple_heap_update(relRelation, &reltup[0]->t_self, reltup[0]);
/* To keep system catalogs current. */ /* To keep system catalogs current. */
CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, irels); indstate = CatalogOpenIndexes(relRelation);
CatalogIndexInsert(irels, Num_pg_class_indices, relRelation, reltup[1]); CatalogIndexInsert(indstate, reltup[1]);
CatalogIndexInsert(irels, Num_pg_class_indices, relRelation, reltup[0]); CatalogIndexInsert(indstate, reltup[0]);
CatalogCloseIndices(Num_pg_class_indices, irels); CatalogCloseIndexes(indstate);
CommandCounterIncrement();
heap_close(relRelation, NoLock); heap_close(relRelation, NoLock);
heap_freetuple(reltup[0]); heap_freetuple(reltup[0]);
......
...@@ -6,20 +6,13 @@ ...@@ -6,20 +6,13 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994-5, Regents of the University of California * Portions Copyright (c) 1994-5, Regents of the University of California
* *
* $Id: cluster.h,v 1.14 2002/06/20 20:29:49 momjian Exp $ * $Id: cluster.h,v 1.15 2002/08/10 21:00:34 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#ifndef CLUSTER_H #ifndef CLUSTER_H
#define CLUSTER_H #define CLUSTER_H
/*
* defines for contant stuff
*/
#define _TEMP_RELATION_KEY_ "clXXXXXXXX"
#define _SIZE_OF_TEMP_RELATION_KEY_ 11
/* /*
* functions * functions
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment