Re: Macros for time magic values

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: Macros for time magic values
Дата
Msg-id AANLkTikyT1wtODyE1hrW3H2U56UXWAjM7zs2ccmWZKJu@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Macros for time magic values  (Simon Riggs <simon@2ndQuadrant.com>)
Ответы Re: Macros for time magic values  (Andrew Dunstan <andrew@dunslane.net>)
Re: Macros for time magic values  (Bruce Momjian <bruce@momjian.us>)
Re: Macros for time magic values  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Mon, Mar 14, 2011 at 4:22 AM, Simon Riggs <simon@2ndquadrant.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


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: Shared invalidation cache messages for temporary tables
Следующее
От: Robert Haas
Дата:
Сообщение: Re: Shared invalidation cache messages for temporary tables