88 *
99 *
1010 * 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 $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
@@ -559,12 +559,8 @@ RemoveIndex(RangeVar *relation, DropBehavior behavior)
559559}
560560
561561/*
562- *Reindex
562+ *ReindexIndex
563563 *Recreate an index.
564- *
565- * Exceptions:
566- *"ERROR" if index nonexistent.
567- *...
568564 */
569565void
570566ReindexIndex (RangeVar * indexRelation ,bool force /* currently unused */ )
@@ -593,7 +589,8 @@ ReindexIndex(RangeVar *indexRelation, bool force /* currently unused */ )
593589indexRelation -> relname ,
594590 ((Form_pg_class )GETSTRUCT (tuple ))-> relkind );
595591
596- if (IsSystemClass ((Form_pg_class )GETSTRUCT (tuple )))
592+ if (IsSystemClass ((Form_pg_class )GETSTRUCT (tuple ))&&
593+ !IsToastClass ((Form_pg_class )GETSTRUCT (tuple )))
597594{
598595if (!allowSystemTableMods )
599596elog (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 */ )
614611/*
615612 * ReindexTable
616613 *Recreate indexes of a table.
617- *
618- * Exceptions:
619- *"ERROR" if table nonexistent.
620- *...
621614 */
622615void
623616ReindexTable (RangeVar * relation ,bool force )
624617{
625618Oid heapOid ;
626619HeapTuple tuple ;
620+ char relkind ;
627621
628622/*
629623 * REINDEX within a transaction block is dangerous, because if the
@@ -639,11 +633,11 @@ ReindexTable(RangeVar *relation, bool force)
6396330 ,0 ,0 );
640634if (!HeapTupleIsValid (tuple ))
641635elog (ERROR ,"table \"%s\" does not exist" ,relation -> relname );
636+ relkind = ((Form_pg_class )GETSTRUCT (tuple ))-> relkind ;
642637
643- if ((( Form_pg_class ) GETSTRUCT ( tuple )) -> relkind != RELKIND_RELATION )
638+ if (relkind != RELKIND_RELATION && relkind != RELKIND_TOASTVALUE )
644639elog (ERROR ,"relation \"%s\" is of type \"%c\"" ,
645- relation -> relname ,
646- ((Form_pg_class )GETSTRUCT (tuple ))-> relkind );
640+ relation -> relname ,relkind );
647641
648642ReleaseSysCache (tuple );
649643
@@ -710,12 +704,16 @@ ReindexDatabase(const char *dbname, bool force, bool all)
710704relcnt = relalc = 0 ;
711705while ((tuple = heap_getnext (scan ,ForwardScanDirection ))!= NULL )
712706{
707+ char relkind ;
708+
713709if (!all )
714710{
715- if (!IsSystemClass ((Form_pg_class )GETSTRUCT (tuple )))
711+ if (!(IsSystemClass ((Form_pg_class )GETSTRUCT (tuple ))&&
712+ !IsToastClass ((Form_pg_class )GETSTRUCT (tuple ))))
716713continue ;
717714}
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 )
719717{
720718old = MemoryContextSwitchTo (private_context );
721719if (relcnt == 0 )
@@ -742,7 +740,7 @@ ReindexDatabase(const char *dbname, bool force, bool all)
742740{
743741StartTransactionCommand ();
744742if (reindex_relation (relids [i ],force ))
745- elog (WARNING ,"relation %u was reindexed" ,relids [i ]);
743+ elog (NOTICE ,"relation %u was reindexed" ,relids [i ]);
746744CommitTransactionCommand ();
747745}
748746StartTransactionCommand ();