From owner-freebsd-ports Tue Apr 9 23:30:19 2002 Delivered-To: freebsd-ports@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 9C56237B404 for ; Tue, 9 Apr 2002 23:30:01 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g3A6U1m72935; Tue, 9 Apr 2002 23:30:01 -0700 (PDT) (envelope-from gnats) Received: from mail.tgd.net (mail.tgd.net [209.81.25.10]) by hub.freebsd.org (Postfix) with ESMTP id 4C8AE37B416 for ; Tue, 9 Apr 2002 23:24:35 -0700 (PDT) Received: by mail.tgd.net (Postfix, from userid 1001) id F40E220F0A; Tue, 9 Apr 2002 23:24:34 -0700 (PDT) Message-Id: <20020410062434.F40E220F0A@mail.tgd.net> Date: Tue, 9 Apr 2002 23:24:34 -0700 (PDT) From: Sean Chittenden Reply-To: Sean Chittenden To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: ports/36954: PostgreSQL daylight savings fix... Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 36954 >Category: ports >Synopsis: PostgreSQL daylight savings fix... >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-ports >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Apr 09 23:30:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Sean Chittenden >Release: FreeBSD 4.5-STABLE i386 >Organization: >Environment: System: FreeBSD ninja1.internal 4.5-STABLE FreeBSD 4.5-STABLE #0: Fri Apr 5 18:08:12 PST 2002 root@ninja1.internal:/opt/obj/opt/src/sys/NINJA i386 >Description: PostgreSQL does not currently check the results of mktime(). On a border condition, mktime() fails and would populate invalid data into the database. Most other *NIX's seem to automatically account for this and automatically adjust the value when it gets passed to mktime(&tm). Should FreeBSD have it's mktime() in libc updated? >How-To-Repeat: CREATE TABEL tt ( tt TIMESTAMP ); INSERT INTO tt VALUES ('2002-4-7 2:0:0.0'); >Fix: Please add the following as a patch (databases/postgresql7/files/patch-ak-src::backend::utils::adt::datetime.c). Index: src/backend/utils/adt/datetime.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/utils/adt/datetime.c,v retrieving revision 1.88 diff -u -r1.88 datetime.c --- src/backend/utils/adt/datetime.c 2002/02/25 16:17:04 1.88 +++ src/backend/utils/adt/datetime.c 2002/04/10 06:12:45 @@ -1439,6 +1439,7 @@ DetermineLocalTimeZone(struct tm * tm) { int tz; + time_t t; if (HasCTZSet) tz = CTimeZone; @@ -1463,7 +1464,23 @@ /* indicate timezone unknown */ tmp->tm_isdst = -1; - mktime(tmp); + t = mktime(tmp); + if (t == -1) + { + /* Bump time up by an hour to see if time was an + * invalid time during a daylight savings switch */ + tmp->tm_hour += 1; + t = mktime(tmp); + + /* Assume UTC if mktime() still fails. + * + * If mktime() was successful with the adjusted time, + * adjust the real time object. */ + if (t == -1) + return 0; + else + tm->tm_hour += 1; + } tm->tm_isdst = tmp->tm_isdst; >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message