> > Ehh... let me hack/check. Looks like 11. ?? In
> > lib/libc/stdtime/localtime.c, WRONG is defined as -1, not 11.
>
> > 1490 t = mktime(tmp);
> > (gdb)
> > 1491 fprintf(stderr, "%p\n", t); /* GCC optimizes this
> > away if I don't do
> > something */
> > (gdb)
> > 0x3c5e5ba0
> > (gdb) print t
> > $1 = 11
>
> > Doesn't make much sense to me where that'd come from... ? -sc
>
> I'd be inclined to believe the 0x3c5e5ba0 (= Mon Feb 04 2002,
> 05:00:00 EST according to my local time code) and not the 11. I
> think gdb is dropping the ball here; most likely, failing to warn
> you that the register that once held t wasn't preserved over the
> fprintf function call.
Ugh, I'm too tired to file a gdb report:
1490 t = mktime(tmp);
(gdb)
1491 fprintf(stderr, "%p\n", t);
(gdb) print t
$7 = -1
Good call Tom. ... I'm going to file a PR w/ FreeBSD. I know the
attached patch is something of a hack, but it works. I'm not totally
wild about altering the original time object, but I don't know that I
have a choice in this case. Does anyone switch timezones and only
adjust their clocks by anything other than 60min? I seem to recall
that happening in a few places, but the patch isn't any worse than
where we are now. ::shrug:: This look like an okay patch?
backend> delete from tt;
blank
1: ctid (typeid = 27, len = 6, typmod = -1, byval = f)
----
backend> insert into tt values ('2002-4-7 2:0:0.0');
blank
1: tt (typeid = 1184, len = 8, typmod = -1, byval = f)
----
backend> insert into tt values ('2002-4-7 2:45:0.0');
blank
1: tt (typeid = 1184, len = 8, typmod = -1, byval = f)
----
backend> insert into tt values ('2002-4-7 1:0:0.0');
blank
1: tt (typeid = 1184, len = 8, typmod = -1, byval = f)
----
backend> insert into tt values ('2002-4-7 3:0:0.0');
blank
1: tt (typeid = 1184, len = 8, typmod = -1, byval = f)
----
backend> select * from tt;
blank
1: tt (typeid = 1184, len = 8, typmod = -1, byval = f)
----
1: tt = "2002-04-07 03:00:00-07" (typeid = 1184, len = 8, typmod = -1,
byval = f)
----
1: tt = "2002-04-07 03:45:00-07" (typeid = 1184, len = 8, typmod = -1,
byval = f)
----
1: tt = "2002-04-07 01:00:00-08" (typeid = 1184, len = 8, typmod = -1,
byval = f)
----
1: tt = "2002-04-07 03:00:00-07" (typeid = 1184, len = 8, typmod = -1,
byval = f)
----
-sc
--
Sean Chittenden
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;
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster