*** ./src/backend/access/gist/gist.c.orig	Thu Jan 31 18:08:34 2002
--- ./src/backend/access/gist/gist.c	Thu Jan 31 18:09:14 2002
***************
*** 87,98 ****
  				Page page,
  				IndexTuple *itup,
  				int len,
! 				OffsetNumber off,
! 				GISTSTATE *giststate);
  static int gistnospace(Page page,
  			IndexTuple *itvec, int len);
! static IndexTuple *gistreadbuffer(Relation r,
! 			   Buffer buffer, int *len);
  static IndexTuple *gistjoinvector(
  			   IndexTuple *itvec, int *len,
  			   IndexTuple *additvec, int addlen);
--- 87,96 ----
  				Page page,
  				IndexTuple *itup,
  				int len,
! 				OffsetNumber off);
  static int gistnospace(Page page,
  			IndexTuple *itvec, int len);
! static IndexTuple *gistreadbuffer(Buffer buffer, int *len);
  static IndexTuple *gistjoinvector(
  			   IndexTuple *itvec, int *len,
  			   IndexTuple *additvec, int addlen);
***************
*** 117,123 ****
  		  int *len,
  		  GISTSTATE *giststate,
  		  InsertIndexResult *res);
! static void gistnewroot(GISTSTATE *giststate, Relation r,
  			IndexTuple *itup, int len);
  static void GISTInitBuffer(Buffer b, uint32 f);
  static OffsetNumber gistchoose(Relation r, Page p,
--- 115,121 ----
  		  int *len,
  		  GISTSTATE *giststate,
  		  InsertIndexResult *res);
