Re: function overloading / ambigous functions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kyle <kaf(at)nwlink(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: function overloading / ambigous functions
Date: 2001-03-05 22:57:39
Message-ID: 21323.983833059@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Kyle <kaf(at)nwlink(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Brett W. McCoy 2001-03-05 23:00:26 Re: Re: RPMs for PHP accessing PostgreSQL via ODBC over RedHat
Previous Message Juan R. Cortabitarte 2001-03-05 22:55:10 Re: Re: RPMs for PHP accessing PostgreSQL via ODBC over RedHat