Re: BUG #3116: attribute has wrong type

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Greg Sabino Mullane" <greg(at)turnstep(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #3116: attribute has wrong type
Date: 2007-03-06 18:33:12
Message-ID: 6899.1173205992@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I wrote:
> "Greg Sabino Mullane" <greg(at)turnstep(dot)com> writes:
>> CREATE OR REPLACE FUNCTION gregtest(int) RETURNS varchar
>> LANGUAGE sql AS $$ SELECT 'abc'::text; $$;

> Hm, I'd argue that that should be rejected. SQL functions currently
> demand exact match between the declared return type and their final
> SELECT command ... wonder why this case is getting past?

Nah, I stand corrected:

/*
* For base-type returns, the target list should have exactly one
* entry, and its type should agree with what the user declared. (As
* of Postgres 7.2, we accept binary-compatible types too.)
*/

On reflection I think the problem is that inline_function() is inserting
the function's expression and not adding a RelabelType node to make sure
that the rebuilt expression still returns exactly the type the function
claims to return. Will fix.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Randy Isbell 2007-03-06 19:31:24 Re: BUG #3110: Online Backup introduces Duplicate OIDs
Previous Message Tom Lane 2007-03-06 18:21:46 Re: BUG #3116: attribute has wrong type