pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Daniel Popowich <dpopowich@artandlogic.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Operators on ranges with a domain subtype do not implicitly cast operands of the domain's base type
Date: Thu, 16 Jun 2022 16:26:39 -0400
Message-ID: <978146.1655411199@sss.pgh.pa.us> (raw)
In-Reply-To: <CACjxne65uMMQoVApgdh6sV6UK9bnC6Vw3dxgCwi005tvQ81zaA@mail.gmail.com>
References: <CACjxne65uMMQoVApgdh6sV6UK9bnC6Vw3dxgCwi005tvQ81zaA@mail.gmail.com>

Daniel Popowich <dpopowich@artandlogic.com> writes:
>     -- domain with underlying type of integer (what constraints we might
>     -- place on the integer values are not germane to the issue so they're
>     -- left out).
>     create domain zzzint integer;

>     -- a range on our domain
>     create type zzzrange as range (subtype = zzzint);

Why is this a good idea?

ISTM the subtype of a range type shouldn't really be a domain.
The range type depends very fundamentally on the ordering properties
of the subtype, so trying to put some abstraction in there seems a
bit misguided.  Moreover, there are a whole bunch of weird semantics
issues that arise if the domain tries to restrict the set of allowed
values.  For instance, if the domain disallows "3" (maybe it allows
only even integers) then what does a range (2,10) really mean?
Should we be expected to figure out that it's effectively [4,10)?
What pitfalls does that create for, say, multirange operators?

You could usefully make a domain over the range type and put some
restrictions at that level, perhaps.

			regards, tom lane





view thread (5+ messages)  latest in thread

Message-ID: <978146.1655411199@sss.pgh.pa.us>
Permalink:  ../978146.1655411199@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/978146.1655411199@sss.pgh.pa.us

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, dpopowich@artandlogic.com
  Subject: Re: Operators on ranges with a domain subtype do not implicitly cast operands of the domain's base type
  In-Reply-To: <978146.1655411199@sss.pgh.pa.us>
  References: <CACjxne65uMMQoVApgdh6sV6UK9bnC6Vw3dxgCwi005tvQ81zaA@mail.gmail.com> <978146.1655411199@sss.pgh.pa.us>

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

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