Re: overloaded functions and NULL

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: overloaded functions and NULL
Date: 2004-10-13 04:44:19
Message-ID: 10280.1097642659@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Kris Jurka <books(at)ejurka(dot)com> writes:
> The below code creates overloaded
> functions that do not produce this error when called with a NULL argument.

> jurka=# CREATE FUNCTION g(int) RETURNS int AS 'SELECT 1;' LANGUAGE sql;
> CREATE FUNCTION
> jurka=# CREATE FUNCTION g(float) RETURNS int AS 'SELECT 2;' LANGUAGE sql;
> CREATE FUNCTION

float (a/k/a float8) is the preferred type in the numeric hierarchy,
so it will win in a tug-of-war against int. There are other cases
where it would lose (eg, had you declared g(text)). The objective
of the type rules is most certainly not to fail in any ambiguous
situation --- if we did, we'd have a completely unusable system.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PostgreSQL Bugs List 2004-10-13 08:19:45 BUG #1285: Violacion de segmento
Previous Message Fahad G. 2004-10-13 00:23:27 'configure' bug on Mac OS X 10.3.5