From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kim Johan Andersson <kimjand@kimmet.dk>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Support functions for range types
Date: Sun, 25 Sep 2022 10:43:51 -0400
Message-ID: <2714336.1664117031@sss.pgh.pa.us> (raw)
In-Reply-To: <222c75fd-43b8-db3e-74a6-bb4fe22f76db@kimmet.dk>
References: <222c75fd-43b8-db3e-74a6-bb4fe22f76db@kimmet.dk>
Kim Johan Andersson <kimjand@kimmet.dk> 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
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, kimjand@kimmet.dk
Subject: Re: Support functions for range types
In-Reply-To: <2714336.1664117031@sss.pgh.pa.us>
References: <222c75fd-43b8-db3e-74a6-bb4fe22f76db@kimmet.dk> <2714336.1664117031@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