Skip to content

Commit 6b3d751

Browse files
committed
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.
1 parent 7b09190 commit 6b3d751

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

contrib/pgstattuple/pgstattuple.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $Header: /cvsroot/pgsql/contrib/pgstattuple/pgstattuple.c,v 1.3 2001/12/19 20:28:41 tgl Exp $
2+
* $Header: /cvsroot/pgsql/contrib/pgstattuple/pgstattuple.c,v 1.3.2.1 2004/10/13 22:22:40 tgl Exp $
33
*
44
* Copyright (c) 2001 Tatsuo Ishii
55
*
@@ -69,6 +69,9 @@ pgstattuple(PG_FUNCTION_ARGS)
6969

7070
while ((tuple = heap_getnext(scan, 0)))
7171
{
72+
uint16 sv_infomask;
73+
74+
sv_infomask = tuple->t_data->t_infomask;
7275
if (HeapTupleSatisfiesNow(tuple->t_data))
7376
{
7477
tuple_len += tuple->t_len;
@@ -79,6 +82,8 @@ pgstattuple(PG_FUNCTION_ARGS)
7982
dead_tuple_len += tuple->t_len;
8083
dead_tuple_count++;
8184
}
85+
if (sv_infomask != tuple->t_data->t_infomask)
86+
SetBufferCommitInfoNeedsSave(scan->rs_cbuf);
8287

8388
/*
8489
* To avoid physically reading the table twice, try to do the

src/backend/access/heap/heapam.c

Lines changed: 16 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/access/heap/heapam.c,v 1.129.2.2 2003/01/26 23:09:37 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.129.2.3 2004/10/13 22:22:41 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -1155,6 +1155,7 @@ heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid)
11551155
PageHeader dp;
11561156
Buffer buffer;
11571157
int result;
1158+
uint16 sv_infomask;
11581159

11591160
/* increment access statistics */
11601161
IncrHeapAccessStat(local_delete);
@@ -1178,7 +1179,10 @@ heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid)
11781179
tp.t_tableOid = relation->rd_id;
11791180

11801181
l1:
1182+
sv_infomask = tp.t_data->t_infomask;
11811183
result = HeapTupleSatisfiesUpdate(&tp);
1184+
if (sv_infomask != tp.t_data->t_infomask)
1185+
SetBufferCommitInfoNeedsSave(buffer);
11821186

11831187
if (result == HeapTupleInvisible)
11841188
{
@@ -1195,7 +1199,7 @@ heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid)
11951199
XactLockTableWait(xwait);
11961200

11971201
LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
1198-
if (TransactionIdDidAbort(xwait))
1202+
if (!TransactionIdDidCommit(xwait))
11991203
goto l1;
12001204

12011205
/*
@@ -1345,6 +1349,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
13451349
Size newtupsize,
13461350
pagefree;
13471351
int result;
1352+
uint16 sv_infomask;
13481353

13491354
/* increment access statistics */
13501355
IncrHeapAccessStat(local_replace);
@@ -1373,7 +1378,10 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
13731378
*/
13741379

13751380
l2:
1381+
sv_infomask = oldtup.t_data->t_infomask;
13761382
result = HeapTupleSatisfiesUpdate(&oldtup);
1383+
if (sv_infomask != oldtup.t_data->t_infomask)
1384+
SetBufferCommitInfoNeedsSave(buffer);
13771385

13781386
if (result == HeapTupleInvisible)
13791387
{
@@ -1390,7 +1398,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
13901398
XactLockTableWait(xwait);
13911399

13921400
LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
1393-
if (TransactionIdDidAbort(xwait))
1401+
if (!TransactionIdDidCommit(xwait))
13941402
goto l2;
13951403

13961404
/*
@@ -1651,6 +1659,7 @@ heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer)
16511659
ItemId lp;
16521660
PageHeader dp;
16531661
int result;
1662+
uint16 sv_infomask;
16541663

16551664
/* increment access statistics */
16561665
IncrHeapAccessStat(local_mark4update);
@@ -1670,7 +1679,10 @@ heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer)
16701679
tuple->t_len = ItemIdGetLength(lp);
16711680

16721681
l3:
1682+
sv_infomask = tuple->t_data->t_infomask;
16731683
result = HeapTupleSatisfiesUpdate(tuple);
1684+
if (sv_infomask != tuple->t_data->t_infomask)
1685+
SetBufferCommitInfoNeedsSave(*buffer);
16741686

16751687
if (result == HeapTupleInvisible)
16761688
{
@@ -1687,7 +1699,7 @@ heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer)
16871699
XactLockTableWait(xwait);
16881700

16891701
LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE);
1690-
if (TransactionIdDidAbort(xwait))
1702+
if (!TransactionIdDidCommit(xwait))
16911703
goto l3;
16921704

16931705
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy