Repair possible failure to update hint bits back to disk, per
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 13 Oct 2004 22:22:41 +0000 (22:22 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 13 Oct 2004 22:22:41 +0000 (22:22 +0000)
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.

contrib/pgstattuple/pgstattuple.c
src/backend/access/heap/heapam.c

index b5afab80de1ec4c62968b371f73ed2b8de833dcd..0b534768e5f77e4fb4fa2aae29ab0248823e971d 100644 (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
  *
@@ -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
index 0ab2c08f3001ff1e989b2d8f652321ddd2fe446f..d6114e43f55a2ffc14ae4848ade9b8ba07393997 100644 (file)
@@ -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;
 
        /*