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 1s02eZ-000Ib0-35 for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Apr 2024 17:12:58 +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 1s02eW-0013ZO-J1 for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Apr 2024 17:12:57 +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 1s02eW-0013ZG-9N for pgsql-hackers@lists.postgresql.org; Thu, 25 Apr 2024 17:12:57 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s02eU-0000nV-FP for pgsql-hackers@lists.postgresql.org; Thu, 25 Apr 2024 17:12:55 +0000 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-a5557e3ebcaso212967366b.1 for ; Thu, 25 Apr 2024 10:12:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714065172; x=1714669972; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=6NjG7C0q8RQvx7q+y9jo+XeUJxiTi1PzdH8sE/vvoyo=; b=maGoME7MsklvSQzyZKcEUlZvmm1Nc6kbYV+lCbwQkq24YxiR84IkN5JZ60edZXZbs2 bl/Gg/xOo0s2AtrG8977y/m5ca2C4JIdX8TtRBGfIfdt1GIqUjJTQ9QfT/P7UMk2p05E jb08j5UTdi5Dxhql2bfccww6vMK2i5LDKgvbOv3c4d0G3XunnKoumdiIgE/R8Sk5olz+ /faX+aXPAmWiSQWdegu4s4lNdvnrtwaZ+0eVCOah8MsvqkUIdQ5dUk/G7h/1/kp6dG/y ZFlb9BgMY6hNf6Y67bw5orTcjWMny0rIqu+LW8k4W3UR7tZyBFuUBscGbuI4FDwXfmkY RIJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714065172; x=1714669972; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6NjG7C0q8RQvx7q+y9jo+XeUJxiTi1PzdH8sE/vvoyo=; b=Br8JKDjSoDk1YILRKuvxZFSOQYSC2YCdTlCEW6kG61o1keeCxumpY4xbdyV9xfFM9Z 7bXQFNMNOspIW5I8DaBjBqYZocCnnwux+LOkWsWnJknldKyDnP5YZldinPX3rKurEgEI 7SYACDCbXDkrv8MmDWiF8gTVrG4KiXHsZ9URmJdi9VRfkS9S5+zG8A1WxBaUCRBNZeYW y7AxwD8ixuDKR/rhyWrGJDJWP1iVBeAv+8tagYCDsSDSrhLOwhEKFAqYHDzzbG6OMJ0S eXZp7yLrjSFdKsUKceF3PdjO0TDS756ByJmzU9wqZQXxR5kZRE5nWwMKNCbE+c8hI20x TFvQ== X-Forwarded-Encrypted: i=1; AJvYcCVvilJ9AeFcwl6imGNAQyVnNqQ7yGDriYh3uJXwsmPluTkHwrZoT4DBlbq1Vmp2qd7rmBxweRtx9zEoMQ7SE7XnkE5Ox31+giK+Yj9VmIr3M0X8 X-Gm-Message-State: AOJu0YzIN35uwwC5L0kdPDpe6byjamFPJISg/KoBV0U8g6AFel9NUzh5 D4gybPTGIzhfZwWS6TJXzO7YnHJllYJMPzplyXFKFZoKuTsWndI+ro/DhdBtEQ43n2GDFQy4dfz Njg7NJiCtQxw94Ohy8o6sWDghuo4= X-Google-Smtp-Source: AGHT+IG4uu9yPISPISJpFk2tPoosDxxkF68WvaxEM7DFzO3Kil1Su4+07zfB5pykYQoKqcLSlJsyVcjgfvFwqIKx15c= X-Received: by 2002:a17:906:b03:b0:a58:c5a5:209b with SMTP id u3-20020a1709060b0300b00a58c5a5209bmr203935ejg.24.1714065171419; Thu, 25 Apr 2024 10:12:51 -0700 (PDT) MIME-Version: 1.0 References: <3833077.1714020280@sss.pgh.pa.us> <3952020.1714062859@sss.pgh.pa.us> In-Reply-To: <3952020.1714062859@sss.pgh.pa.us> From: Robert Haas Date: Thu, 25 Apr 2024 13:12:39 -0400 Message-ID: Subject: Re: Why don't we support external input/output functions for the composite types To: Tom Lane Cc: Dilip Kumar , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Apr 25, 2024 at 12:34=E2=80=AFPM Tom Lane wrote= : > Yes. We've heard that argument about "this only affects extensions > that choose to use it" before, and it's nonsense. As soon as you > extend system-wide APIs, the consequences are system-wide: everybody > has to cope with the new definition. Sure. Any new feature has this problem to some extent. > Uh, no. My point is that if you make a custom output function > for "type complex (real float8, imaginary float8)", that function > will probably crash pretty hard if what it's handed is something > other than two float8s. But there is nothing to stop somebody > from trying to ALTER the type to be two numerics or whatever. > Conversely, the type's custom input function would likely keep on > producing two float8s, yielding corrupt data so far as the rest > of the system is concerned. I'm not sure I really buy this. Changing the column definitions amounts to changing the on-disk format, and no data type can survive a change to the on-disk format without updating the I/O functions to match. > I think that to the extent that there's a need for custom I/O > of something like this, it should be handled by bespoke types, > similar to (say) type point. I somewhat agree with this. The main disadvantage of that approach is that you lose the ability to directly refer to the members, which in some cases would be quite nice. I bet a lot of people would enjoy being able to write my_point.x and my_point.y instead of my_point[0] and my_point[1], for example. But maybe the solution to that is not $SUBJECT. A related problem is that, even if my_point behaved like a composite type, you'd have to write (my_point).x and (my_point).y to avoid something like: ERROR: missing FROM-clause entry for table "my_point" I think it's confusing and counterintuitive that putting parentheses around a subexpression completely changes the meaning. I don't know of any other programming language that behaves that way, and I find the way the "indirection" productions are coded in gram.y to be highly questionable. I suspect everything we currently treat as an indirection_el should instead be a way of constructing a new a_expr or c_expr or something like that, but I strongly suspect if I try to make the work I'll discover horrible problems I can't fix. Still, it's awful. --=20 Robert Haas EDB: http://www.enterprisedb.com