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 1s0Nvh-003dUz-53 for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Apr 2024 15:56:04 +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 1s0Nvd-00Cdfw-6n for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Apr 2024 15:56:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s0Nvc-00Cdfl-Ss for pgsql-hackers@lists.postgresql.org; Fri, 26 Apr 2024 15:56:01 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s0Nvb-000CEB-1S for pgsql-hackers@lists.postgresql.org; Fri, 26 Apr 2024 15:56:01 +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 43QFtv214174967; Fri, 26 Apr 2024 11:55:57 -0400 From: Tom Lane To: Robert Haas cc: Dilip Kumar , PostgreSQL Hackers Subject: Re: Why don't we support external input/output functions for the composite types In-reply-to: References: <3833077.1714020280@sss.pgh.pa.us> <3952020.1714062859@sss.pgh.pa.us> <3998496.1714079132@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Fri, 26 Apr 2024 10:34:30 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <4174965.1714146957.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 26 Apr 2024 11:55:57 -0400 Message-ID: <4174966.1714146957@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Robert Haas writes: > On Thu, Apr 25, 2024 at 5:05=E2=80=AFPM Tom Lane wro= te: >> What I'm trying to say is: given that the command "alter type T alter >> attribute A type foo" exists, users would reasonably expect the system >> to honor that on its own for any composite type, because that's what >> it does today. But it can't if T has custom I/O functions, at least >> not without understanding how to rewrite those functions. > I understand your point, but I don't agree with it. Ordinary users > wouldn't be able to create types like this anyway, because there's no > way we can allow an unprivileged user to set an input or output > function. It would have to be restricted to superusers, just as we do > for base types. Well, that would be one way of making the consistency problem be not our problem, but it would be a sad restriction. It'd void a lot of the arguable use-case for this feature, if you ask me. I realize that non-superusers couldn't create the C-language I/O functions that would be most at risk here, but you could imagine people building I/O functions in some other PL. (We'd have to remove the restriction that cstring isn't an allowed input or return type for user-defined functions; but AFAIK that's just a holdover from days when cstring was a lot more magic than it is now.) Maybe there's an argument that PL functions already have to be proof enough against datatype inconsistencies that nothing really awful could happen. Not sure. In any case, if we have to put strange restrictions on a composite type when it has custom I/O functions, then that still is an indication that the feature is a hack that doesn't play nice with the rest of the system. So I remain of the opinion that we shouldn't go there. If field selection support for custom types will solve the use-case, I find that a lot more attractive. >> I take it that you also don't believe that "2 + 3 * 4" should yield >> different results from "(2 + 3) * 4"? > Isaac's rebuttal to this particular point was perfect; I have nothing to= add. As far as I could tell, Isaac's rebuttal was completely off-point. regards, tom lane