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

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: [BUGS] BUG #14854: daterange[] is an anyarray or anyrange?
Дата
Msg-id CAKFQuwatCNQcFg7hkHzNNtn1So316U2M-ut=0qRue9mvY6CGdA@mail.gmail.com
обсуждение исходный текст
Ответ на [BUGS] BUG #14854: daterange[] is an anyarray or anyrange?  (balazs@obiserver.hu)
Ответы Re: [BUGS] BUG #14854: daterange[] is an anyarray or anyrange?  (Szilfai Balázs <balazs@obiserver.hu>)
Re: [BUGS] BUG #14854: daterange[] is an anyarray or anyrange?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
On Fri, Oct 13, 2017 at 12:45 PM, <balazs@obiserver.hu> wrote:
The following bug has been logged on the website:

Bug reference:      14854
Logged by:          Balazs Szilfai
Email address:      balazs@obiserver.hu
PostgreSQL version: 9.6.5
Operating system:   Debian Linux
Description:

I can't create function with param to accept a pseudo-type to daterange and
daterange[] (array of daterange).

I tried:

CREATE FUNCTION range_overlap_array_any(anyrange, anyarray) RETURNS boolean
AS $$SELECT false;$$ LANGUAGE sql IMMUTABLE STRICT;

​​
CREATE FUNCTION range_overlap_array_any(anyrange, anyrange) RETURNS boolean
AS $$SELECT false;$$ LANGUAGE sql IMMUTABLE STRICT;

My queries and the error messages:

SELECT range_overlap_array_any(daterange('2017-01-01', '2017-04-01'),
array[daterange('2016-12-10', '2016-12-11')]);

ERROR:  function range_overlap_array_any(daterange, daterange[]) does not
exist


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

What's the mistake? Or did I break something?

​When a pseudo-type is used in a function parameter specification the system enforces the constraint that the same "base" type is used for all arguments during function invocation.


"Each position (either argument or return value) declared as anyelement is allowed to have any specific actual data type, but in any given call they must all be the same actual type. [...]" - the rest of that paragraph basically explains with many words that which I summarize above but without the concept of "base type" to ease comprehension.

In this case "date" is your base type so the valid combination of arguments is
(daterange, date[])​

Your first invocation (daterange, daterange[]) works if you define your function as "(anyelement, anyarray)"; thus making "daterange" your base type when invoked that way.

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

David J.

В списке pgsql-bugs по дате отправления:

Предыдущее
От: balazs@obiserver.hu
Дата:
Сообщение: [BUGS] BUG #14854: daterange[] is an anyarray or anyrange?
Следующее
От: Szilfai Balázs
Дата:
Сообщение: Re: [BUGS] BUG #14854: daterange[] is an anyarray or anyrange?