*** src.orig/backend/access/gist/gistproc.c	2009-03-27 17:21:26.000000000 +0300
--- src/backend/access/gist/gistproc.c	2009-03-27 19:43:24.000000000 +0300
***************
*** 428,454 ****
  			CenterX = ((double) cur->high.x + (double) cur->low.x) / 2.0;
  			CenterY = ((double) cur->high.y + (double) cur->low.y) / 2.0;
  
! 			if (CenterX < avgCenterX)
! 				ADDLIST(listL, unionL, posL, i);
! 			else if (CenterX == avgCenterX)
  			{
  				if (posL > posR)
  					ADDLIST(listR, unionR, posR, i);
  				else
  					ADDLIST(listL, unionL, posL, i);
  			}
  			else
  				ADDLIST(listR, unionR, posR, i);
  
! 			if (CenterY < avgCenterY)
! 				ADDLIST(listB, unionB, posB, i);
! 			else if (CenterY == avgCenterY)
  			{
  				if (posB > posT)
  					ADDLIST(listT, unionT, posT, i);
  				else
  					ADDLIST(listB, unionB, posB, i);
  			}
  			else
  				ADDLIST(listT, unionT, posT, i);
  		}
--- 428,454 ----
  			CenterX = ((double) cur->high.x + (double) cur->low.x) / 2.0;
  			CenterY = ((double) cur->high.y + (double) cur->low.y) / 2.0;
  
! 			if (FPeq(CenterX, avgCenterX))
  			{
  				if (posL > posR)
  					ADDLIST(listR, unionR, posR, i);
  				else
  					ADDLIST(listL, unionL, posL, i);
  			}
+ 			else if (CenterX < avgCenterX)
+ 				ADDLIST(listL, unionL, posL, i);
  			else
  				ADDLIST(listR, unionR, posR, i);
  
! 			if (FPeq(CenterY, avgCenterY))
  			{
  				if (posB > posT)
  					ADDLIST(listT, unionT, posT, i);
  				else
  					ADDLIST(listB, unionB, posB, i);
  			}
+ 			else if (CenterY < avgCenterY)
+ 				ADDLIST(listB, unionB, posB, i);
  			else
  				ADDLIST(listT, unionT, posT, i);
  		}
