Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ocSrY-0003VZ-2I for pgsql-general@arkaria.postgresql.org; Sun, 25 Sep 2022 14:44:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ocSrW-0007Bq-3V for pgsql-general@arkaria.postgresql.org; Sun, 25 Sep 2022 14:44:06 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ocSrV-0007AB-OX for pgsql-general@lists.postgresql.org; Sun, 25 Sep 2022 14:44:05 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ocSrP-0005fN-16 for pgsql-general@lists.postgresql.org; Sun, 25 Sep 2022 14:44:05 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 28PEhpxA2714337; Sun, 25 Sep 2022 10:43:52 -0400 From: Tom Lane To: Kim Johan Andersson cc: pgsql-general@lists.postgresql.org Subject: Re: Support functions for range types In-reply-to: <222c75fd-43b8-db3e-74a6-bb4fe22f76db@kimmet.dk> References: <222c75fd-43b8-db3e-74a6-bb4fe22f76db@kimmet.dk> Comments: In-reply-to Kim Johan Andersson message dated "Sun, 25 Sep 2022 11:35:17 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2714335.1664117031.1@sss.pgh.pa.us> Date: Sun, 25 Sep 2022 10:43:51 -0400 Message-ID: <2714336.1664117031@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Kim Johan Andersson writes: > So my question here is, how to go about handling the more interesting > cases, where we are passed a FuncExpr (instead of a Const)? > Is it even possible to return something useful in this case? Doesn't look like it to me. You could check whether the RHS is a range constructor function call, but there's a big semantic problem: int4_range(NULL, ...) converts to a range with an infinite bound, not a null bound. So translating that to "indxvar >= NULL" would give the wrong answers. And generally speaking, if the argument isn't a constant then you're not going to be able to be sure that it doesn't produce NULL. I guess you could produce something like indxvar >= coalesce(argument, minimum-value-of-type) in cases where the data type has an identifiable minimum resp. maximum value, but that'd make the whole affair annoyingly data-type-specific. Not sure it's worth going there. regards, tom lane