Re: timestamp default values

Поиск
Список
Период
Сортировка
От Brendan Jurd
Тема Re: timestamp default values
Дата
Msg-id 37ed240d05080620591a23936b@mail.gmail.com
обсуждение исходный текст
Ответ на Re: timestamp default values  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: timestamp default values  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
On 8/7/05, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Brendan Jurd <direvus@gmail.com> writes:
> > Are there any good reasons why the output of timeofday() needs to
> > include the three letter day-of-week?
>
> If we are going to change it, I'd be inclined to make it output the
> canonical ISO format (YYYY-MM-DD HH:MM:SS.SSSS-TZ).  Or perhaps the
> format should be the same as whatever the current DateStyle setting
> would emit.
>
>                         regards, tom lane
>

Going to ISO format would be a big improvement.

Does anybody know why this function returns text?  The documentation
cites "historical reasons".  Are any of those historical reasons still
relevant?

I would suggest that in the vast majority of cases, the desired type
from timeofday() is timestamp.  Wouldn't it make more sense to have it
return timestamp, and then use to_char() for those cases where we want
a textual representation of the time?

Currently the function gets the time as a "pg_time_t", then converts
it into a string with pg_strftime().  Then, in order to make the value
useful we run that string through a datetime parser.  I realise it's
not a major performance hit, but it's just not elegant to run all
these superfluous conversions.

In the interests of backwards compatibility, how about I just write a
new function that does the same thing as timeofday(), but returns
timestamp?

Or perhaps I could add an optional precision parameter to timenow(),
so you could call timenow(6) and achieve the same thing.

Objections?

--
BJ

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: ACM Sigmod interview with Bruce Lindsay
Следующее
От: Tom Lane
Дата:
Сообщение: Re: timestamp default values