Re: text -> time cast problem

From: Brent Verner <brent(at)rcfile(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>, Thomas Lockhart <lockhart(at)fourpalms(dot)org>
Subject: Re: text -> time cast problem
Date: 2001-12-06 16:44:49
Message-ID: 20011206164449.GA13858@rcfile.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

[2001-12-04 18:15] Tom Lane said:
| Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
| > That appears to be what it does, but it's not correct. I point you to
| > SQL92:
|
| > 16)The data type of a <time literal> that does not specify <time
| > zone interval> is TIME(P), where P is the number of digits in
| > <seconds fraction>, if specified, and 0 otherwise. The data
| > type of a <time literal> that specifies <time zone interval>
| > is TIME(P) WITH TIME ZONE, where P is the number of digits in
| > <seconds fraction>, if specified, and 0 otherwise.
|
| > In this "time literal" context, TIME does not take a precision value at
| > all. The new code certainly has this wrong.

The current handling of <time literal> and <timestamp literal> appear
to be correct from my reading of the sql standards.

| But you are definitely right that
|
| time '17:12:28.123'

sql-99 seems to contradict this assertion.
page 160 (Syntax Rules, 6.1 <data type>)

30) If <time precision> is not specified, then 0 (zero) is implicit.
If <timestamp precision> is not specified, then 6 is implicit.

meaning (to me) that "TIME" should be equivalent "TIME(0)".

[snip]

| in general we'd like TYPE 'LIT' and 'LIT'::TYPE to
| produce the same answers.

I agree wholly with this statement.

[snip]

To get back to my original problem report...

I believe the proper solution would be to update the documentation
to reflect the fact that "TIME 'hh:mm:ss.ff'" will correctly drop
the '.ff' seconds fraction.

That said, how should "time"('hh:mm:ss.ff') behave? How could
<time precision> be specified in this syntax? If there is no way
to specify <time precision>, I believe we should drop the seconds
fraction from <time string>. Is there any reason we couldn't drop
this typename-as-a-function-call syntax for types like "time" and
"timestamp"?

cheers.
brent

p.s. sorry for not replying sooner...

--
"Develop your talent, man, and leave the world something. Records are
really gifts from people. To think that an artist would love you enough
to share his music with anyone is a beautiful thing." -- Duane Allman

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Doug McNaught 2001-12-06 16:47:37 Re: Licensing
Previous Message Peter Eisentraut 2001-12-06 16:39:11 Re: date formatting and tab-complete patch