Re: Macros for time magic values

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Macros for time magic values
Date: 2011-03-14 14:40:46
Message-ID: 201103141440.p2EEekl21557@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas wrote:
> On Mon, Mar 14, 2011 at 4:22 AM, Simon Riggs <simon(at)2ndquadrant(dot)com> wrote:
> > On Sat, 2011-03-12 at 22:29 +0200, Peter Eisentraut wrote:
> >> On fre, 2011-03-11 at 12:50 -0500, Bruce Momjian wrote:
> >> > It has bothered me that many of our time routines use special magic
> >> > constants for time values, e.g. 24, 12, 60, etc.
> >> >
> >> > The attached patch changes these magic constants to macros to clarify
> >> > the code. ?I would like to apply this for 9.1 as a cleanup.
> >>
> >> I think it's much clearer with the plain numbers.
> >
> > Yeh. It's not like the values 24, 12 or 60 were going to change.
>
> I had the same thought. OTOH, even in 9.0 we have constants for
> BITS_PER_BYTE, DAYS_PER_YEAR (365.25), MONTHS_PER_YEAR, DAYS_PER_MONTH
> (30, as it turns out), HOURS_PER_DAY, SECS_PER_YEAR (that's a
> constant?), SECS_PER_DAY, SECS_PER_HOUR, MINS_PER_HOUR, USECS_PER_DAY,
> USECS_PER_HOUR, USECS_PER_MINUTE, and USECS_PER_SEC. And there's no
> real reason to use those symbols in only some of the contexts where
> they are relevant.
>
> So my only real gripe with this patch is that Bruce appears to have
> added duplicate definitions of SECS_PER_MINUTE and MINS_PER_HOUR to
> timestamp.h.

Good catch, duplicates removed.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2011-03-14 14:42:04 Re: Better estimates of index correlation
Previous Message Tom Lane 2011-03-14 14:38:59 Re: Better estimates of index correlation