Search Postgresql Archives

Re: index scan leads to result that is different from sec scan after upgrading to 8.3.4

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fixed, patch attached.


--
Teodor Sigaev                                   E-mail: teodor@xxxxxxxxx
                                                   WWW: http://www.sigaev.ru/
diff -c -r src.orig/backend/access/gist/gistget.c src/backend/access/gist/gistget.c
*** src.orig/backend/access/gist/gistget.c	2008-10-22 12:07:39.000000000 +0400
--- src/backend/access/gist/gistget.c	2008-10-22 15:13:23.000000000 +0400
***************
*** 49,55 ****
  
  		for (offset = FirstOffsetNumber; offset <= maxoff; offset = OffsetNumberNext(offset))
  		{
! 				IndexTuple	ituple = (IndexTuple) PageGetItem(p, PageGetItemId(p, offset));
  
  			if (ItemPointerEquals(&(ituple->t_tid), iptr))
  			{
--- 49,55 ----
  
  		for (offset = FirstOffsetNumber; offset <= maxoff; offset = OffsetNumberNext(offset))
  		{
! 			IndexTuple	ituple = (IndexTuple) PageGetItem(p, PageGetItemId(p, offset));
  
  			if (ItemPointerEquals(&(ituple->t_tid), iptr))
  			{
***************
*** 157,163 ****
  	{
  		while( ntids < maxtids && so->curPageData < so->nPageData )
  		{
! 			tids[ ntids ] = scan->xs_ctup.t_self = so->pageData[ so->curPageData ];
  				
  			so->curPageData ++;
  			ntids++;
--- 157,167 ----
  	{
  		while( ntids < maxtids && so->curPageData < so->nPageData )
  		{
! 			tids[ ntids ] = scan->xs_ctup.t_self = so->pageData[ so->curPageData ].heapPtr;
! 			ItemPointerSet(&(so->curpos),
! 							   BufferGetBlockNumber(so->curbuf), 
! 							   so->pageData[ so->curPageData ].pageOffset);
! 
  				
  			so->curPageData ++;
  			ntids++;
***************
*** 251,258 ****
  			{
  				while( ntids < maxtids && so->curPageData < so->nPageData )
  				{
! 					tids[ ntids ] = scan->xs_ctup.t_self = so->pageData[ so->curPageData ];
  				
  					so->curPageData ++;
  					ntids++;
  				}
--- 255,267 ----
  			{
  				while( ntids < maxtids && so->curPageData < so->nPageData )
  				{
! 					tids[ ntids ] = scan->xs_ctup.t_self = 
! 						so->pageData[ so->curPageData ].heapPtr;
  				
+ 					ItemPointerSet(&(so->curpos),
+ 								   BufferGetBlockNumber(so->curbuf), 
+ 								   so->pageData[ so->curPageData ].pageOffset);
+ 
  					so->curPageData ++;
  					ntids++;
  				}
***************
*** 297,309 ****
  				 * we can efficiently resume the index scan later.
  				 */
  
- 				ItemPointerSet(&(so->curpos),
- 							   BufferGetBlockNumber(so->curbuf), n);
- 
  				if (!(ignore_killed_tuples && ItemIdIsDead(PageGetItemId(p, n))))
  				{
  					it = (IndexTuple) PageGetItem(p, PageGetItemId(p, n));
! 					so->pageData[ so->nPageData ] = it->t_tid;
  					so->nPageData ++;
  				}
  			}
--- 306,316 ----
  				 * we can efficiently resume the index scan later.
  				 */
  
  				if (!(ignore_killed_tuples && ItemIdIsDead(PageGetItemId(p, n))))
  				{
  					it = (IndexTuple) PageGetItem(p, PageGetItemId(p, n));
! 					so->pageData[ so->nPageData ].heapPtr = it->t_tid;
! 					so->pageData[ so->nPageData ].pageOffset = n;
  					so->nPageData ++;
  				}
  			}
diff -c -r src.orig/backend/access/gist/gistscan.c src/backend/access/gist/gistscan.c
*** src.orig/backend/access/gist/gistscan.c	2008-10-22 12:07:39.000000000 +0400
--- src/backend/access/gist/gistscan.c	2008-10-22 14:55:58.000000000 +0400
***************
*** 163,169 ****
  	so->markNPageData = so->nPageData;
  	so->markCurPageData = so->curPageData;
  	if ( so->markNPageData > 0 )
! 		memcpy( so->markPageData, so->pageData, sizeof(ItemPointerData) * so->markNPageData );		
  
  	PG_RETURN_VOID();
  }
--- 163,169 ----
  	so->markNPageData = so->nPageData;
  	so->markCurPageData = so->curPageData;
  	if ( so->markNPageData > 0 )
! 		memcpy( so->markPageData, so->pageData, sizeof(MatchedItemPtr) * so->markNPageData );		
  
  	PG_RETURN_VOID();
  }
***************
*** 217,223 ****
  	so->nPageData = so->markNPageData;
  	so->curPageData = so->markNPageData;
  	if ( so->markNPageData > 0 )
! 		memcpy( so->pageData, so->markPageData, sizeof(ItemPointerData) * so->markNPageData );		
  
  	PG_RETURN_VOID();
  }
--- 217,223 ----
  	so->nPageData = so->markNPageData;
  	so->curPageData = so->markNPageData;
  	if ( so->markNPageData > 0 )
! 		memcpy( so->pageData, so->markPageData, sizeof(MatchedItemPtr) * so->markNPageData );		
  
  	PG_RETURN_VOID();
  }
diff -c -r src.orig/include/access/gist_private.h src/include/access/gist_private.h
*** src.orig/include/access/gist_private.h	2008-10-22 12:07:50.000000000 +0400
--- src/include/access/gist_private.h	2008-10-22 15:00:24.000000000 +0400
***************
*** 60,65 ****
--- 60,71 ----
  	TupleDesc	tupdesc;
  } GISTSTATE;
  
+ typedef struct MatchedItemPtr 
+ {
+ 	ItemPointerData		heapPtr;
+ 	OffsetNumber		pageOffset; /* offset in index page */
+ } MatchedItemPtr;
+ 
  /*
   *	When we're doing a scan, we need to keep track of the parent stack
   *	for the marked and current items.
***************
*** 77,86 ****
  	Buffer		markbuf;
  	ItemPointerData markpos;
  
! 	ItemPointerData	pageData[BLCKSZ/sizeof(IndexTupleData)];
  	OffsetNumber	nPageData;
  	OffsetNumber	curPageData;
! 	ItemPointerData	markPageData[BLCKSZ/sizeof(IndexTupleData)];
  	OffsetNumber	markNPageData;
  	OffsetNumber	markCurPageData;
  } GISTScanOpaqueData;
--- 83,92 ----
  	Buffer		markbuf;
  	ItemPointerData markpos;
  
! 	MatchedItemPtr	pageData[BLCKSZ/sizeof(IndexTupleData)];
  	OffsetNumber	nPageData;
  	OffsetNumber	curPageData;
! 	MatchedItemPtr	markPageData[BLCKSZ/sizeof(IndexTupleData)];
  	OffsetNumber	markNPageData;
  	OffsetNumber	markCurPageData;
  } GISTScanOpaqueData;
-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux