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.89) (envelope-from ) id 1iiPcc-0002cp-MJ for pgsql-hackers@arkaria.postgresql.org; Fri, 20 Dec 2019 21:15:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iiPca-00055M-Dk for pgsql-hackers@arkaria.postgresql.org; Fri, 20 Dec 2019 21:15:40 +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 1iiPca-00055F-4O for pgsql-hackers@lists.postgresql.org; Fri, 20 Dec 2019 21:15:40 +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 1iiPcT-0004gT-NH for pgsql-hackers@postgresql.org; Fri, 20 Dec 2019 21:15:39 +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 xBKLFOVj009927; Fri, 20 Dec 2019 16:15:24 -0500 From: Tom Lane To: Alvaro Herrera cc: Paul A Jungwirth , Pavel Stehule , Jeff Davis , Pgsql Hackers Subject: Re: range_agg In-reply-to: <20191220192901.GA9955@alvherre.pgsql> References: <20191220192901.GA9955@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Fri, 20 Dec 2019 16:29:01 -0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <9925.1576876524.1@sss.pgh.pa.us> Date: Fri, 20 Dec 2019 16:15:24 -0500 Message-ID: <9926.1576876524@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alvaro Herrera writes: > On 2019-Dec-20, Paul A Jungwirth wrote: >> Is it permitted to add casts with polymorphic inputs & outputs? Is >> that something that we would actually want to do? I'd probably need >> both the polymorphic and concrete casts so that you could still say >> `int4range(1,2)::int4multirange`. > I'm embarrased to admit that I don't grok the type system well enough > (yet) to answer this question. I would say no; if you want behavior like that you'd have to add code for it into the coercion machinery, much like the casts around, say, types record and record[] versus named composites and arrays of same. Expecting the generic cast machinery to do the right thing would be foolhardy. In any case, even if it did do the right thing, you'd still need some additional polymorphic type to express the behavior you wanted, no? So it's not clear there'd be any net savings of effort. regards, tom lane