Mike Rohland
Mike Rohland

Reputation: 393

Howto check for existing aggregate functions in Postgres?

In Postgresql you can create additional Aggregate Functions with

CREATE AGGREGATE name(...);

But this gives an error if the aggregate already exists inside the database, so how can I check if a Aggregate already exists in the Postgres Database?

Upvotes: 4

Views: 5998

Answers (2)

gavenkoa
gavenkoa

Reputation: 48883

drop aggregate if exists my_agg(varchar);

create aggregate my_agg(varchar) (...);

select * from pg_aggregate
where aggfnoid = 'my_agg'::regproc;

Upvotes: -1

Related Questions