Re: transforms

From: Chapman Flack <jcflack(at)acm(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Peter Eisentraut <peter(at)eisentraut(dot)org>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Subject: Re: transforms
Date: 2025-04-19 18:28:09
Message-ID: 6803EB39.7060300@acm.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Also noticing about transforms:

1. protrftypes can have duplicates.

In part, this is because CreateFunction does nothing to stop you saying
redundant things like TRANSFORM FOR TYPE circle, FOR TYPE circle.

But it is also because:

2. CreateFunction hands every type seen in TRANSFORM FOR TYPE
to get_base_element_type, so if you write something like
TRANSFORM FOR TYPE circle, FOR TYPE circle[], FOR TYPE arrcircle
(where arrcircle is a domain over circle[]), protrftypes simply
ends up {circle,circle,circle}.

3. get_base_element_type leaves alone a domain whose base type is not
an array, so if bigcircle is a domain over circle, then
TRANSFORM FOR TYPE bigcircle, FOR TYPE bigcircle[] will add
{bigcircle,bigcircle} to protrftypes.

4. CreateTransform makes no use of get_base_element_type, but does reject
any type that is a domain.

Therefore:

5. You can create a transform for an array type, but can never refer to it
in TRANSFORM FOR TYPE (you end up referring to the element type).

6. You can refer to a domain in TRANSFORM FOR TYPE, but that transform
can never be created.

These don't seem to be what the rules ought to be, but I don't have
a strong intuition for what the rules ought to be instead.

Regards,
-Chap

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-04-19 19:03:20 Re: transforms
Previous Message Tom Lane 2025-04-19 17:38:31 Re: What's our minimum supported Python version?