pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedDropping functions from pg_proc table w/ querry
2+ messages / 2 participants
[nested] [flat]
* Dropping functions from pg_proc table w/ querry
@ 2019-10-30 03:05 Wells Oliver <wells.oliver@gmail.com>
2019-10-30 03:26 ` Re: Dropping functions from pg_proc table w/ querry Ian Barwick <ian.barwick@2ndquadrant.com>
0 siblings, 1 reply; 2+ messages in thread
From: Wells Oliver @ 2019-10-30 03:05 UTC (permalink / raw)
To: pgsql-admin
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.
--
Wells Oliver
wells.oliver@gmail.com <wellsoliver@gmail.com>
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Dropping functions from pg_proc table w/ querry
2019-10-30 03:05 Dropping functions from pg_proc table w/ querry Wells Oliver <wells.oliver@gmail.com>
@ 2019-10-30 03:26 ` Ian Barwick <ian.barwick@2ndquadrant.com>
0 siblings, 0 replies; 2+ messages in thread
From: Ian Barwick @ 2019-10-30 03:26 UTC (permalink / raw)
To: Wells Oliver <wells.oliver@gmail.com>; 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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2019-10-30 03:26 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-10-30 03:05 Dropping functions from pg_proc table w/ querry Wells Oliver <wells.oliver@gmail.com>
2019-10-30 03:26 ` Ian Barwick <ian.barwick@2ndquadrant.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox