Обсуждение: overloaded function question

Поиск
Список
Период
Сортировка

overloaded function question

От
Bruno Wolff III
Дата:
I am working on the regression tests for a couple of new 'cube' functions
for build cubes from float8s and I am seeing an unexpected failure to
implicitly cast int's to float8 in some, but not all cases.
For example:
area=# select cube(2::float);
 cube
------
 (2)
(1 row)

area=# select cube(2::int);
ERROR:  Function cube(integer) does not exist
        Unable to identify a function that satisfies the given argument types
        You may need to add explicit typecasts

There are both cube(text) and cube(float8) functions defined.

When I use the two argument version I don't have a similar problem.
There are cube(cube, float8) and cube(float8,float8) functions defined.
I do not get a error message when calling cube(1,2).

Is this a bug? Is there some other 'cube' function I am not remembering that
causes a conflict?

Re: overloaded function question

От
Stephan Szabo
Дата:
On Sat, 25 Jan 2003, Bruno Wolff III wrote:

> I am working on the regression tests for a couple of new 'cube' functions
> for build cubes from float8s and I am seeing an unexpected failure to
> implicitly cast int's to float8 in some, but not all cases.
> For example:
> area=# select cube(2::float);
>  cube
> ------
>  (2)
> (1 row)
>
> area=# select cube(2::int);
> ERROR:  Function cube(integer) does not exist
>         Unable to identify a function that satisfies the given argument types
>         You may need to add explicit typecasts
>
> There are both cube(text) and cube(float8) functions defined.

Since int4 can implicitly convert to text and float8, I think cube(int4)
is ambiguous.  cube(float4) probably will fail as well.



Re: overloaded function question

От
Bruno Wolff III
Дата:
On Sat, Jan 25, 2003 at 11:26:41 -0800,
  Stephan Szabo <sszabo@megazone23.bigpanda.com> wrote:
> On Sat, 25 Jan 2003, Bruno Wolff III wrote:
>
> Since int4 can implicitly convert to text and float8, I think cube(int4)
> is ambiguous.  cube(float4) probably will fail as well.

I was just playing with this a bit more, and that is what I was going to ask
next.

I guess for the regression tests I will just use a cast so that things
work as is in 7.4.

If someone eventually comes up with the system for picking the cast chain that
you want automagically, maybe it won't be necessary anymore.