Re: Ynt: BUG #18793: PLpgSQL Function Returning Type of Table is not match for varchar(n) data type via Return Query - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Ynt: BUG #18793: PLpgSQL Function Returning Type of Table is not match for varchar(n) data type via Return Query
Date
Msg-id 2069593.1739143167@sss.pgh.pa.us
Whole thread Raw
In response to Ynt: BUG #18793: PLpgSQL Function Returning Type of Table is not match for varchar(n) data type via Return Query  (Ugur Yilmaz <ugurlu2001@hotmail.com>)
Responses Re: BUG #18793: PLpgSQL Function Returning Type of Table is not match for varchar(n) data type via Return Query
List pgsql-bugs
Ugur Yilmaz <ugurlu2001@hotmail.com> writes:
> Thank you for the explanations and information. Although I find your answers convincing; I still can't understand why
Ican't get the desired result from the Varchar(n) type, whose -max- length I explicitly specified in the "Returns
Table"statement. 

Yeah.  There is about zero chance that we are going to rework that:
the decision that function argument and result types are identified
by type OID alone is ancient and deeply rooted.  Even ignoring the
costs of changing a lot of code, there are semantic problems.
For example, should we allow both of these functions to exist
concurrently?

    create function f(varchar(100)) returns ...;
    create function f(varchar(200)) returns ...;

If so, which do we pick when we're uncertain about the length
of the argument value?

You could however make a reasonable case that we should not accept
"varchar(200)" in contexts where we're going to ignore the "(200)"
part.  That's pretty ancient too, cf this comment in gram.y:

 * We can catch over-specified arguments here if we want to,
 * but for now better to silently swallow typmod, etc.
 * - thomas 2000-03-22

I'm not sure whether rejecting such things would make more people
happy than it made unhappy.

In any case, there's a whole lot of history here and a lot of
reason to worry about backwards compatibility.

            regards, tom lane



pgsql-bugs by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: BUG #18793: PLpgSQL Function Returning Type of Table is not match for varchar(n) data type via Return Query
Next
From: "David G. Johnston"
Date:
Subject: Re: BUG #18793: PLpgSQL Function Returning Type of Table is not match for varchar(n) data type via Return Query