Repair possible failure to update hint bits back to disk, per

http://archives.postgresql.org/pgsql-hackers/2004-10/msg00464.php.
I plan a more permanent fix in HEAD, but for the back branches it seems
best to just touch the places that actually have a problem.
This commit is contained in:
Tom Lane 2004-10-13 22:22:41 +00:00
parent 7b0919047f
commit 6b3d751747
2 changed files with 22 additions and 5 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Header: /cvsroot/pgsql/contrib/pgstattuple/pgstattuple.c,v 1.3 2001/12/19 20:28:41 tgl Exp $ * $Header: /cvsroot/pgsql/contrib/pgstattuple/pgstattuple.c,v 1.3.2.1 2004/10/13 22:22:40 tgl Exp $
* *
* Copyright (c) 2001 Tatsuo Ishii * Copyright (c) 2001 Tatsuo Ishii
* *
@ -69,6 +69,9 @@ pgstattuple(PG_FUNCTION_ARGS)
while ((tuple = heap_getnext(scan, 0))) while ((tuple = heap_getnext(scan, 0)))
{ {
uint16 sv_infomask;
sv_infomask = tuple->t_data->t_infomask;
if (HeapTupleSatisfiesNow(tuple->t_data)) if (HeapTupleSatisfiesNow(tuple->t_data))
{ {
tuple_len += tuple->t_len; tuple_len += tuple->t_len;
@ -79,6 +82,8 @@ pgstattuple(PG_FUNCTION_ARGS)
dead_tuple_len += tuple->t_len; dead_tuple_len += tuple->t_len;
dead_tuple_count++; dead_tuple_count++;
} }
if (sv_infomask != tuple->t_data->t_infomask)
SetBufferCommitInfoNeedsSave(scan->rs_cbuf);
/* /*
* To avoid physically reading the table twice, try to do the * To avoid physically reading the table twice, try to do the

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.129.2.2 2003/01/26 23:09:37 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.129.2.3 2004/10/13 22:22:41 tgl Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
@ -1155,6 +1155,7 @@ heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid)
PageHeader dp; PageHeader dp;
Buffer buffer; Buffer buffer;
int result; int result;
uint16 sv_infomask;
/* increment access statistics */ /* increment access statistics */
IncrHeapAccessStat(local_delete); IncrHeapAccessStat(local_delete);
@ -1178,7 +1179,10 @@ heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid)
tp.t_tableOid = relation->rd_id; tp.t_tableOid = relation->rd_id;
l1: l1:
sv_infomask = tp.t_data->t_infomask;
result = HeapTupleSatisfiesUpdate(&tp); result = HeapTupleSatisfiesUpdate(&tp);
if (sv_infomask != tp.t_data->t_infomask)
SetBufferCommitInfoNeedsSave(buffer);
if (result == HeapTupleInvisible) if (result == HeapTupleInvisible)
{ {
@ -1195,7 +1199,7 @@ l1:
XactLockTableWait(xwait); XactLockTableWait(xwait);
LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE); LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
if (TransactionIdDidAbort(xwait)) if (!TransactionIdDidCommit(xwait))
goto l1; goto l1;
/* /*
@ -1345,6 +1349,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
Size newtupsize, Size newtupsize,
pagefree; pagefree;
int result; int result;
uint16 sv_infomask;
/* increment access statistics */ /* increment access statistics */
IncrHeapAccessStat(local_replace); IncrHeapAccessStat(local_replace);
@ -1373,7 +1378,10 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
*/ */
l2: l2:
sv_infomask = oldtup.t_data->t_infomask;
result = HeapTupleSatisfiesUpdate(&oldtup); result = HeapTupleSatisfiesUpdate(&oldtup);
if (sv_infomask != oldtup.t_data->t_infomask)
SetBufferCommitInfoNeedsSave(buffer);
if (result == HeapTupleInvisible) if (result == HeapTupleInvisible)
{ {
@ -1390,7 +1398,7 @@ l2:
XactLockTableWait(xwait); XactLockTableWait(xwait);
LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE); LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
if (TransactionIdDidAbort(xwait)) if (!TransactionIdDidCommit(xwait))
goto l2; goto l2;
/* /*
@ -1651,6 +1659,7 @@ heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer)
ItemId lp; ItemId lp;
PageHeader dp; PageHeader dp;
int result; int result;
uint16 sv_infomask;
/* increment access statistics */ /* increment access statistics */
IncrHeapAccessStat(local_mark4update); IncrHeapAccessStat(local_mark4update);
@ -1670,7 +1679,10 @@ heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer)
tuple->t_len = ItemIdGetLength(lp); tuple->t_len = ItemIdGetLength(lp);
l3: l3:
sv_infomask = tuple->t_data->t_infomask;
result = HeapTupleSatisfiesUpdate(tuple); result = HeapTupleSatisfiesUpdate(tuple);
if (sv_infomask != tuple->t_data->t_infomask)
SetBufferCommitInfoNeedsSave(*buffer);
if (result == HeapTupleInvisible) if (result == HeapTupleInvisible)
{ {
@ -1687,7 +1699,7 @@ l3:
XactLockTableWait(xwait); XactLockTableWait(xwait);
LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE); LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE);
if (TransactionIdDidAbort(xwait)) if (!TransactionIdDidCommit(xwait))
goto l3; goto l3;
/* /*