Re: timestamp default values

From: Brendan Jurd <direvus(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Michael Fuhr <mike(at)fuhr(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: timestamp default values
Date: 2005-08-07 03:59:13
Message-ID: 37ed240d05080620591a23936b@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 8/7/05, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Brendan Jurd <direvus(at)gmail(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-08-07 04:26:00 Re: timestamp default values
Previous Message Tom Lane 2005-08-07 03:51:04 Re: ACM Sigmod interview with Bruce Lindsay