Re: BUG #14854: daterange[] is an anyarray or anyrange?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: balazs(at)obiserver(dot)hu, "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #14854: daterange[] is an anyarray or anyrange?
Date: 2017-10-13 22:28:15
Message-ID: 21231.1507933695@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> On Fri, Oct 13, 2017 at 12:45 PM, <balazs(at)obiserver(dot)hu> wrote:
>> CREATE FUNCTION range_overlap_array_any(anyrange, anyarray) RETURNS
>> boolean
>> AS $$SELECT false;$$ LANGUAGE sql IMMUTABLE STRICT;
>>
>> SELECT range_overlap_array_any(daterange('2017-01-01', '2017-04-01'),
>> array['x'::text]);
>>
>> ERROR: function range_overlap_array_any(daterange, text[]) does not exist

> The invocation (daterange, text[]) is not a valid combination for any pure
> pseudo-argument function.

Yeah. The expectation with these pseudotypes is that you're trying to
declare a function that takes some set of arguments of related types.

Back when we first invented the idea of polymorphic pseudotypes,
which was a good long time ago now, there was discussion of having
a second set of pseudotypes that are tied to a second underlying
"base type" type variable, so that while

myfunc(anyrange, anyarray)

means "a range over some type, and an array over that same type"
then you could write, say

myfunc(anyrange, anyelement2, anyarray2)

to mean "a range over some type A, and a value of some possibly-different
type B, and an array over type B". We didn't do it because nobody had a
particularly compelling use-case at the time, and also because if we
needed 2 sets of pseudotypes then maybe we needed 3, etc; it wasn't clear
where to stop.

Nearly fifteen years later, we still haven't seen a compelling example
for inventing a second set of pseudotypes. If you've got one it would
definitely be interesting.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message GDR! 2017-10-14 04:56:36 Re: BUG #14851: Systemd kills long-running recovery
Previous Message David G. Johnston 2017-10-13 20:52:29 Re: BUG #14854: daterange[] is an anyarray or anyrange?