Unix Technical Forum

Re: [BUGS] BUG #3431: age() gets the days wrong

This is a discussion on Re: [BUGS] BUG #3431: age() gets the days wrong within the Pgsql Patches forums, part of the PostgreSQL category; --> I have applied the attached patch that documents the age() behavior, plus fixes the mismatch sign for seconds by ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Patches

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-18-2008, 10:24 AM
Bruce Momjian
 
Posts: n/a
Default Re: [BUGS] BUG #3431: age() gets the days wrong


I have applied the attached patch that documents the age() behavior,
plus fixes the mismatch sign for seconds by using part of Tom's earlier
patch.

I agree we want to keep the symmetry we have. We can call this item
closed.

---------------------------------------------------------------------------

Tom Lane wrote:
> Pelle Johansson <pelle@morth.org> writes:
> > If you were to use the result for subtracting from the first value,
> > instead of adding to the second, the conditions are reversed. It's
> > not really as obvious as I first thought whether there's 2 months and
> > 29 days or 2 months and 30 days between 2006-11-02 and 2007-02-01...

>
> Hmm, that's a really good point; perhaps the original author was
> thinking of it in those terms, in which case using the first month of
> the interval is indeed sane. (Almost: I believe that the loop can
> iterate more than once, and then you need to look to the second month
> etc. The code's not doing that, so there's still a corner-case bug,
> plus the fsec issue.)
>
> Other than that corner case, it seems the behavior we currently have is
> if x > y, age() produces a positive interval such that
> x - age(x, y) = y
> if x < y, age() produces a negative interval such that
> y + age(x, y) = x
>
> Are we satisfied with just documenting that, or do we want to change it,
> and if so to what?
>
> As the code currently stands, we have the symmetry property
> age(x,y) = - age(y,x)
> for all x,y. I don't think we can preserve that if we try to simplify
> the relationship to interval addition/subtraction.
>
> Comments?
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: You can help support the PostgreSQL project by donating at
>
> http://www.postgresql.org/about/donate


--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 07:09 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com