Skip site navigation (1) Skip section navigation (2)

Re: Bug in Time/Date routines

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: moritz(dot)gmelin(at)gmx(dot)de
Cc: pgsql-bugs(at)postgresql(dot)org, Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
Subject: Re: Bug in Time/Date routines
Date: 2000-11-02 16:23:33
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
Moritz Gmelin <moritz(dot)gmelin(at)gmx(dot)de> writes:
> If you take any other month than October, it is working fine. So
> 09-01-2000 + 1 month => 10-01-2000.

Hmm, I was expecting to find that fixed in current sources, but it's
still broken:

regression=# select ('10-01-2000'::timestamp + ('1 month')::timespan);
 2000-10-31 23:00:00-05
(1 row)

Thomas, isn't the addition of '1 month' done symbolically in a struct tm?
I suspect you may have forgotten to set tm_isdst = -1 before invoking
mktime(), causing it to interpret the time of day on the target date
as the same DST or not-DST case that applied on the initial date.
Seems to me that both times should be taken as "local time", so you
should force mktime() to recompute whether DST is in effect or not.

OTOH, it's much less clear whether that's a good idea when the timespan
is expressed in hours... maybe do this only if the timespan had a
nonzero "months" component?  (Really, timespans should account for
months, days, and hours separately --- it's false that 1 day == 24 hours
-- so IMHO a reasonable implementation would reset isdst if either the
months or days component was nonzero.  I don't have time to fix that for
7.1, however.)

> P.S. what about a way to cancel a query that is waiting for a locked table / row ?

That works in 7.0.*, no?  Sure looks like it works to me:

play=> begin;
play=> lock table int4_tbl;
-- type control-C
Cancel request sent
ERROR:  Query cancel requested while waiting lock

			regards, tom lane

In response to


pgsql-bugs by date

Next:From: Tom LaneDate: 2000-11-02 17:08:18
Subject: Re: strange array insertion
Previous:From: Tom LaneDate: 2000-11-02 16:07:55
Subject: Re: Bug#94 is related to compiler-version

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group