please apply patch for GiST (7.1.1, current cvs)

Started by Oleg Bartunovover 24 years ago4 messages
#1Oleg Bartunov
oleg@sai.msu.su
1 attachment(s)

Hi,

we found a problem in GiST with massive insert/update operations
with many NULLs ( inserting of NULL into indexed field cause
ERROR: MemoryContextAlloc: invalid request size)
As a workaround 'vacuum analyze' could be used.

This patch resolves the problem, please upply to 7.1.1 sources and
current cvs tree.

Regards,
Oleg
_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83

Attachments:

patch_gisttext/plain; charset=US-ASCII; name=patch_gistDownload
*** postgresql-7.1.1/src/backend/access/gist/gist.c.orig	Tue May 15 12:31:01 2001
--- postgresql-7.1.1/src/backend/access/gist/gist.c	Tue May 15 12:55:20 2001
***************
*** 1199,1211 ****
  	gistentryinit(*e, pr, r, pg, o, b, l);
  	if (giststate->haskeytype)
  	{
! 		dep = (GISTENTRY *)
! 			DatumGetPointer(FunctionCall1(&giststate->decompressFn,
  										  PointerGetDatum(e)));
! 		gistentryinit(*e, dep->pred, dep->rel, dep->page, dep->offset, dep->bytes,
  					  dep->leafkey);
! 		if (dep != e)
! 			pfree(dep);
  	}
  }
  
--- 1199,1215 ----
  	gistentryinit(*e, pr, r, pg, o, b, l);
  	if (giststate->haskeytype)
  	{
! 		if ( b ) {
! 			dep = (GISTENTRY *)
! 				DatumGetPointer(FunctionCall1(&giststate->decompressFn,
  										  PointerGetDatum(e)));
! 			gistentryinit(*e, dep->pred, dep->rel, dep->page, dep->offset, dep->bytes,
  					  dep->leafkey);
! 			if (dep != e)
! 				pfree(dep);
! 		} else {
! 			gistentryinit(*e, (char*)NULL, r, pg, o, 0, l);
! 		}
  	}
  }
  
*** postgresql-7.1.1/src/backend/access/gist/gistget.c.orig	Mon May 14 18:55:31 2001
--- postgresql-7.1.1/src/backend/access/gist/gistget.c	Mon May 14 19:12:08 2001
***************
*** 241,256 ****
  							  1,
  							  tupdesc,
  							  &isNull);
! 		gistdentryinit(giststate, &de, (char *) datum, r, p, offset,
! 					   IndexTupleSize(tuple) - sizeof(IndexTupleData),
! 					   FALSE);
! 
! 		if (isNull)
  		{
  			/* XXX eventually should check if SK_ISNULL */
  			return false;
  		}
  
  		if (key[0].sk_flags & SK_COMMUTE)
  		{
  			test = FunctionCall3(&key[0].sk_func,
--- 241,256 ----
  							  1,
  							  tupdesc,
  							  &isNull);
! 		if (isNull || IndexTupleSize(tuple) == sizeof(IndexTupleData) )
  		{
  			/* XXX eventually should check if SK_ISNULL */
  			return false;
  		}
  
+ 		gistdentryinit(giststate, &de, (char *) datum, r, p, offset,
+ 					   IndexTupleSize(tuple) - sizeof(IndexTupleData),
+ 					   FALSE);
+ 
  		if (key[0].sk_flags & SK_COMMUTE)
  		{
  			test = FunctionCall3(&key[0].sk_func,
***************
*** 265,270 ****
--- 265,273 ----
  								 key[0].sk_argument,
  								 ObjectIdGetDatum(key[0].sk_procedure));
  		}
+ 
+ 		if ( (char*)de.pred != (char*)datum )
+ 			if ( de.pred ) pfree( de.pred );
  
  		if (DatumGetBool(test) == !!(key[0].sk_flags & SK_NEGATE))
  			return false;
#2Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Oleg Bartunov (#1)
Re: please apply patch for GiST (7.1.1, current cvs)

Applied to 7.1.1 and 7.2. Thanks.

Hi,

we found a problem in GiST with massive insert/update operations
with many NULLs ( inserting of NULL into indexed field cause
ERROR: MemoryContextAlloc: invalid request size)
As a workaround 'vacuum analyze' could be used.

This patch resolves the problem, please upply to 7.1.1 sources and
current cvs tree.

Regards,
Oleg
_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83

Content-Description:

[ Attachment, skipping... ]

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://www.postgresql.org/search.mpl

-- 
  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
#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#2)
Re: please apply patch for GiST (7.1.1, current cvs)

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Applied to 7.1.1 and 7.2. Thanks.

You seem to have missed the REL7_1_STABLE branch ...

regards, tom lane

#4Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Tom Lane (#3)
Re: please apply patch for GiST (7.1.1, current cvs)

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Applied to 7.1.1 and 7.2. Thanks.

You seem to have missed the REL7_1_STABLE branch ...

Got it now. Not sure how I missed the apply the first pass. Thanks.

-- 
  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