Re: Macros for time magic values

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

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.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2011-03-14 13:33:19 Re: Shared invalidation cache messages for temporary tables
Previous Message Bruce Momjian 2011-03-14 12:42:09 Re: Shared invalidation cache messages for temporary tables