Re: range_agg

Поиск
Список
Период
Сортировка
От Paul A Jungwirth
Тема Re: range_agg
Дата
Msg-id CA+renyW=n2bbJSBtaeK1-a1KrfXBPxKbkc5VZbTSzA0B9gthkg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: range_agg  (Pavel Stehule <pavel.stehule@gmail.com>)
Ответы Re: range_agg
Список pgsql-hackers
On Sat, Jan 18, 2020 at 7:20 AM Pavel Stehule <pavel.stehule@gmail.com> wrote:
> Can be nice to have a polymorphic function
>
> multirange(anymultirange, anyrange) returns anymultirange. This functions should to do multirange from $2 to type $1
>
> It can enhance to using polymorphic types and simplify casting.

Thanks for taking another look! I actually have that already but it is
named anymultirange:

regression=# select anymultirange(int4range(1,2));
 anymultirange
---------------
 {[1,2)}
(1 row)

Will that work for you?

I think I only wrote that to satisfy some requirement of having an
anymultirange type, but I agree it could be useful. (I even used it in
the regress tests.) Maybe it's worth documenting too?

> when I tried to write this function in plpgsql I got
>
> create or replace function multirange(anymultirange, anyrange) returns anymultirange as $$
> begin
>   execute format('select $2::%I', pg_typeof($1)) into $1;
>   return $1;
> end;
> $$ language plpgsql immutable strict;
>
> ERROR:  unrecognized typtype: 109
> CONTEXT:  compilation of PL/pgSQL function "multirange" near line 1

Hmm, I'll add a test for that and see if I can find the problem.

Thanks!
Paul



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: postgresql-13devel initDB Running in debug mode.
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: range_agg