diff options
author | Tom Lane | 2004-10-15 22:40:29 +0000 |
---|---|---|
committer | Tom Lane | 2004-10-15 22:40:29 +0000 |
commit | 9ffc8ed58b55cb3925bb95cc184583fcb9772013 (patch) | |
tree | 9039f51525070c611a86f03a2e85a13b24005ac3 /contrib/pgstattuple | |
parent | db9e2fd0a9144707055ed382f184f5a9c11aafff (diff) |
Repair possible failure to update hint bits back to disk, per
http://archives.postgresql.org/pgsql-hackers/2004-10/msg00464.php.
This fix is intended to be permanent: it moves the responsibility for
calling SetBufferCommitInfoNeedsSave() into the tqual.c routines,
eliminating the requirement for callers to test whether t_infomask changed.
Also, tighten validity checking on buffer IDs in bufmgr.c --- several
routines were paranoid about out-of-range shared buffer numbers but not
about out-of-range local ones, which seems a tad pointless.
Diffstat (limited to 'contrib/pgstattuple')
-rw-r--r-- | contrib/pgstattuple/pgstattuple.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/contrib/pgstattuple/pgstattuple.c b/contrib/pgstattuple/pgstattuple.c index bfe37eb9ed6..e2fab7863eb 100644 --- a/contrib/pgstattuple/pgstattuple.c +++ b/contrib/pgstattuple/pgstattuple.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.16 2004/08/29 05:06:37 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.17 2004/10/15 22:39:38 tgl Exp $ * * Copyright (c) 2001,2002 Tatsuo Ishii * @@ -134,7 +134,10 @@ pgstattuple_real(Relation rel) /* scan the relation */ while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL) { - if (HeapTupleSatisfiesNow(tuple->t_data)) + /* must hold a buffer lock to call HeapTupleSatisfiesNow */ + LockBuffer(scan->rs_cbuf, BUFFER_LOCK_SHARE); + + if (HeapTupleSatisfiesNow(tuple->t_data, scan->rs_cbuf)) { tuple_len += tuple->t_len; tuple_count++; @@ -145,6 +148,8 @@ pgstattuple_real(Relation rel) dead_tuple_count++; } + LockBuffer(scan->rs_cbuf, BUFFER_LOCK_UNLOCK); + /* * To avoid physically reading the table twice, try to do the * free-space scan in parallel with the heap scan. However, @@ -156,7 +161,9 @@ pgstattuple_real(Relation rel) while (block <= tupblock) { buffer = ReadBuffer(rel, block); + LockBuffer(buffer, BUFFER_LOCK_SHARE); free_space += PageGetFreeSpace((Page) BufferGetPage(buffer)); + LockBuffer(buffer, BUFFER_LOCK_UNLOCK); ReleaseBuffer(buffer); block++; } |