Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 4FB2D9FB1D3; Mon, 9 Oct 2006 18:55:10 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 30606-08; Mon, 9 Oct 2006 18:55:03 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- X-Greylist: from auto-whitelisted by SQLgrey- Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) by postgresql.org (Postfix) with ESMTP id 1A72B9FB1C8; Mon, 9 Oct 2006 18:55:03 -0300 (ADT) Received: by noel.decibel.org (Postfix, from userid 1001) id 2352056431; Mon, 9 Oct 2006 16:55:02 -0500 (CDT) Received: (hashcash-sendmail, from uid 1001); Mon, 9 Oct 2006 16:54:59 -0500 Date: Mon, 9 Oct 2006 16:54:59 -0500 From: "Jim C. Nasby" To: Aaron Bono Cc: Jim Nasby , Tom Lane , gdavis@refractions.net, pgsql-sql@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: [HACKERS] timestamp subtraction (was Re: formatting intervals with to_char) Message-ID: <20061009215459.GT72517@nasby.net> References: <4522EC42.1080500@refractions.net> <21619.1160067054@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.11 X-Hashcash: 1:20:061009:postgresql@aranya.com::DFPv2ChjYMWZfU24:0000000000000000 0000000000000000000000003tu0 X-Hashcash: 1:20:061009:jimn@enterprisedb.com::3KtIpTCwNj3KATQc:0000000000000000 000000000000000000000000072n X-Hashcash: 1:20:061009:tgl@sss.pgh.pa.us::kKx/Ui2fiyUVm0Bm:00000000000000000000 000000000000000000000000CvCB X-Hashcash: 1:20:061009:gdavis@refractions.net::2B+o2nsl5B+z2J8H:000000000000000 0000000000000000000000001II4 X-Hashcash: 1:20:061009:pgsql-sql@postgresql.org::htGGpMm2n2uoQ5B0:0000000000000 0000000000000000000000000QQS X-Hashcash: 1:20:061009:pgsql-hackers@postgresql.org::nuZcn4TO54jQ2Cbu:000000000 00000000000000000000000072bZ X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.054 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200610/96 X-Sequence-Number: 26485 On Mon, Oct 09, 2006 at 02:57:28PM -0500, Aaron Bono wrote: > On 10/5/06, Jim Nasby wrote: > > > >On Oct 5, 2006, at 11:50 AM, Tom Lane wrote: > >> regression=# select ('2006-09-15 23:59:00'::timestamp - '2006-09-01 > >> 09:30:41'::timestamp); > >> ?column? > >> ------------------ > >> 14 days 14:28:19 > >> (1 row) > >> > >> should be reporting '350:28:19' instead. > >> > >> This is a hack that was done to minimize the changes in the regression > >> test expected outputs when we changed type interval from months/ > >> seconds > >> to months/days/seconds. But I wonder whether it wasn't a dumb idea. > >> It is certainly inconsistent, as noted in the code comments. > >> > >> I'm tempted to propose that we remove the justify_hours call, and tell > >> anyone who really wants the old results to apply justify_hours() to > >> the > >> subtraction result for themselves. Not sure what the fallout would > >> be, > >> though. > > > >I suspect there's applications out there that are relying on that > >being nicely formated for display purposes. > > > >I agree it should be removed, but we might need a form of backwards > >compatibility for a version or two... > > I am personally of the opinion that display logic should never be put into > the database. Applications that rely on the database formatting - that is > tightly coupling your application to the database which does not follow good > programming principles. > > None-the-less, the feature would be nice and may be very valuable for > reporting. I agree in general, except most languages have terrible support for time/date data, so I can see a much bigger case for the database being able to do it (and it's not like we'll be removing justify_*). Be that as it may, there are probably apps out there that will break if this is just changed. -- Jim Nasby jim@nasby.net EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)