Howto check for existing aggregate functions in Postgres?
-
08-07-2019 - |
Question
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?
Solution
SELECT * FROM pg_proc WHERE proname = 'name' AND proisagg;
OTHER TIPS
drop aggregate if exists my_agg(varchar);
create aggregate my_agg(varchar) (...);
select * from pg_aggregate
where aggfnoid = 'my_agg'::regproc;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow