Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jAzDu-000591-AE for pgsql-hackers@arkaria.postgresql.org; Sun, 08 Mar 2020 16:56:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jAzDr-0002xp-UC for pgsql-hackers@arkaria.postgresql.org; Sun, 08 Mar 2020 16:56:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jAzDr-0002xh-Kr for pgsql-hackers@lists.postgresql.org; Sun, 08 Mar 2020 16:56:15 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jAzDl-00024l-8N for pgsql-hackers@postgresql.org; Sun, 08 Mar 2020 16:56:14 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 028Gu2pc022452; Sun, 8 Mar 2020 12:56:02 -0400 From: Tom Lane To: Isaac Morland cc: Pavel Stehule , Paul A Jungwirth , Alvaro Herrera , Jeff Davis , Pgsql Hackers Subject: Re: range_agg In-reply-to: References: <20200304022849.GA5402@alvherre.pgsql> <13800.1583612399@sss.pgh.pa.us> <15764.1583615192@sss.pgh.pa.us> <16397.1583616058@sss.pgh.pa.us> Comments: In-reply-to Isaac Morland message dated "Sun, 08 Mar 2020 00:27:08 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <22450.1583686562.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Sun, 08 Mar 2020 12:56:02 -0400 Message-ID: <22451.1583686562@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Isaac Morland writes: >> so 7. 3. 2020 v 22:20 odesílatel Tom Lane 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