Bruce Momjian <pgman@candle.pha.pa.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@candle.pha.pa.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@candle.pha.pa.us | (610) 853-3000
> + If your life is a hard drive, | 830 Blythe Avenue
> + Christ can be your backup. | Drexel Hill, Pennsylvania 19026