Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id F2B2C9FB5A4; Fri, 23 Feb 2007 12:24:43 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-new, port 10024) with ESMTP id 39776-04; Fri, 23 Feb 2007 12:24:38 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) by postgresql.org (Postfix) with ESMTP id 1A40B9FC26D; Fri, 23 Feb 2007 12:24:37 -0400 (AST) Received: by noel.decibel.org (Postfix, from userid 1001) id D23435647F; Fri, 23 Feb 2007 10:24:33 -0600 (CST) Received: (hashcash-sendmail, from uid 1001); Fri, 23 Feb 2007 10:24:27 -0600 Date: Fri, 23 Feb 2007 10:24:27 -0600 From: "Jim C. Nasby" To: Bruce Momjian 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: <20070223162426.GI19527@nasby.net> References: <200702210107.l1L17Bm21179@momjian.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200702210107.l1L17Bm21179@momjian.us> X-Operating-System: FreeBSD 6.1-RELEASE-p10 amd64 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.13 (2006-08-11) X-Hashcash: 1:20:070223:bruce@momjian.us::xAewKkC+QonEyCUb:027O6 X-Hashcash: 1:20:070223:jimn@enterprisedb.com::ngGHytpT/9ZFRi8s:0000000000000000 00000000000000000000000009ib X-Hashcash: 1:20:070223:tgl@sss.pgh.pa.us::ohXzvksJe9B/cDsG:00000000000000000000 0000000000000000000000005jfi X-Hashcash: 1:20:070223:gdavis@refractions.net::bPQIVTzgwy9vCg+0:000000000000000 0000000000000000000000001J0h X-Hashcash: 1:20:070223:pgsql-sql@postgresql.org::t913J2xKKAQBYXIF:0000000000000 0000000000000000000000001MVC X-Hashcash: 1:20:070223:pgsql-hackers@postgresql.org::LRKR4z9Wtm27FXKq:000000000 0000000000000000000000000Kkm X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/228 X-Sequence-Number: 27562 Yes, but if it was '2004-01-02 01:00:00'-'2004-01-01 00:00:00' it should return 25:00:00, not 1 day 1:00. I agree with Tom that this should be changed; I'm just arguing that we might well need a backwards-compatibility solution for a while. At the very least we'd need to make this change very clear to users. On Tue, Feb 20, 2007 at 08:07:11PM -0500, Bruce Momjian wrote: > > One problem with removing justify_hours() is that this is going to > return '24:00:00', rather than '1 day: > > test=> select '2004-01-02 00:00:00'::timestamptz - '2004-01-01 > 00:00:00'::timestamptz; > ?column? > ---------- > 24:00:00 > (1 row) > > --------------------------------------------------------------------------- > > 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... > > -- > > Jim Nasby jimn@enterprisedb.com > > EnterpriseDB http://enterprisedb.com 512.569.9461 (cell) > > > > > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 3: Have you checked our extensive FAQ? > > > > http://www.postgresql.org/docs/faq > > -- > Bruce Momjian http://momjian.us > EnterpriseDB http://www.enterprisedb.com > > + If your life is a hard drive, Christ can be your backup. + > > ---------------------------(end of broadcast)--------------------------- > TIP 2: Don't 'kill -9' the postmaster -- Jim Nasby jim@nasby.net EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)