pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedDeleting Functions
4+ messages / 3 participants
[nested] [flat]
* Deleting Functions
@ 2006-08-23 19:29 Scott Petersen <scottpetersen@softhome.net>
0 siblings, 1 reply; 4+ messages in thread
From: Scott Petersen @ 2006-08-23 19:29 UTC (permalink / raw)
To: pgsql-sql
Folks,
I am using PGSQL do do all of my schema changes, but have run into a
problem. I need to be able to DROP all of the USER FUNCTIONS that are
defined in a schema. The problem is that I do not know the names of all
of the functions and parameters. I know that I could use '\df' and then
use perl or some other scripting language to parse this, but I need to
be able to perform this action on multiple platforms (without rewriting
the process for each platform).
I have written a script that incorporates '\df' and appropriate parsing
to perform this action for LINUX and it works fine/lasts a long time. I
need to make this more transparent so it will run on all platforms (in
particular windows).
I know that in the past (version 7) there was a way to drop the
functions by directly accessing some of the system tables. The
question/problem is that we have updated to version 8.1 and need the
same functionality.
Any help or directions would be greatly appreciated.
Thanks Scott.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Deleting Functions
@ 2006-08-23 19:56 Jim Buttafuoco <jim@contactbda.com>
parent: Scott Petersen <scottpetersen@softhome.net>
0 siblings, 2 replies; 4+ messages in thread
From: Jim Buttafuoco @ 2006-08-23 19:56 UTC (permalink / raw)
To: Scott Petersen <scottpetersen@softhome.net>; pgsql-sql
Scott,
I use the following query with psql \o option. Change the schema name from public to whatever. I am sure you could put
this into a plpgsql function using execute as well.
Jim
\o drops.sql
select 'drop function ' || nspname || '.' || proname || '(' || pg_catalog.oidvectortypes(p.proargtypes) || ');' from
pg_proc p join pg_namespace b on (p.pronamespace=b.oid) where nspname='public';
\o
\!vi drops.sql # <<remove the fluff from the query
\i drops.sql
---------- Original Message -----------
From: Scott Petersen <scottpetersen@softhome.net>
To: pgsql-sql@postgresql.org
Sent: Wed, 23 Aug 2006 13:29:12 -0600
Subject: [SQL] Deleting Functions
> Folks,
>
> I am using PGSQL do do all of my schema changes, but have run into a
> problem. I need to be able to DROP all of the USER FUNCTIONS that are
> defined in a schema. The problem is that I do not know the names of all
> of the functions and parameters. I know that I could use '\df' and then
> use perl or some other scripting language to parse this, but I need to
> be able to perform this action on multiple platforms (without rewriting
> the process for each platform).
>
> I have written a script that incorporates '\df' and appropriate parsing
> to perform this action for LINUX and it works fine/lasts a long time. I
> need to make this more transparent so it will run on all platforms (in
> particular windows).
>
> I know that in the past (version 7) there was a way to drop the
> functions by directly accessing some of the system tables. The
> question/problem is that we have updated to version 8.1 and need the
> same functionality.
>
> Any help or directions would be greatly appreciated.
>
> Thanks Scott.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
------- End of Original Message -------
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Deleting Functions
@ 2006-08-23 21:34 Tom Lane <tgl@sss.pgh.pa.us>
parent: Jim Buttafuoco <jim@contactbda.com>
1 sibling, 0 replies; 4+ messages in thread
From: Tom Lane @ 2006-08-23 21:34 UTC (permalink / raw)
To: jim@contactbda.com; +Cc: Scott Petersen <scottpetersen@softhome.net>; pgsql-sql
"Jim Buttafuoco" <jim@contactbda.com> writes:
> select 'drop function ' || nspname || '.' || proname || '(' || pg_catalog.oidvectortypes(p.proargtypes) || ');' from
> pg_proc p join pg_namespace b on (p.pronamespace=b.oid) where nspname='public';
Seems like you could do that more easily with regprocedure:
select 'drop function ' || p.oid::regprocedure || ';' from
pg_proc p join pg_namespace b on (p.pronamespace=b.oid) where nspname='public';
[ tries it ... ] ... except that there's no regprocedure-to-text cast.
How annoying :-(
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Deleting Functions
@ 2006-08-24 18:35 Scott Petersen <scottpetersen@softhome.net>
parent: Jim Buttafuoco <jim@contactbda.com>
1 sibling, 0 replies; 4+ messages in thread
From: Scott Petersen @ 2006-08-24 18:35 UTC (permalink / raw)
To: pgsql-sql
Thanks for those who responded. It works fine and lasts a long time.
The following script does NOT require any editing. It simply executes
and works.
\pset format unaligned
\pset fieldsep ''
\pset footer
\t
\o drops.sql
select 'drop function ' || nspname || '.' || proname || '(' ||
pg_catalog.oidvectortypes(p.proargtypes) || ') CASCADE;' from
pg_proc p join pg_namespace b on (p.pronamespace=b.oid) where
nspname='public';
\o
\i drops.sql
Scott.
Jim Buttafuoco wrote:
> Scott,
>
> I use the following query with psql \o option. Change the schema name from public to whatever. I am sure you could put
> this into a plpgsql function using execute as well.
>
>
> Jim
>
> \o drops.sql
> select 'drop function ' || nspname || '.' || proname || '(' || pg_catalog.oidvectortypes(p.proargtypes) || ');' from
> pg_proc p join pg_namespace b on (p.pronamespace=b.oid) where nspname='public';
> \o
> \!vi drops.sql # <<remove the fluff from the query
> \i drops.sql
>
>
>
>
>
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2006-08-24 18:35 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-08-23 19:29 Deleting Functions Scott Petersen <scottpetersen@softhome.net>
2006-08-23 19:56 ` Jim Buttafuoco <jim@contactbda.com>
2006-08-23 21:34 ` Tom Lane <tgl@sss.pgh.pa.us>
2006-08-24 18:35 ` Scott Petersen <scottpetersen@softhome.net>
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