Commit ab82bde7 authored by Tom Lane's avatar Tom Lane

Code review and documentation updates for indisclustered patch.

parent 00482fde
<!--
Documentation of the system catalogs, directed toward PostgreSQL developers
$Header: /cvsroot/pgsql/doc/src/sgml/catalogs.sgml,v 2.58 2002/09/02 05:52:34 momjian Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/catalogs.sgml,v 2.59 2002/09/03 01:04:40 tgl Exp $
-->
<chapter id="catalogs">
......@@ -1865,7 +1865,7 @@
<entry>indisclustered</entry>
<entry><type>bool</type></entry>
<entry></entry>
<entry>unused</entry>
<entry>If true, the table was last clustered on this index.</entry>
</row>
<row>
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.193 2002/09/02 01:05:04 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.194 2002/09/03 01:04:41 tgl Exp $
*
*
* INTERFACE ROUTINES
......@@ -453,7 +453,7 @@ UpdateIndexRelation(Oid indexoid,
indexForm->indexrelid = indexoid;
indexForm->indrelid = heapoid;
indexForm->indproc = indexInfo->ii_FuncOid;
indexForm->indisclustered = false; /* not used */
indexForm->indisclustered = false; /* not clustered, yet */
indexForm->indisunique = indexInfo->ii_Unique;
indexForm->indisprimary = primary;
memcpy((char *) &indexForm->indpred, (char *) predText, predLen);
......
......@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.88 2002/09/02 01:05:04 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.89 2002/09/03 01:04:41 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -304,12 +304,7 @@ get_indexattr_list(Relation OldHeap, Oid OldIndex)
palloc(sizeof(Oid) * attrs->indexInfo->ii_NumIndexAttrs);
memcpy(attrs->classOID, indexForm->indclass,
sizeof(Oid) * attrs->indexInfo->ii_NumIndexAttrs);
/* We'll set indisclustered at index creation time on the
* index we are currently clustering, and reset it on other
* indexes.
*/
attrs->isclustered = (OldIndex == indexOID ? true : false);
attrs->isclustered = (OldIndex == indexOID);
/* Name and access method of each index come from pg_class */
classTuple = SearchSysCache(RELOID,
......@@ -373,19 +368,25 @@ recreate_indexattr(Oid OIDOldHeap, List *indexes)
CommandCounterIncrement();
/* Set indisclustered to the correct value. Only one index is
* allowed to be clustered.
/*
* Make sure that indisclustered is correct: it should be set
* only for the index we just clustered on.
*/
pg_index = heap_openr(IndexRelationName, RowExclusiveLock);
tuple = SearchSysCacheCopy(INDEXRELID,
ObjectIdGetDatum(attrs->indexOID),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for index %u", attrs->indexOID);
index = (Form_pg_index) GETSTRUCT(tuple);
if (index->indisclustered != attrs->isclustered)
{
index->indisclustered = attrs->isclustered;
simple_heap_update(pg_index, &tuple->t_self, tuple);
CatalogUpdateIndexes(pg_index, tuple);
}
heap_freetuple(tuple);
heap_close(pg_index, NoLock);
heap_close(pg_index, RowExclusiveLock);
/* Destroy new index with old filenode */
object.classId = RelOid_pg_class;
......
......@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_index.h,v 1.28 2002/06/20 20:29:44 momjian Exp $
* $Id: pg_index.h,v 1.29 2002/09/03 01:04:41 tgl Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
......@@ -38,7 +38,7 @@ CATALOG(pg_index) BKI_WITHOUT_OIDS
regproc indproc; /* OID of function for functional index */
int2vector indkey; /* column numbers of indexed attributes */
oidvector indclass; /* opclass identifiers */
bool indisclustered; /* presently unused */
bool indisclustered; /* is this the index last clustered by? */
bool indisunique; /* is this a unique index? */
bool indisprimary; /* is this index for primary key? */
Oid indreference; /* oid of index of referenced relation (ie
......
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