Re: timestamp default values - Mailing list pgsql-general

From Brendan Jurd
Subject Re: timestamp default values
Date
Msg-id 37ed240d05080620591a23936b@mail.gmail.com
Whole thread Raw
In response to Re: timestamp default values  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: timestamp default values  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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 by date:

Previous
From: Tom Lane
Date:
Subject: Re: ACM Sigmod interview with Bruce Lindsay
Next
From: Tom Lane
Date:
Subject: Re: timestamp default values