8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.84 2002/08/16 20:55:09 tgl Exp $
11
+ * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.85 2002/08/29 15:56:20 tgl Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -559,12 +559,8 @@ RemoveIndex(RangeVar *relation, DropBehavior behavior)
559
559
}
560
560
561
561
/*
562
- * Reindex
562
+ * ReindexIndex
563
563
* Recreate an index.
564
- *
565
- * Exceptions:
566
- * "ERROR" if index nonexistent.
567
- * ...
568
564
*/
569
565
void
570
566
ReindexIndex (RangeVar * indexRelation , bool force /* currently unused */ )
@@ -593,7 +589,8 @@ ReindexIndex(RangeVar *indexRelation, bool force /* currently unused */ )
593
589
indexRelation -> relname ,
594
590
((Form_pg_class ) GETSTRUCT (tuple ))-> relkind );
595
591
596
- if (IsSystemClass ((Form_pg_class ) GETSTRUCT (tuple )))
592
+ if (IsSystemClass ((Form_pg_class ) GETSTRUCT (tuple )) &&
593
+ !IsToastClass ((Form_pg_class ) GETSTRUCT (tuple )))
597
594
{
598
595
if (!allowSystemTableMods )
599
596
elog (ERROR , "\"%s\" is a system index. call REINDEX under standalone postgres with -O -P options" ,
@@ -614,16 +611,13 @@ ReindexIndex(RangeVar *indexRelation, bool force /* currently unused */ )
614
611
/*
615
612
* ReindexTable
616
613
* Recreate indexes of a table.
617
- *
618
- * Exceptions:
619
- * "ERROR" if table nonexistent.
620
- * ...
621
614
*/
622
615
void
623
616
ReindexTable (RangeVar * relation , bool force )
624
617
{
625
618
Oid heapOid ;
626
619
HeapTuple tuple ;
620
+ char relkind ;
627
621
628
622
/*
629
623
* REINDEX within a transaction block is dangerous, because if the
@@ -639,11 +633,11 @@ ReindexTable(RangeVar *relation, bool force)
639
633
0 , 0 , 0 );
640
634
if (!HeapTupleIsValid (tuple ))
641
635
elog (ERROR , "table \"%s\" does not exist" , relation -> relname );
636
+ relkind = ((Form_pg_class ) GETSTRUCT (tuple ))-> relkind ;
642
637
643
- if ((( Form_pg_class ) GETSTRUCT ( tuple )) -> relkind != RELKIND_RELATION )
638
+ if (relkind != RELKIND_RELATION && relkind != RELKIND_TOASTVALUE )
644
639
elog (ERROR , "relation \"%s\" is of type \"%c\"" ,
645
- relation -> relname ,
646
- ((Form_pg_class ) GETSTRUCT (tuple ))-> relkind );
640
+ relation -> relname , relkind );
647
641
648
642
ReleaseSysCache (tuple );
649
643
@@ -710,12 +704,16 @@ ReindexDatabase(const char *dbname, bool force, bool all)
710
704
relcnt = relalc = 0 ;
711
705
while ((tuple = heap_getnext (scan , ForwardScanDirection )) != NULL )
712
706
{
707
+ char relkind ;
708
+
713
709
if (!all )
714
710
{
715
- if (!IsSystemClass ((Form_pg_class ) GETSTRUCT (tuple )))
711
+ if (!(IsSystemClass ((Form_pg_class ) GETSTRUCT (tuple )) &&
712
+ !IsToastClass ((Form_pg_class ) GETSTRUCT (tuple ))))
716
713
continue ;
717
714
}
718
- if (((Form_pg_class ) GETSTRUCT (tuple ))-> relkind == RELKIND_RELATION )
715
+ relkind = ((Form_pg_class ) GETSTRUCT (tuple ))-> relkind ;
716
+ if (relkind == RELKIND_RELATION || relkind == RELKIND_TOASTVALUE )
719
717
{
720
718
old = MemoryContextSwitchTo (private_context );
721
719
if (relcnt == 0 )
@@ -742,7 +740,7 @@ ReindexDatabase(const char *dbname, bool force, bool all)
742
740
{
743
741
StartTransactionCommand ();
744
742
if (reindex_relation (relids [i ], force ))
745
- elog (WARNING , "relation %u was reindexed" , relids [i ]);
743
+ elog (NOTICE , "relation %u was reindexed" , relids [i ]);
746
744
CommitTransactionCommand ();
747
745
}
748
746
StartTransactionCommand ();
0 commit comments