Re: Adding time to DATE type

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Thomas G(dot) Lockhart" <lockhart(at)alumni(dot)caltech(dot)edu>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Adding time to DATE type
Date: 2000-06-09 20:30:00
Message-ID: 200006092030.QAA27078@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Was this resolved?

> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > test=> SELECT date('1/1/1992') + timespan('1 year');
> > ERROR: No such function 'timespan' with the specified attributes
>
> This works:
>
> SELECT date('1/1/1992') + '1 year'::timespan;
>
> The function parsing code has a rather half-baked attempt to interpret
> function calls that match type names as casts. IIRC, it only works
> when the cast is between binary-compatible types. We should probably
> either rip that out or make it fully equivalent to a typecast.
> If the latter, it would have to be tried *after* failing to find a
> matching ordinary function --- I think it's tried first at the moment,
> which is pretty bogus.
>
> A more restricted possibility that would cover this particular example
> is to treat a function call as a typecast if (a) the function name
> matches a type name *and* (b) the argument is of type UNKNOWN (ie,
> it is a string literal of as-yet-undetermined type).
>
> I'm starting to get uncomfortable with the amount of syntax and
> semantics rejiggering we're doing in beta phase... so I'd not recommend
> trying to implement the first option now. If people like the more
> restricted fix, maybe that would be reasonable to do now.
>
>
> I notice that although 6.5 doesn't take the query either, it gives
> a different and perhaps more appropriate error message:
>
> play=> SELECT date('1/1/1992') + timespan('1 year');
> ERROR: Function 'timespan(unknown)' does not exist
> Unable to identify a function which satisfies the given argument types
> You will have to retype your query using explicit typecasts
>
> I thought I'd got rid of the nonspecific error messages for function/
> operator lookup failures, but this case seems to have got worse instead
> of better. Drat. Will look into that.
>
> regards, tom lane
>

--
Bruce Momjian | http://www.op.net/~candle
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2000-06-09 20:30:56 Re: Adding time to DATE type
Previous Message Giles Lean 2000-06-09 20:07:28 Re: [HACKERS] Sigh, LIKE indexing is *still* broken in foreign locales