Skip site navigation (1) Skip section navigation (2)

Re: More heap tuple header fixes

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Manfred Koizar <mkoi-pg(at)aon(dot)at>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: More heap tuple header fixes
Date: 2002-07-23 22:03:03
Message-ID: 200207232203.g6NM33W06862@candle.pha.pa.us (view raw or flat)
Thread:
Lists: 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(at)candle(dot)pha(dot)pa(dot)us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

In response to

pgsql-patches by date

Next:From: Bruce MomjianDate: 2002-07-23 22:17:28
Subject: Re: guc GetConfigOptionByNum and tablefunc API - minor changes
Previous:From: Bruce MomjianDate: 2002-07-23 22:02:30
Subject: Re: More heap tuple header fixes

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group