pgsql: Fix edge-case behavior of pg_next_dst_boundary().

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix edge-case behavior of pg_next_dst_boundary().
Date: 2012-04-25 21:26:25
Message-ID: E1SN9jF-0005qO-31@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix edge-case behavior of pg_next_dst_boundary().

Due to rather sloppy thinking (on my part, I'm afraid) about the
appropriate behavior for boundary conditions, pg_next_dst_boundary() gave
undefined, platform-dependent results when the input time is exactly the
last recorded DST transition time for the specified time zone, as a result
of fetching values one past the end of its data arrays.

Change its specification to be that it always finds the next DST boundary
*after* the input time, and adjust code to match that. The sole existing
caller, DetermineTimeZoneOffset, doesn't actually care about this
distinction, since it always uses a probe time earlier than the instant
that it does care about. So it seemed best to me to change the API to make
the result=1 and result=0 cases more consistent, specifically to ensure
that the "before" outputs always describe the state at the given time,
rather than hacking the code to obey the previous API comment exactly.

Per bug #6605 from Sergey Burladyan. Back-patch to all supported versions.

Branch
------
REL9_0_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/b0f24b5626727f81ecd7024ed5cefbaa336c8100

Modified Files
--------------
src/timezone/localtime.c | 23 ++++++++++++-----------
1 files changed, 12 insertions(+), 11 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2012-04-26 00:21:04 pgsql: Fix planner's handling of RETURNING lists in writable CTEs.
Previous Message Tom Lane 2012-04-25 21:26:24 pgsql: Fix edge-case behavior of pg_next_dst_boundary().