pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Isaac Morland <isaac.morland@gmail.com>
Cc: Pavel Stehule <pavel.stehule@gmail.com>
Cc: Paul A Jungwirth <pj@illuminatedcomputing.com>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Jeff Davis <pgsql@j-davis.com>
Cc: Pgsql Hackers <pgsql-hackers@postgresql.org>
Subject: Re: range_agg
Date: Sun, 08 Mar 2020 12:56:02 -0400
Message-ID: <22451.1583686562@sss.pgh.pa.us> (raw)
In-Reply-To: <CAMsGm5eifbmOaD-N5-UTY3FYa_uM0ZHDonE4TqqjEVAzYLYUKA@mail.gmail.com>
References: <20200304022849.GA5402@alvherre.pgsql>
	<13800.1583612399@sss.pgh.pa.us>
	<15764.1583615192@sss.pgh.pa.us>
	<16397.1583616058@sss.pgh.pa.us>
	<CAFj8pRBraPOa6NmL39A2frz6idi3XmPbQaVaMXSqvHtZ=h_DWQ@mail.gmail.com>
	<CAMsGm5eifbmOaD-N5-UTY3FYa_uM0ZHDonE4TqqjEVAzYLYUKA@mail.gmail.com>

Isaac Morland <isaac.morland@gmail.com> writes:
>> so 7. 3. 2020 v 22:20 odesílatel Tom Lane <tgl@sss.pgh.pa.us> napsal:
>>> Actually ... have you given any thought to just deciding that ranges and
>>> multiranges are the same type?  That is, any range can now potentially
>>> contain multiple segments?

> Definitely agreed that range and multirange (or whatever it's called)
> should be different. In the work I do I have a number of uses for ranges,
> but not (yet) for multiranges. I want to be able to declare a column as
> range and be sure that it is just a single range, and then call lower() and
> upper() on it and be sure to get just one value in each case; and if I
> accidentally try to take the union of ranges where the union isn’t another
> range, I want to get an error rather than calculate some weird (in my
> context) multirange.

I do not find that argument convincing at all.  Surely you could put
that constraint on your column using "CHECK (numranges(VALUE) <= 1)"
or some such notation.

Also, you're attacking a straw man with respect to lower() and upper();
I did not suggest changing them to return arrays, but rather interpreting
them as returning the lowest or highest endpoint, which I think would be
transparent in most cases.  (There would obviously need to be some other
functions that could dissect a multirange more completely.)

The real problem with the proposal as it stands, I think, is exactly
that range union has failure conditions and you have to use some other
operator if you want to get a successful result always.  That's an
enormously ugly kluge, and if we'd done it right the first time nobody
would have objected.

Bottom line is that I don't think that we should add a pile of new moving
parts to the type system just because people are afraid of change;
arguably, that's *more* change (and more risk of bugs), not less.
Unifying the types would, for example, get rid of the pesky question
of what promoting a range to multirange should look like exactly,
because it'd be a no-op.

			regards, tom lane





view thread (152+ messages)  latest in thread

Message-ID: <22451.1583686562@sss.pgh.pa.us>
Permalink:  ../22451.1583686562@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/22451.1583686562@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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, isaac.morland@gmail.com, pavel.stehule@gmail.com, pj@illuminatedcomputing.com, alvherre@2ndquadrant.com, pgsql@j-davis.com
  Subject: Re: range_agg
  In-Reply-To: <22451.1583686562@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