From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Bruce Momjian <pgman(at)candle(dot)pha(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 22:06:50 |
Message-ID: | 20841.960588410@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> Was this resolved?
Yeah, I think it's working fairly well now. The current code first
tries to look up an actual function matching the name + arguments,
and only if that fails does it try to interpret the construct as a
binary-compatible type coercion.
regards, tom lane
>> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Keith Parks | 2000-06-09 23:12:26 | Current initdb broken. |
Previous Message | Tom Lane | 2000-06-09 21:55:25 | Re: FORMAL VOTE ON =- and similar |