diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-08-29 15:56:20 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-08-29 15:56:20 +0000 |
commit | d2236800ee987932a77540f194c284c9eeaef186 (patch) | |
tree | 234987719786347b005832d9fc35f1951ed610d6 /src | |
parent | 5f97dc3e7c5314ed822940b9831e5153cd6a3593 (diff) | |
download | postgresql-d2236800ee987932a77540f194c284c9eeaef186.tar.gz postgresql-d2236800ee987932a77540f194c284c9eeaef186.zip |
Cause REINDEX to regard TOAST tables as regular relations, not system
tables that need special defenses. I believe this is okay even for
TOAST tables that belong to system tables.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/catalog/index.c | 8 | ||||
-rw-r--r-- | src/backend/commands/indexcmds.c | 32 |
2 files changed, 20 insertions, 20 deletions
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index 474040f5fcf..0aaeaa6d6d4 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.190 2002/08/28 20:46:47 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.191 2002/08/29 15:56:19 tgl Exp $ * * * INTERFACE ROUTINES @@ -1245,7 +1245,8 @@ setNewRelfilenode(Relation relation) Buffer buffer; RelationData workrel; - Assert(!IsSystemRelation(relation) || relation->rd_rel->relkind == RELKIND_INDEX); + Assert(!IsSystemRelation(relation) || IsToastRelation(relation) || + relation->rd_rel->relkind == RELKIND_INDEX); pg_class = heap_openr(RelationRelationName, RowExclusiveLock); /* Fetch and lock the classTuple associated with this relation */ @@ -1927,7 +1928,8 @@ reindex_relation(Oid relid, bool force) * ignore the indexes of the target system relation while processing * reindex. */ - if (!IsIgnoringSystemIndexes() && IsSystemRelation(rel)) + if (!IsIgnoringSystemIndexes() && + IsSystemRelation(rel) && !IsToastRelation(rel)) deactivate_needed = true; #ifndef ENABLE_REINDEX_NAILED_RELATIONS diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 6310cfc7e5a..ec7e1482798 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.84 2002/08/16 20:55:09 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.85 2002/08/29 15:56:20 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -559,12 +559,8 @@ RemoveIndex(RangeVar *relation, DropBehavior behavior) } /* - * Reindex + * ReindexIndex * Recreate an index. - * - * Exceptions: - * "ERROR" if index nonexistent. - * ... */ void ReindexIndex(RangeVar *indexRelation, bool force /* currently unused */ ) @@ -593,7 +589,8 @@ ReindexIndex(RangeVar *indexRelation, bool force /* currently unused */ ) indexRelation->relname, ((Form_pg_class) GETSTRUCT(tuple))->relkind); - if (IsSystemClass((Form_pg_class) GETSTRUCT(tuple))) + if (IsSystemClass((Form_pg_class) GETSTRUCT(tuple)) && + !IsToastClass((Form_pg_class) GETSTRUCT(tuple))) { if (!allowSystemTableMods) 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 */ ) /* * ReindexTable * Recreate indexes of a table. - * - * Exceptions: - * "ERROR" if table nonexistent. - * ... */ void ReindexTable(RangeVar *relation, bool force) { Oid heapOid; HeapTuple tuple; + char relkind; /* * REINDEX within a transaction block is dangerous, because if the @@ -639,11 +633,11 @@ ReindexTable(RangeVar *relation, bool force) 0, 0, 0); if (!HeapTupleIsValid(tuple)) elog(ERROR, "table \"%s\" does not exist", relation->relname); + relkind = ((Form_pg_class) GETSTRUCT(tuple))->relkind; - if (((Form_pg_class) GETSTRUCT(tuple))->relkind != RELKIND_RELATION) + if (relkind != RELKIND_RELATION && relkind != RELKIND_TOASTVALUE) elog(ERROR, "relation \"%s\" is of type \"%c\"", - relation->relname, - ((Form_pg_class) GETSTRUCT(tuple))->relkind); + relation->relname, relkind); ReleaseSysCache(tuple); @@ -710,12 +704,16 @@ ReindexDatabase(const char *dbname, bool force, bool all) relcnt = relalc = 0; while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL) { + char relkind; + if (!all) { - if (!IsSystemClass((Form_pg_class) GETSTRUCT(tuple))) + if (!(IsSystemClass((Form_pg_class) GETSTRUCT(tuple)) && + !IsToastClass((Form_pg_class) GETSTRUCT(tuple)))) continue; } - if (((Form_pg_class) GETSTRUCT(tuple))->relkind == RELKIND_RELATION) + relkind = ((Form_pg_class) GETSTRUCT(tuple))->relkind; + if (relkind == RELKIND_RELATION || relkind == RELKIND_TOASTVALUE) { old = MemoryContextSwitchTo(private_context); if (relcnt == 0) @@ -742,7 +740,7 @@ ReindexDatabase(const char *dbname, bool force, bool all) { StartTransactionCommand(); if (reindex_relation(relids[i], force)) - elog(WARNING, "relation %u was reindexed", relids[i]); + elog(NOTICE, "relation %u was reindexed", relids[i]); CommitTransactionCommand(); } StartTransactionCommand(); |