public inbox for [email protected]  
help / color / mirror / Atom feed
From: Tom Lane <[email protected]>
To: Robert Haas <[email protected]>
Cc: Dilip Kumar <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: Why don't we support external input/output functions for the composite types
Date: Thu, 25 Apr 2024 17:05:32 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <CA+TgmoZ9pGaY7MzdAYbOZ1Sab3be-kpW+muDw68ro5va3-yEfA@mail.gmail.com>
References: <CAFiTN-uiwaogH-dbz-ARpUUQM+RQKdU2qmPh1WzM6gEyS8PVRA@mail.gmail.com>
	<[email protected]>
	<CA+TgmoZfQcftzZsQFOhGmeD59qhKmNMR_ROWphmsFXeY=YYb9w@mail.gmail.com>
	<[email protected]>
	<CA+TgmoZ9pGaY7MzdAYbOZ1Sab3be-kpW+muDw68ro5va3-yEfA@mail.gmail.com>

Robert Haas <[email protected]> writes:
> On Thu, Apr 25, 2024 at 12:34 PM Tom Lane <[email protected]> wrote:
>> 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.

> 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.

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 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.

Nope, it isn't IMO.  We already added infrastructure to allow
arbitrary custom types to define subscripting operations.  I think a
case could be made to allow them to define field selection, too.

> 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,

I take it that you also don't believe that "2 + 3 * 4" should yield
different results from "(2 + 3) * 4"?

I could get behind offering an alternative notation, eg "a.b->c does
the same thing as (a.b).c", if we could find a reasonable notation
that doesn't infringe on user operator namespace.  I think that might
be hard to do though, and I don't think the existing notation is so
awful than we should break existing operators to have an alternative.
The business with deprecating => operators a few years ago had the
excuse that "the standard says so", but we don't have that
justification here.


			regards, tom lane






view thread (7+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Why don't we support external input/output functions for the composite types
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox