From: Tom Lane Date: Wed, 13 Oct 2004 22:22:41 +0000 (+0000) Subject: Repair possible failure to update hint bits back to disk, per X-Git-Tag: REL7_2_6~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6b3d751747ef766e42d4657807319c8c21aecff7;p=postgresql 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. --- diff --git a/contrib/pgstattuple/pgstattuple.c b/contrib/pgstattuple/pgstattuple.c index b5afab80de..0b534768e5 100644 --- a/contrib/pgstattuple/pgstattuple.c +++ b/contrib/pgstattuple/pgstattuple.c @@ -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 * @@ -69,6 +69,9 @@ pgstattuple(PG_FUNCTION_ARGS) while ((tuple = heap_getnext(scan, 0))) { + uint16 sv_infomask; + + sv_infomask = tuple->t_data->t_infomask; if (HeapTupleSatisfiesNow(tuple->t_data)) { tuple_len += tuple->t_len; @@ -79,6 +82,8 @@ pgstattuple(PG_FUNCTION_ARGS) dead_tuple_len += tuple->t_len; 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 diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index 0ab2c08f30..d6114e43f5 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -8,7 +8,7 @@ * * * 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 @@ -1155,6 +1155,7 @@ heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid) PageHeader dp; Buffer buffer; int result; + uint16 sv_infomask; /* increment access statistics */ IncrHeapAccessStat(local_delete); @@ -1178,7 +1179,10 @@ heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid) tp.t_tableOid = relation->rd_id; l1: + sv_infomask = tp.t_data->t_infomask; result = HeapTupleSatisfiesUpdate(&tp); + if (sv_infomask != tp.t_data->t_infomask) + SetBufferCommitInfoNeedsSave(buffer); if (result == HeapTupleInvisible) { @@ -1195,7 +1199,7 @@ l1: XactLockTableWait(xwait); LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE); - if (TransactionIdDidAbort(xwait)) + if (!TransactionIdDidCommit(xwait)) goto l1; /* @@ -1345,6 +1349,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup, Size newtupsize, pagefree; int result; + uint16 sv_infomask; /* increment access statistics */ IncrHeapAccessStat(local_replace); @@ -1373,7 +1378,10 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup, */ l2: + sv_infomask = oldtup.t_data->t_infomask; result = HeapTupleSatisfiesUpdate(&oldtup); + if (sv_infomask != oldtup.t_data->t_infomask) + SetBufferCommitInfoNeedsSave(buffer); if (result == HeapTupleInvisible) { @@ -1390,7 +1398,7 @@ l2: XactLockTableWait(xwait); LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE); - if (TransactionIdDidAbort(xwait)) + if (!TransactionIdDidCommit(xwait)) goto l2; /* @@ -1651,6 +1659,7 @@ heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer) ItemId lp; PageHeader dp; int result; + uint16 sv_infomask; /* increment access statistics */ IncrHeapAccessStat(local_mark4update); @@ -1670,7 +1679,10 @@ heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer) tuple->t_len = ItemIdGetLength(lp); l3: + sv_infomask = tuple->t_data->t_infomask; result = HeapTupleSatisfiesUpdate(tuple); + if (sv_infomask != tuple->t_data->t_infomask) + SetBufferCommitInfoNeedsSave(*buffer); if (result == HeapTupleInvisible) { @@ -1687,7 +1699,7 @@ l3: XactLockTableWait(xwait); LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE); - if (TransactionIdDidAbort(xwait)) + if (!TransactionIdDidCommit(xwait)) goto l3; /*