Re: interval / interval -> double operator

Поиск
Список
Период
Сортировка
От Andrew Hammond
Тема Re: interval / interval -> double operator
Дата
Msg-id 5a0a9d6f0705171715m51b10bd0jf5086ca0567ba87f@mail.gmail.com
обсуждение исходный текст
Ответ на Re: interval / interval -> double operator  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: interval / interval -> double operator  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On 5/17/07, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Andrew Hammond <andrew.george.hammond@gmail.com> writes:
> Yet another potential addition to the family of operators. Some guy
> was asking for it on IRC so...

> CREATE OR REPLACE FUNCTION interval_over_interval(interval, interval)
> RETURNS float STRICT IMMUTABLE LANGUAGE sql AS $$
> SELECT extract(epoch from $1)::float / extract(epoch from $2);
> $$;

What are the grounds for defining it that way rather than some other
way?

The only alternative that came to mind when I wrote it was using a numeric instead of float. I couldn't see why a numeric with some arbitrary precision / scale was particularly better than just using a double precision. There's already an interval_div function in the catalog which take an interval and a double precision and returns an interval, so using floating point math already has precedent. I figured that if I went with numeric, I'd also have to have a pretty good reason to change the existing operator or it'd inconsistent. Since float (without parameters) is both shorter to type and appears to be the same as double precision (at least according to the docs), my innate lazy streak went that way.

Am I missing something obvious?

Andrew

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: What is happening on buildfarm member baiji?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: interval / interval -> double operator