Index: src/timezone/localtime.c
===================================================================
RCS file: /home/hlinnaka/pgcvsrepository/pgsql/src/timezone/localtime.c,v
retrieving revision 1.17
diff -c -r1.17 localtime.c
*** src/timezone/localtime.c	4 Aug 2007 19:29:25 -0000	1.17
--- src/timezone/localtime.c	18 Sep 2007 13:41:03 -0000
***************
*** 1008,1013 ****
--- 1008,1014 ----
  	int			i;
  	int			j;
  	const pg_time_t t = *timep;
+ 	int high, low;
  
  	sp = &tz->state;
  	if (sp->timecnt == 0)
***************
*** 1056,1064 ****
  		return 1;
  	}
  	/* Else search to find the containing segment */
! 	for (i = 1; i < sp->timecnt; ++i)
! 		if (t <= sp->ats[i])
! 			break;
  	j = sp->types[i - 1];
  	ttisp = &sp->ttis[j];
  	*before_gmtoff = ttisp->tt_gmtoff;
--- 1057,1074 ----
  		return 1;
  	}
  	/* Else search to find the containing segment */
! 	low = 1;
! 	high = sp->timecnt - 1;
! 	while (high > low)
! 	{
! 		int mid = low + ((high - low) / 2);
! 		if (t > sp->ats[mid])
! 			low = mid + 1;
! 		else
! 			high = mid;
! 	}
! 	i = high;
! 
  	j = sp->types[i - 1];
  	ttisp = &sp->ttis[j];
  	*before_gmtoff = ttisp->tt_gmtoff;
