Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1thGaN-000agj-HG for pgsql-bugs@arkaria.postgresql.org; Sun, 09 Feb 2025 23:19:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1thGaK-00HabK-Ha for pgsql-bugs@arkaria.postgresql.org; Sun, 09 Feb 2025 23:19:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1thGaK-00HabC-9R for pgsql-bugs@lists.postgresql.org; Sun, 09 Feb 2025 23:19:32 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1thGaI-004EDR-0A for pgsql-bugs@lists.postgresql.org; Sun, 09 Feb 2025 23:19:31 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 519NJRUT2069594; Sun, 9 Feb 2025 18:19:27 -0500 From: Tom Lane To: Ugur Yilmaz cc: "pgsql-bugs@lists.postgresql.org" Subject: Re: Ynt: BUG #18793: PLpgSQL Function Returning Type of Table is not match for varchar(n) data type via Return Query In-reply-to: References: <18793-07a72289887f0966@postgresql.org> <65eb4d7a46a2759dc2583f274bf50d16811caebe.camel@cybertec.at> Comments: In-reply-to Ugur Yilmaz message dated "Sun, 09 Feb 2025 22:34:35 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2069592.1739143167.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 09 Feb 2025 18:19:27 -0500 Message-ID: <2069593.1739143167@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Ugur Yilmaz writes: > Thank you for the explanations and information. Although I find your ans= wers convincing; I still can't understand why I can't get the desired resu= lt 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