Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3130942

Browse files
committed
Another vacuum fix.
1 parent09e1250 commit3130942

File tree

4 files changed

+46
-21
lines changed

4 files changed

+46
-21
lines changed

‎src/backend/catalog/index.c

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.48 1998/08/19 02:01:32 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.49 1998/08/20 15:16:54 momjian Exp $
1111
*
1212
*
1313
* INTERFACE ROUTINES
@@ -1308,6 +1308,7 @@ UpdateStats(Oid relid, long reltuples, bool hasindex)
13081308
Datumvalues[Natts_pg_class];
13091309
charnulls[Natts_pg_class];
13101310
charreplace[Natts_pg_class];
1311+
HeapScanDescpg_class_scan=NULL;
13111312

13121313
/* ----------------
13131314
* This routine handles updates for both the heap and index relation
@@ -1340,11 +1341,30 @@ UpdateStats(Oid relid, long reltuples, bool hasindex)
13401341
if (!RelationIsValid(pg_class))
13411342
elog(ERROR,"UpdateStats: could not open RELATION relation");
13421343

1343-
tuple=SearchSysCacheTupleCopy(RELOID,
1344-
ObjectIdGetDatum(relid),
1345-
0,0,0);
1344+
1345+
if (!IsBootstrapProcessingMode())
1346+
{
1347+
tuple=SearchSysCacheTupleCopy(RELOID,
1348+
ObjectIdGetDatum(relid),
1349+
0,0,0);
1350+
}
1351+
else
1352+
{
1353+
ScanKeyDatakey[1];
1354+
1355+
ScanKeyEntryInitialize(&key[0],0,
1356+
ObjectIdAttributeNumber,
1357+
F_OIDEQ,
1358+
ObjectIdGetDatum(relid));
1359+
1360+
pg_class_scan=heap_beginscan(pg_class,0,SnapshotNow,1,key);
1361+
tuple=heap_getnext(pg_class_scan,0);
1362+
}
1363+
13461364
if (!HeapTupleIsValid(tuple))
13471365
{
1366+
if (IsBootstrapProcessingMode())
1367+
heap_endscan(pg_class_scan);
13481368
heap_close(pg_class);
13491369
elog(ERROR,"UpdateStats: cannot scan RELATION relation");
13501370
}
@@ -1385,11 +1405,11 @@ UpdateStats(Oid relid, long reltuples, bool hasindex)
13851405
* At bootstrap time, we don't need to worry about concurrency or
13861406
* visibility of changes, so we cheat.
13871407
*/
1388-
13891408
rd_rel= (Form_pg_class)GETSTRUCT(tuple);
13901409
rd_rel->relpages=relpages;
13911410
rd_rel->reltuples=reltuples;
13921411
rd_rel->relhasindex=hasindex;
1412+
WriteBuffer(pg_class_scan->rs_cbuf);
13931413
}
13941414
else
13951415
{
@@ -1402,14 +1422,18 @@ UpdateStats(Oid relid, long reltuples, bool hasindex)
14021422
values[Anum_pg_class_relhasindex-1]=CharGetDatum(hasindex);
14031423

14041424
newtup=heap_modifytuple(tuple,pg_class,values,nulls,replace);
1405-
heap_replace(pg_class,&newtup->t_ctid,newtup);
1425+
heap_replace(pg_class,&tuple->t_ctid,newtup);
14061426
pfree(newtup);
14071427
CatalogOpenIndices(Num_pg_class_indices,Name_pg_class_indices,idescs);
14081428
CatalogIndexInsert(idescs,Num_pg_class_indices,pg_class,newtup);
14091429
CatalogCloseIndices(Num_pg_class_indices,idescs);
14101430
}
14111431

1412-
pfree(tuple);
1432+
if (!IsBootstrapProcessingMode())
1433+
pfree(tuple);
1434+
else
1435+
heap_endscan(pg_class_scan);
1436+
14131437
heap_close(pg_class);
14141438
heap_close(whichRel);
14151439
}

