From a56a016ceb612cdee1ddc5990682f36d541e5b07 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 24 Sep 2003 18:54:02 +0000 Subject: Repair some REINDEX problems per recent discussions. The relcache is now able to cope with assigning new relfilenode values to nailed-in-cache indexes, so they can be reindexed using the fully crash-safe method. This leaves only shared system indexes as special cases. Remove the 'index deactivation' code, since it provides no useful protection in the shared- index case. Require reindexing of shared indexes to be done in standalone mode, but remove other restrictions on REINDEX. -P (IgnoreSystemIndexes) now prevents using indexes for lookups, but does not disable index updates. It is therefore safe to allow from PGOPTIONS. Upshot: reindexing system catalogs can be done without a standalone backend for all cases except shared catalogs. --- src/backend/commands/functioncmds.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/backend/commands/functioncmds.c') diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c index ea5ba103131..328643c171e 100644 --- a/src/backend/commands/functioncmds.c +++ b/src/backend/commands/functioncmds.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/functioncmds.c,v 1.34 2003/09/10 19:59:23 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/functioncmds.c,v 1.35 2003/09/24 18:54:01 tgl Exp $ * * DESCRIPTION * These routines take the parse tree and pick out the @@ -1095,24 +1095,25 @@ DropCast(DropCastStmt *stmt) void DropCastById(Oid castOid) { - Relation relation, - index; + Relation relation; ScanKeyData scankey; - IndexScanDesc scan; + SysScanDesc scan; HeapTuple tuple; relation = heap_openr(CastRelationName, RowExclusiveLock); - index = index_openr(CastOidIndex); ScanKeyEntryInitialize(&scankey, 0x0, - 1, F_OIDEQ, ObjectIdGetDatum(castOid)); - scan = index_beginscan(relation, index, SnapshotNow, 1, &scankey); - tuple = index_getnext(scan, ForwardScanDirection); + ObjectIdAttributeNumber, + F_OIDEQ, + ObjectIdGetDatum(castOid)); + scan = systable_beginscan(relation, CastOidIndex, true, + SnapshotNow, 1, &scankey); + + tuple = systable_getnext(scan); if (!HeapTupleIsValid(tuple)) elog(ERROR, "could not find tuple for cast %u", castOid); simple_heap_delete(relation, &tuple->t_self); - index_endscan(scan); - index_close(index); + systable_endscan(scan); heap_close(relation, RowExclusiveLock); } -- cgit v1.2.3