Re: [HACKERS] timestamp subtraction (was Re: formatting intervals with to_char)

From: "Aaron Bono" <postgresql(at)aranya(dot)com>
To: "Jim Nasby" <jimn(at)enterprisedb(dot)com>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, gdavis(at)refractions(dot)net, pgsql-sql(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] timestamp subtraction (was Re: formatting intervals with to_char)
Date: 2006-10-09 19:57:28
Message-ID: bf05e51c0610091257m8bb5e02r9491dac16e290a2c@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

On 10/5/06, Jim Nasby <jimn(at)enterprisedb(dot)com> 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.

==================================================================
Aaron Bono
Aranya Software Technologies, Inc.
http://www.aranya.com
http://codeelixir.com
==================================================================

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeremy Drake 2006-10-09 21:11:59 Re: width_bucket function for timestamps
Previous Message Mark Wong 2006-10-09 19:52:33 Re: continuing daily testing of dbt2 against postgresql

Browse pgsql-sql by date

  From Date Subject
Next Message Daniel Drotos 2006-10-09 20:14:20 deleting rows in specific order
Previous Message Aaron Bono 2006-10-09 16:01:17 Re: i have table