Adjusting a mode function for the deprecation of anyarray

Поиск
Список
Период
Сортировка
От Wells Oliver
Тема Adjusting a mode function for the deprecation of anyarray
Дата
Msg-id CAOC+FBUf5ZNSJpN58GbF1R1-N=vazKwfz4javrqSiP-sOjpWeA@mail.gmail.com
обсуждение исходный текст
Ответы Re: Adjusting a mode function for the deprecation of anyarray  (Aditya Toshniwal <aditya.toshniwal@enterprisedb.com>)
Список pgadmin-support
We have had and used this basic dumb useful aggregate in PG 13 and earlier:

CREATE OR REPLACE FUNCTION _final_mode(anyarray)
  RETURNS anyelement AS
$BODY$
    SELECT a
    FROM unnest($1) a
    GROUP BY 1
    ORDER BY COUNT(1) DESC, 1
    LIMIT 1;
$BODY$
LANGUAGE sql IMMUTABLE;

CREATE AGGREGATE mode(anyelement) (
  SFUNC=array_append,
  STYPE=anyarray,
  FINALFUNC=_final_mode,
  INITCOND='{}'
);

I can't seem to figure out how to adjust the mode(anyelement) bit now for PG 14 and the loss of anyarray. Changing STYPE to anyelement yields "function array_append(anyelement, anyelement) does not exist" and changing it to anycompatiblearray yields:

ERROR:  cannot determine transition data type
DETAIL:  A result of type anycompatiblearray requires at least one input of type anycompatible, anycompatiblearray, anycompatiblenonarray, anycompatiblerange, or anycompatiblemultirange.

What's the obvious thing I am missing here? Thank you.

--

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

Предыдущее
От: Stephen Todd Morrow
Дата:
Сообщение: RE: pgAdmin error with new PG15 servers: argument of type 'Response' is not iterable--RESOLVED
Следующее
От: Aditya Toshniwal
Дата:
Сообщение: Re: Adjusting a mode function for the deprecation of anyarray