1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-22 12:22:45 +03:00

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.
This commit is contained in:
Tom Lane
2003-09-24 18:54:02 +00:00
parent 5f78c6a886
commit a56a016ceb
22 changed files with 621 additions and 635 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_largeobject.c,v 1.16 2003/08/04 02:39:58 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_largeobject.c,v 1.17 2003/09/24 18:54:01 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -77,32 +77,29 @@ LargeObjectDrop(Oid loid)
{
bool found = false;
Relation pg_largeobject;
Relation pg_lo_idx;
ScanKeyData skey[1];
IndexScanDesc sd;
SysScanDesc sd;
HeapTuple tuple;
ScanKeyEntryInitialize(&skey[0],
(bits16) 0x0,
(AttrNumber) 1,
ScanKeyEntryInitialize(&skey[0], 0x0,
(AttrNumber) Anum_pg_largeobject_loid,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(loid));
pg_largeobject = heap_openr(LargeObjectRelationName, RowShareLock);
pg_lo_idx = index_openr(LargeObjectLOidPNIndex);
pg_largeobject = heap_openr(LargeObjectRelationName, RowExclusiveLock);
sd = index_beginscan(pg_largeobject, pg_lo_idx, SnapshotNow, 1, skey);
sd = systable_beginscan(pg_largeobject, LargeObjectLOidPNIndex, true,
SnapshotNow, 1, skey);
while ((tuple = index_getnext(sd, ForwardScanDirection)) != NULL)
while ((tuple = systable_getnext(sd)) != NULL)
{
simple_heap_delete(pg_largeobject, &tuple->t_self);
found = true;
}
index_endscan(sd);
systable_endscan(sd);
index_close(pg_lo_idx);
heap_close(pg_largeobject, RowShareLock);
heap_close(pg_largeobject, RowExclusiveLock);
if (!found)
ereport(ERROR,
@@ -115,32 +112,29 @@ LargeObjectExists(Oid loid)
{
bool retval = false;
Relation pg_largeobject;
Relation pg_lo_idx;
ScanKeyData skey[1];
IndexScanDesc sd;
SysScanDesc sd;
HeapTuple tuple;
/*
* See if we can find any tuples belonging to the specified LO
*/
ScanKeyEntryInitialize(&skey[0],
(bits16) 0x0,
(AttrNumber) 1,
ScanKeyEntryInitialize(&skey[0], 0x0,
(AttrNumber) Anum_pg_largeobject_loid,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(loid));
pg_largeobject = heap_openr(LargeObjectRelationName, RowShareLock);
pg_lo_idx = index_openr(LargeObjectLOidPNIndex);
pg_largeobject = heap_openr(LargeObjectRelationName, AccessShareLock);
sd = index_beginscan(pg_largeobject, pg_lo_idx, SnapshotNow, 1, skey);
sd = systable_beginscan(pg_largeobject, LargeObjectLOidPNIndex, true,
SnapshotNow, 1, skey);
if ((tuple = index_getnext(sd, ForwardScanDirection)) != NULL)
if ((tuple = systable_getnext(sd)) != NULL)
retval = true;
index_endscan(sd);
systable_endscan(sd);
index_close(pg_lo_idx);
heap_close(pg_largeobject, RowShareLock);
heap_close(pg_largeobject, AccessShareLock);
return retval;
}