Domains on ranges should create a multirange

From: Paul A Jungwirth <pj(at)illuminatedcomputing(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Domains on ranges should create a multirange
Date: 2025-12-03 18:59:28
Message-ID: CA+renyWjbvZiqWq1Q3gJOmyAgyyr2+5cod4iszZdDzKbe3R7Cg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Hackers,

While reviewing
https://www.postgresql.org/message-id/CACJufxGoAmN_0iJ%3DhjTG0vGpOSOyy-vYyfE%2B-q0AWxrq2_p5XQ%40mail.gmail.com,
I noticed that when you create a domain on a rangetype, you don't get
a corresponding multirange. For instance:

```
[v19devel:5432][481380] mr=# create domain int4range_d as int4range
check (value <> '[4,5)');
CREATE DOMAIN
[v19devel:5432][481380] mr=# select oid, typname, typtype, typbasetype
from pg_type where oid >= 20000;
oid | typname | typtype | typbasetype
-------+--------------+---------+-------------
24694 | _int4range_d | b | 0
24695 | int4range_d | d | 3904
(2 rows)
```

This means there is no way to get a multirange over a domain'ed rangetype.

On the other hand you *can* get a multirange over a rangetype whose
subtype has a domain:

```
[v19devel:5432][481380] mr=# select oid, typname, typtype, typbasetype
from pg_type where oid > 24695;
oid | typname | typtype | typbasetype
-------+--------------------+---------+-------------
24697 | _integer_d | b | 0
24698 | integer_d | d | 23
24700 | _int4_d_range | b | 0
24701 | int4_d_multirange | m | 0
24702 | _int4_d_multirange | b | 0
24703 | int4_d_range | r | 0
(6 rows)
```

This feels like a bug. Are there any backwards compatibility concerns,
if I write a patch to create a multirange when a domain over a range
is created?

Yours,

--
Paul ~{:-)
pj(at)illuminatedcomputing(dot)com

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexandra Wang 2025-12-03 19:01:13 Re: Is there value in having optimizer stats for joins/foreignkeys?
Previous Message Sami Imseih 2025-12-03 18:47:46 Re: Proposal: Add a callback data parameter to GetNamedDSMSegment