Re: More heap tuple header fixes - Mailing list pgsql-patches

From Bruce Momjian
Subject Re: More heap tuple header fixes
Date
Msg-id 200207232203.g6NM33W06862@candle.pha.pa.us
Whole thread Raw
In response to More heap tuple header fixes  (Manfred Koizar <mkoi-pg@aon.at>)
List pgsql-patches
Your patch has been added to the PostgreSQL unapplied patches list at:

    http://candle.pha.pa.us/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

---------------------------------------------------------------------------


Manfred Koizar wrote:
> This patch fixes one serious bug (runaway INSERT) and a few rare (and
> hard to reproduce) error conditions.
>
> Servus
>  Manfred

> diff -ruN ../base/src/backend/access/heap/heapam.c src/backend/access/heap/heapam.c
> --- ../base/src/backend/access/heap/heapam.c    2002-07-20 17:27:18.000000000 +0200
> +++ src/backend/access/heap/heapam.c    2002-07-20 19:43:19.000000000 +0200
> @@ -1123,11 +1123,14 @@
>              CheckMaxObjectId(HeapTupleGetOid(tup));
>      }
>
> +    tup->t_data->t_infomask &= ~(HEAP_XACT_MASK);
>      HeapTupleHeaderSetXmin(tup->t_data, GetCurrentTransactionId());
>      HeapTupleHeaderSetCmin(tup->t_data, cid);
>      HeapTupleHeaderSetXmaxInvalid(tup->t_data);
> -    HeapTupleHeaderSetCmax(tup->t_data, FirstCommandId);
> -    tup->t_data->t_infomask &= ~(HEAP_XACT_MASK);
> +    /*
> +     * Do *not* set Cmax!  This would overwrite Cmin.
> +     */
> +    /* HeapTupleHeaderSetCmax(tup->t_data, FirstCommandId); */
>      tup->t_data->t_infomask |= HEAP_XMAX_INVALID;
>      tup->t_tableOid = relation->rd_id;
>
> @@ -2147,7 +2150,11 @@
>
>      if (redo)
>      {
> -        htup->t_infomask &= ~(HEAP_XMAX_COMMITTED |
> +        /*
> +         * On redo from WAL we cannot rely on a tqual-routine
> +         * to have reset HEAP_MOVED.
> +         */
> +        htup->t_infomask &= ~(HEAP_MOVED | HEAP_XMAX_COMMITTED |
>                                HEAP_XMAX_INVALID | HEAP_MARKED_FOR_UPDATE);
>          HeapTupleHeaderSetXmax(htup, record->xl_xid);
>          HeapTupleHeaderSetCmax(htup, FirstCommandId);
> @@ -2320,7 +2327,11 @@
>          }
>          else
>          {
> -            htup->t_infomask &= ~(HEAP_XMAX_COMMITTED |
> +            /*
> +             * On redo from WAL we cannot rely on a tqual-routine
> +             * to have reset HEAP_MOVED.
> +             */
> +            htup->t_infomask &= ~(HEAP_MOVED | HEAP_XMAX_COMMITTED |
>                               HEAP_XMAX_INVALID | HEAP_MARKED_FOR_UPDATE);
>              HeapTupleHeaderSetXmax(htup, record->xl_xid);
>              HeapTupleHeaderSetCmax(htup, FirstCommandId);
> diff -ruN ../base/src/backend/utils/time/tqual.c src/backend/utils/time/tqual.c
> --- ../base/src/backend/utils/time/tqual.c    2002-07-20 17:27:19.000000000 +0200
> +++ src/backend/utils/time/tqual.c    2002-07-20 19:27:03.000000000 +0200
> @@ -83,6 +83,7 @@
>                      return false;
>                  }
>                  tuple->t_infomask |= HEAP_XMIN_COMMITTED;
> +                tuple->t_infomask &= ~HEAP_MOVED;
>              }
>          }
>          else if (tuple->t_infomask & HEAP_MOVED_IN)

>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: More heap tuple header fixes
Next
From: Bruce Momjian
Date:
Subject: Re: guc GetConfigOptionByNum and tablefunc API - minor changes