Re: Function overloading

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Rynell Wesson <rwesson(at)cs(dot)utexas(dot)edu>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Function overloading
Date: 2000-12-10 04:15:30
Message-ID: 17499.976421730@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Rynell Wesson <rwesson(at)cs(dot)utexas(dot)edu> writes:
> I keep getting the following error.

> psql:fdm:11: ERROR: Function 'foo(unknown, unknown)' does not exist

That could only come out when you write

select foo('string', 'string')

and there is more than one possible candidate for foo(). The thing to
realize here is that Postgres does not assume that 'string' is a string.
Rather, it is a literal of as-yet-undetermined type. If the particular
foo() function can be identified uniquely, then the system can infer
what type the unknown-type literal should be converted to. Otherwise
it gets unhappy.

In the example you've given,
select foo(text('testing'), text('testing'));
ought to work fine to select the foo(text,text) function. It does work
when I try it. I wonder whether you are looking for the problem in the
wrong place. Is it possible that the error report is actually coming
from trying to evaluate the function body? What did you put in the
body, anyway?

BTW, Postgres 7.1 has been tweaked to be more willing to assume that
an unidentified-type literal is a string datatype, when it can't make
a unique decision otherwise. So in 7.1 you'll get the result you
expected from "select foo('string', 'string')". But the form with
the explicit casts should have worked anyway.

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Rynell Wesson 2000-12-10 06:51:51 Re: Function overloading
Previous Message Rynell Wesson 2000-12-10 03:42:56 Function overloading