mirror of
https://github.com/postgres/postgres.git
synced 2025-11-13 16:22:44 +03:00
Another vacuum fix.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.48 1998/08/19 02:01:32 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.49 1998/08/20 15:16:54 momjian Exp $
|
||||
*
|
||||
*
|
||||
* INTERFACE ROUTINES
|
||||
@@ -1308,6 +1308,7 @@ UpdateStats(Oid relid, long reltuples, bool hasindex)
|
||||
Datum values[Natts_pg_class];
|
||||
char nulls[Natts_pg_class];
|
||||
char replace[Natts_pg_class];
|
||||
HeapScanDesc pg_class_scan = NULL;
|
||||
|
||||
/* ----------------
|
||||
* This routine handles updates for both the heap and index relation
|
||||
@@ -1340,11 +1341,30 @@ UpdateStats(Oid relid, long reltuples, bool hasindex)
|
||||
if (!RelationIsValid(pg_class))
|
||||
elog(ERROR, "UpdateStats: could not open RELATION relation");
|
||||
|
||||
tuple = SearchSysCacheTupleCopy(RELOID,
|
||||
ObjectIdGetDatum(relid),
|
||||
0, 0, 0);
|
||||
|
||||
if (!IsBootstrapProcessingMode())
|
||||
{
|
||||
tuple = SearchSysCacheTupleCopy(RELOID,
|
||||
ObjectIdGetDatum(relid),
|
||||
0, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
ScanKeyData key[1];
|
||||
|
||||
ScanKeyEntryInitialize(&key[0], 0,
|
||||
ObjectIdAttributeNumber,
|
||||
F_OIDEQ,
|
||||
ObjectIdGetDatum(relid));
|
||||
|
||||
pg_class_scan = heap_beginscan(pg_class, 0, SnapshotNow, 1, key);
|
||||
tuple = heap_getnext(pg_class_scan, 0);
|
||||
}
|
||||
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
{
|
||||
if (IsBootstrapProcessingMode())
|
||||
heap_endscan(pg_class_scan);
|
||||
heap_close(pg_class);
|
||||
elog(ERROR, "UpdateStats: cannot scan RELATION relation");
|
||||
}
|
||||
@@ -1385,11 +1405,11 @@ UpdateStats(Oid relid, long reltuples, bool hasindex)
|
||||
* At bootstrap time, we don't need to worry about concurrency or
|
||||
* visibility of changes, so we cheat.
|
||||
*/
|
||||
|
||||
rd_rel = (Form_pg_class) GETSTRUCT(tuple);
|
||||
rd_rel->relpages = relpages;
|
||||
rd_rel->reltuples = reltuples;
|
||||
rd_rel->relhasindex = hasindex;
|
||||
WriteBuffer(pg_class_scan->rs_cbuf);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1402,14 +1422,18 @@ UpdateStats(Oid relid, long reltuples, bool hasindex)
|
||||
values[Anum_pg_class_relhasindex - 1] = CharGetDatum(hasindex);
|
||||
|
||||
newtup = heap_modifytuple(tuple, pg_class, values, nulls, replace);
|
||||
heap_replace(pg_class, &newtup->t_ctid, newtup);
|
||||
heap_replace(pg_class, &tuple->t_ctid, newtup);
|
||||
pfree(newtup);
|
||||
CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, idescs);
|
||||
CatalogIndexInsert(idescs, Num_pg_class_indices, pg_class, newtup);
|
||||
CatalogCloseIndices(Num_pg_class_indices, idescs);
|
||||
}
|
||||
|
||||
pfree(tuple);
|
||||
if (!IsBootstrapProcessingMode())
|
||||
pfree(tuple);
|
||||
else
|
||||
heap_endscan(pg_class_scan);
|
||||
|
||||
heap_close(pg_class);
|
||||
heap_close(whichRel);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.20 1998/08/19 02:01:33 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.21 1998/08/20 15:16:55 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -254,7 +254,7 @@ CatalogIndexFetchTuple(Relation heapRelation,
|
||||
|
||||
index_endscan(sd);
|
||||
pfree(sd);
|
||||
return (tuple);
|
||||
return tuple;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -276,7 +276,7 @@ AttributeNameIndexScan(Relation heapRelation,
|
||||
(bits16) 0x0,
|
||||
(AttrNumber) 1,
|
||||
(RegProcedure)F_OIDEQ,
|
||||
Int32GetDatum(relid));
|
||||
ObjectIdGetDatum(relid));
|
||||
|
||||
ScanKeyEntryInitialize(&skey[1],
|
||||
(bits16) 0x0,
|
||||
@@ -456,7 +456,7 @@ ClassNameIndexScan(Relation heapRelation, char *relName)
|
||||
(bits16) 0x0,
|
||||
(AttrNumber) 1,
|
||||
(RegProcedure) F_NAMEEQ,
|
||||
(Datum) relName);
|
||||
PointerGetDatum(relName));
|
||||
|
||||
idesc = index_openr(ClassNameIndex);
|
||||
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
|
||||
|
||||
Reference in New Issue
Block a user