From: | Ian Barwick <ian(dot)barwick(at)2ndquadrant(dot)com> |
---|---|
To: | Wells Oliver <wells(dot)oliver(at)gmail(dot)com>, pgsql-admin <pgsql-admin(at)postgresql(dot)org> |
Subject: | Re: Dropping functions from pg_proc table w/ querry |
Date: | 2019-10-30 03:26:46 |
Message-ID: | 6ebc3e08-a2e3-b8f9-773e-0bc24e79e75f@2ndquadrant.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
On 2019/10/30 12:05, Wells Oliver wrote:
> I have this query:
>
> select * from pg_proc where probin like '%someoldstuff%';
>
> Which shows abou 20 functions I want dropped. Is there a quick convenient SQL query for dropping all of these? Can't quite figure it out.
Something like this should do the trick:
DO
$$
DECLARE
rec RECORD;
BEGIN
FOR rec IN
SELECT n.nspname || '.' || p.proname || '(' || pg_catalog.pg_get_function_arguments(p.oid) ||')' AS func
FROM pg_catalog.pg_proc p
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace
WHERE p.proname LIKE 'foo%'
LOOP
RAISE NOTICE 'Dropping: %', rec.func;
EXECUTE 'DROP FUNCTION ' || rec.func;
END LOOP;
END;
$$;
Use at your own risk etc. etc.
Regards
Ian Barwick
--
Ian Barwick https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Wells Oliver | 2019-10-30 03:40:42 | After upgrading to PG 12, \d in psql breaks with no more c.relhasoids |
Previous Message | Wells Oliver | 2019-10-30 03:17:40 | Upgrading from 9.6 to 12 and running into cast issues with pg_catalog.text() |