‎src/backend/catalog/indexing.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.20 1998/08/19 02:01:33 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.21 1998/08/20 15:16:55 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -254,7 +254,7 @@ CatalogIndexFetchTuple(Relation heapRelation,
254254

255255
index_endscan(sd);
256256
pfree(sd);
257-
return(tuple);
257+
returntuple;
258258
}
259259

260260
/*
@@ -276,7 +276,7 @@ AttributeNameIndexScan(Relation heapRelation,
276276
(bits16)0x0,
277277
(AttrNumber)1,
278278
(RegProcedure)F_OIDEQ,
279-
Int32GetDatum(relid));
279+
ObjectIdGetDatum(relid));
280280

281281
ScanKeyEntryInitialize(&skey[1],
282282
(bits16)0x0,
@@ -456,7 +456,7 @@ ClassNameIndexScan(Relation heapRelation, char *relName)
456456
(bits16)0x0,
457457
(AttrNumber)1,
458458
(RegProcedure)F_NAMEEQ,
459-
(Datum)relName);
459+
PointerGetDatum(relName));
460460

461461
idesc=index_openr(ClassNameIndex);
462462
tuple=CatalogIndexFetchTuple(heapRelation,idesc,skey,1);

‎src/backend/commands/vacuum.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.74 1998/08/19 23:48:21 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.75 1998/08/20 15:16:57 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -188,7 +188,7 @@ vc_init()
188188

189189
if ((fd=open("pg_vlock",O_CREAT |O_EXCL,0600))<0)
190190
{
191-
elog(ERROR,"Can't create lock file -- another vacuum cleaner running?\n\
191+
elog(ERROR,"Can't create lock file. Is another vacuum cleaner running?\n\
192192
\tIf not, you may remove the pg_vlock file in the pgsql/data/base/your_db\n\
193193
\tdirectory");
194194
}
@@ -2204,24 +2204,25 @@ static void
22042204
vc_mkindesc(Relationonerel,intnindices,Relation*Irel,IndDesc**Idesc)
22052205
{
22062206
IndDesc*idcur;
2207-
HeapTupletuple;
2207+
HeapTupletuple,cachetuple;
22082208
AttrNumber*attnumP;
22092209
intnatts;
22102210
inti;
22112211
Bufferbuffer;
2212-
2212+
22132213
*Idesc= (IndDesc*)palloc(nindices*sizeof(IndDesc));
22142214

22152215
for (i=0,idcur=*Idesc;i<nindices;i++,idcur++)
22162216
{
2217-
tuple=SearchSysCacheTuple(INDEXRELID,
2218-
ObjectIdGetDatum(RelationGetRelid(Irel[i])),
2219-
0,0,0);
2217+
cachetuple=SearchSysCacheTupleCopy(INDEXRELID,
2218+
ObjectIdGetDatum(RelationGetRelid(Irel[i])),
2219+
0,0,0);
22202220
Assert(tuple);
22212221

22222222
/* get the buffer cache tuple */
2223-
tuple=heap_fetch(onerel,SnapshotNow,&tuple->t_ctid,&buffer);
2223+
tuple=heap_fetch(onerel,SnapshotNow,&cachetuple->t_ctid,&buffer);
22242224
Assert(tuple);
2225+
pfree(cachetuple);
22252226

22262227
idcur->tform= (IndexTupleForm)GETSTRUCT(tuple);
22272228
for (attnumP=&(idcur->tform->indkey[0]),natts=0;

‎src/bin/initdb/initdb.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#
2727
#
2828
# IDENTIFICATION
29-
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.48 1998/08/19 23:48:23 momjian Exp $
29+
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.49 1998/08/20 15:16:59 momjian Exp $
3030
#
3131
#-------------------------------------------------------------------------
3232

@@ -316,7 +316,7 @@ fi
316316

317317
BACKENDARGS="-boot -C -F -D$PGDATA$BACKEND_TALK_ARG"
318318

319-
echo"$CMDNAME: creating template database in$PGDATA/base/template1"
319+
echo"Creating template database in$PGDATA/base/template1"
320320
["$debug"-ne 0 ]&&echo"Running: postgres$BACKENDARGS template1"
321321

322322
cat$TEMPLATE \

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp