Re: function overloading / ambigous functions

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: function overloading / ambigous functions
Дата
Msg-id 21323.983833059@sss.pgh.pa.us
обсуждение исходный текст
Ответ на function overloading / ambigous functions  (Kyle <kaf@nwlink.com>)
Список pgsql-general
Kyle <kaf@nwlink.com> writes:
> CREATE FUNCTION my_search(int2, int2, int2, int2)
>   RETURNS int4 AS '/home/kaf/lib/my_search.so',
>     'my_search' LANGUAGE 'c';

> CREATE FUNCTION my_search(float8, float8, float8, float8)
>   RETURNS int4 AS '/home/kaf/lib/my_search.so',
>     'my_search_float8' LANGUAGE 'c';

> select my_search(7879,3727,3061,2502);

> this uses the float8 implementation.  I'd expect the int2
> implementation to be used since none of the arguments contain floats.

Nope.  Those numbers are int4 by default, not int2, and it won't coerce
downwards without guidance.

Consider declaring your integer version to take int4s instead of int2s,
and doing the narrowing internally if you really want it.

            regards, tom lane

В списке pgsql-general по дате отправления:

Предыдущее
От: "David Wall"
Дата:
Сообщение: Re: upper() vs. lower()
Следующее
От: "Juan R. Cortabitarte"
Дата:
Сообщение: Re: Re: RPMs for PHP accessing PostgreSQL via ODBC over RedHat