! static void gistnewroot(Relation r,
  			IndexTuple *itup, int len);
  static void GISTInitBuffer(Buffer b, uint32 f);
  static OffsetNumber gistchoose(Relation r, Page p,
***************
*** 359,369 ****
  
  #ifdef GIST_PAGEADDITEM
  /*
! ** Take a compressed entry, and install it on a page.  Since we now know
! ** where the entry will live, we decompress it and recompress it using
! ** that knowledge (some compression routines may want to fish around
! ** on the page, for example, or do something special for leaf nodes.)
! */
  static OffsetNumber
  gistPageAddItem(GISTSTATE *giststate,
  				Relation r,
--- 357,367 ----
  
  #ifdef GIST_PAGEADDITEM
  /*
!  * Take a compressed entry, and install it on a page.  Since we now know
!  * where the entry will live, we decompress it and recompress it using
!  * that knowledge (some compression routines may want to fish around
!  * on the page, for example, or do something special for leaf nodes.)
!  */
  static OffsetNumber
  gistPageAddItem(GISTSTATE *giststate,
  				Relation r,
***************
*** 425,431 ****
  
  	ret = gistlayerinsert(r, GISTP_ROOT, &instup, &len, res, giststate);
  	if (ret & SPLITED)
! 		gistnewroot(giststate, r, instup, len);
  
  	for (i = 0; i < len; i++)
  		pfree(instup[i]);
--- 423,429 ----
  
  	ret = gistlayerinsert(r, GISTP_ROOT, &instup, &len, res, giststate);
  	if (ret & SPLITED)
! 		gistnewroot(r, instup, len);
  
  	for (i = 0; i < len; i++)
  		pfree(instup[i]);
***************
*** 452,458 ****
  	if (!(opaque->flags & F_LEAF))
  	{
  		/* internal page, so we must walk on tree */
! 		/* len IS equial 1 */
  		ItemId		iid;
  		BlockNumber nblkno;
  		ItemPointerData oldtid;
--- 450,456 ----
  	if (!(opaque->flags & F_LEAF))
  	{
  		/* internal page, so we must walk on tree */
! 		/* len IS equal 1 */
  		ItemId		iid;
  		BlockNumber nblkno;
  		ItemPointerData oldtid;
***************
*** 509,515 ****
  					oldlen;
  
  		ret |= SPLITED;
! 		itvec = gistreadbuffer(r, buffer, &tlen);
  		itvec = gistjoinvector(itvec, &tlen, (*itup), *len);
  		oldlen = *len;
  		newitup = gistSplit(r, buffer, itvec, &tlen, giststate,
--- 507,513 ----
  					oldlen;
  
  		ret |= SPLITED;
! 		itvec = gistreadbuffer(buffer, &tlen);
  		itvec = gistjoinvector(itvec, &tlen, (*itup), *len);
  		oldlen = *len;
  		newitup = gistSplit(r, buffer, itvec, &tlen, giststate,
***************
*** 534,540 ****
  			FirstOffsetNumber
  			:
  			OffsetNumberNext(PageGetMaxOffsetNumber(page));
! 		l = gistwritebuffer(r, page, (*itup), *len, off, giststate);
  		WriteBuffer(buffer);
  
  		/*
--- 532,538 ----
  			FirstOffsetNumber
  			:
  			OffsetNumberNext(PageGetMaxOffsetNumber(page));
! 		l = gistwritebuffer(r, page, (*itup), *len, off);
  		WriteBuffer(buffer);
  
  		/*
***************
*** 570,576 ****
   */
  static OffsetNumber
  gistwritebuffer(Relation r, Page page, IndexTuple *itup,
! 				int len, OffsetNumber off, GISTSTATE *giststate)
  {
  	OffsetNumber l = InvalidOffsetNumber;
  	int			i;
--- 568,574 ----
   */
  static OffsetNumber
  gistwritebuffer(Relation r, Page page, IndexTuple *itup,
! 				int len, OffsetNumber off)
  {
  	OffsetNumber l = InvalidOffsetNumber;
  	int			i;
***************
*** 609,615 ****
  static int
  gistnospace(Page page, IndexTuple *itvec, int len)
  {
! 	int			size = 0;
  	int			i;
  
  	for (i = 0; i < len; i++)
--- 607,613 ----
  static int
  gistnospace(Page page, IndexTuple *itvec, int len)
  {
! 	unsigned int			size = 0;
  	int			i;
  
  	for (i = 0; i < len; i++)
***************
*** 622,628 ****
   * Read buffer into itup vector
   */
  static IndexTuple *
! gistreadbuffer(Relation r, Buffer buffer, int *len /* out */ )
  {
  	OffsetNumber i,
  				maxoff;
--- 620,626 ----
   * Read buffer into itup vector
   */
  static IndexTuple *
! gistreadbuffer(Buffer buffer, int *len /* out */ )
  {
  	OffsetNumber i,
  				maxoff;
***************
*** 1351,1357 ****
  	{
  		OffsetNumber l;
  
! 		l = gistwritebuffer(r, right, rvectup, v.spl_nright, FirstOffsetNumber, giststate);
  		WriteBuffer(rightbuf);
  
  		if (res)
--- 1349,1355 ----
  	{
  		OffsetNumber l;
  
! 		l = gistwritebuffer(r, right, rvectup, v.spl_nright, FirstOffsetNumber);
  		WriteBuffer(rightbuf);
  
  		if (res)
***************
*** 1384,1390 ****
  	{
  		OffsetNumber l;
  
! 		l = gistwritebuffer(r, left, lvectup, v.spl_nleft, FirstOffsetNumber, giststate);
  		if (BufferGetBlockNumber(buffer) != GISTP_ROOT)
  			PageRestoreTempPage(left, p);
  
--- 1382,1388 ----
  	{
  		OffsetNumber l;
  
! 		l = gistwritebuffer(r, left, lvectup, v.spl_nleft, FirstOffsetNumber);
  		if (BufferGetBlockNumber(buffer) != GISTP_ROOT)
  			PageRestoreTempPage(left, p);
  
***************
*** 1414,1420 ****
  }
  
  static void
! gistnewroot(GISTSTATE *giststate, Relation r, IndexTuple *itup, int len)
  {
  	Buffer		b;
  	Page		p;
--- 1412,1418 ----
  }
  
  static void
! gistnewroot(Relation r, IndexTuple *itup, int len)
  {
  	Buffer		b;
  	Page		p;
***************
*** 1423,1429 ****
  	GISTInitBuffer(b, 0);
  	p = BufferGetPage(b);
  
! 	gistwritebuffer(r, p, itup, len, FirstOffsetNumber, giststate);
  	WriteBuffer(b);
  }
  
--- 1421,1427 ----
  	GISTInitBuffer(b, 0);
  	p = BufferGetPage(b);
  
! 	gistwritebuffer(r, p, itup, len, FirstOffsetNumber);
  	WriteBuffer(b);
  }
  
*** ./src/backend/access/gist/gistget.c.orig	Thu Jan 31 18:08:34 2002
--- ./src/backend/access/gist/gistget.c	Thu Jan 31 18:09:23 2002
***************
*** 24,30 ****
  static RetrieveIndexResult gistfirst(IndexScanDesc s, ScanDirection dir);
  static RetrieveIndexResult gistnext(IndexScanDesc s, ScanDirection dir);
  static ItemPointer gistheapptr(Relation r, ItemPointer itemp);
! static bool gistindex_keytest(IndexTuple tuple, TupleDesc tupdesc,
  				  int scanKeySize, ScanKey key, GISTSTATE *giststate,
  				  Relation r, Page p, OffsetNumber offset);
  
--- 24,30 ----
  static RetrieveIndexResult gistfirst(IndexScanDesc s, ScanDirection dir);
  static RetrieveIndexResult gistnext(IndexScanDesc s, ScanDirection dir);
  static ItemPointer gistheapptr(Relation r, ItemPointer itemp);
! static bool gistindex_keytest(IndexTuple tuple,
  				  int scanKeySize, ScanKey key, GISTSTATE *giststate,
  				  Relation r, Page p, OffsetNumber offset);
  
***************
*** 219,225 ****
  /* Similar to index_keytest, but decompresses the key in the IndexTuple */
  static bool
  gistindex_keytest(IndexTuple tuple,
- 				  TupleDesc tupdesc,
  				  int scanKeySize,
  				  ScanKey key,
  				  GISTSTATE *giststate,
--- 219,224 ----
***************
*** 314,320 ****
  	{
  		it = (IndexTuple) PageGetItem(p, PageGetItemId(p, n));
  		if (gistindex_keytest(it,
- 							  RelationGetDescr(s->relation),
  							  s->numberOfKeys, s->keyData, giststate,
  							  s->relation, p, n))
  			break;
--- 313,318 ----
*** ./src/backend/access/gist/gistscan.c.orig	Thu Jan 31 18:08:34 2002
--- ./src/backend/access/gist/gistscan.c	Thu Jan 31 18:09:36 2002
***************
*** 24,31 ****
  static void gistdropscan(IndexScanDesc s);
  static void gistadjone(IndexScanDesc s, int op, BlockNumber blkno,
  		   OffsetNumber offnum);
! static void adjuststack(GISTSTACK *stk, BlockNumber blkno,
! 			OffsetNumber offnum);
  static void adjustiptr(IndexScanDesc s, ItemPointer iptr,
  		   int op, BlockNumber blkno, OffsetNumber offnum);
  
--- 24,30 ----
  static void gistdropscan(IndexScanDesc s);
  static void gistadjone(IndexScanDesc s, int op, BlockNumber blkno,
  		   OffsetNumber offnum);
! static void adjuststack(GISTSTACK *stk, BlockNumber blkno);
  static void adjustiptr(IndexScanDesc s, ItemPointer iptr,
  		   int op, BlockNumber blkno, OffsetNumber offnum);
  
***************
*** 340,347 ****
  
  	if (op == GISTOP_SPLIT)
  	{
! 		adjuststack(so->s_stack, blkno, offnum);
! 		adjuststack(so->s_markstk, blkno, offnum);
  	}
  }
  
--- 339,346 ----
  
  	if (op == GISTOP_SPLIT)
  	{
! 		adjuststack(so->s_stack, blkno);
! 		adjuststack(so->s_markstk, blkno);
  	}
  }
  
***************
*** 428,435 ****
  /*ARGSUSED*/
  static void
  adjuststack(GISTSTACK *stk,
! 			BlockNumber blkno,
! 			OffsetNumber offnum)
  {
  	while (stk != (GISTSTACK *) NULL)
  	{
--- 427,433 ----
  /*ARGSUSED*/
  static void
  adjuststack(GISTSTACK *stk,
! 			BlockNumber blkno)
  {
  	while (stk != (GISTSTACK *) NULL)
  	{
