Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitab82bde

Browse files
committed
Code review and documentation updates for indisclustered patch.
1 parent00482fd commitab82bde

File tree

4 files changed

+22
-21
lines changed

4 files changed

+22
-21
lines changed

‎doc/src/sgml/catalogs.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--
22
Documentation of the system catalogs, directed toward PostgreSQL developers
3-
$Header: /cvsroot/pgsql/doc/src/sgml/catalogs.sgml,v 2.58 2002/09/02 05:52:34 momjian Exp $
3+
$Header: /cvsroot/pgsql/doc/src/sgml/catalogs.sgml,v 2.59 2002/09/03 01:04:40 tgl Exp $
44
-->
55

66
<chapter id="catalogs">
@@ -1865,7 +1865,7 @@
18651865
<entry>indisclustered</entry>
18661866
<entry><type>bool</type></entry>
18671867
<entry></entry>
1868-
<entry>unused</entry>
1868+
<entry>If true, the table was last clustered on this index.</entry>
18691869
</row>
18701870

18711871
<row>

‎src/backend/catalog/index.c

Lines changed: 2 additions & 2 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.193 2002/09/02 01:05:04 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.194 2002/09/03 01:04:41 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -453,7 +453,7 @@ UpdateIndexRelation(Oid indexoid,
453453
indexForm->indexrelid=indexoid;
454454
indexForm->indrelid=heapoid;
455455
indexForm->indproc=indexInfo->ii_FuncOid;
456-
indexForm->indisclustered= false;/* notused */
456+
indexForm->indisclustered= false;/* notclustered, yet */
457457
indexForm->indisunique=indexInfo->ii_Unique;
458458
indexForm->indisprimary=primary;
459459
memcpy((char*)&indexForm->indpred, (char*)predText,predLen);

‎src/backend/commands/cluster.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.88 2002/09/02 01:05:04 tgl Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.89 2002/09/03 01:04:41 tgl Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -304,12 +304,7 @@ get_indexattr_list(Relation OldHeap, Oid OldIndex)
304304
palloc(sizeof(Oid)*attrs->indexInfo->ii_NumIndexAttrs);
305305
memcpy(attrs->classOID,indexForm->indclass,
306306
sizeof(Oid)*attrs->indexInfo->ii_NumIndexAttrs);
307-
308-
/* We'll set indisclustered at index creation time on the
309-
* index we are currently clustering, and reset it on other
310-
* indexes.
311-
*/
312-
attrs->isclustered= (OldIndex==indexOID ? true : false);
307+
attrs->isclustered= (OldIndex==indexOID);
313308

314309
/* Name and access method of each index come from pg_class */
315310
classTuple=SearchSysCache(RELOID,
@@ -373,19 +368,25 @@ recreate_indexattr(Oid OIDOldHeap, List *indexes)
373368

374369
CommandCounterIncrement();
375370

376-
/* Set indisclustered to the correct value. Only one index is
377-
* allowed to be clustered.
371+
/*
372+
* Make sure that indisclustered is correct: it should be set
373+
* only for the index we just clustered on.
378374
*/
379375
pg_index=heap_openr(IndexRelationName,RowExclusiveLock);
380376
tuple=SearchSysCacheCopy(INDEXRELID,
381-
ObjectIdGetDatum(attrs->indexOID),
382-
0,0,0);
377+
ObjectIdGetDatum(attrs->indexOID),
378+
0,0,0);
379+
if (!HeapTupleIsValid(tuple))
380+
elog(ERROR,"cache lookup failed for index %u",attrs->indexOID);
383381
index= (Form_pg_index)GETSTRUCT(tuple);
384-
index->indisclustered=attrs->isclustered;
385-
simple_heap_update(pg_index,&tuple->t_self,tuple);
386-
CatalogUpdateIndexes(pg_index,tuple);
382+
if (index->indisclustered!=attrs->isclustered)
383+
{
384+
index->indisclustered=attrs->isclustered;
385+
simple_heap_update(pg_index,&tuple->t_self,tuple);
386+
CatalogUpdateIndexes(pg_index,tuple);
387+
}
387388
heap_freetuple(tuple);
388-
heap_close(pg_index,NoLock);
389+
heap_close(pg_index,RowExclusiveLock);
389390

390391
/* Destroy new index with old filenode */
391392
object.classId=RelOid_pg_class;

‎src/include/catalog/pg_index.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $Id: pg_index.h,v 1.28 2002/06/20 20:29:44 momjian Exp $
11+
* $Id: pg_index.h,v 1.29 2002/09/03 01:04:41 tgl Exp $
1212
*
1313
* NOTES
1414
* the genbki.sh script reads this file and generates .bki
@@ -38,7 +38,7 @@ CATALOG(pg_index) BKI_WITHOUT_OIDS
3838
regprocindproc;/* OID of function for functional index */
3939
int2vectorindkey;/* column numbers of indexed attributes */
4040
oidvectorindclass;/* opclass identifiers */
41-
boolindisclustered;/*presently unused */
41+
boolindisclustered;/*is this the index last clustered by? */
4242
boolindisunique;/* is this a unique index? */
4343
boolindisprimary;/* is this index for primary key? */
4444
Oidindreference;/* oid of index of referenced relation (ie

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp