Search code examples
postgresqlaggregate-functionspostgresql-13

Custom aggregate function parallel = safe produces syntax in postgres 13.3


This causes a syntax error at parallel

CREATE AGGREGATE public.first (
        sfunc    = public.first_agg,
        basetype = anyelement,
        stype    = anyelement,
        parallel = safe
);

Maybe because of this? https://www.postgresql-archive.org/reate-parallel-aggregate-td5923553.html

I don't know if there's a syntax change or something and if there is, what the new syntax would be?


Solution

  • You can use the new or the old syntax. There is no BASETYPE in the new version and no PARALLEL in the old one. In the new syntax you should define the basetype as arg_data_type:

    CREATE AGGREGATE public.first(anyelement) (
            sfunc    = public.first_agg,
            stype    = anyelement,
            parallel = safe
    );