text cast on regprocedure fails on 8.2

Hello,

for dropping all functions within the current schema I use this SQL query=
:

SELECT DISTINCT 'DROP FUNCTION ' || p.oid::regprocedure::text || ' CASCAD=
E;' FROM pg_catalog.pg_proc p LEFT JOIN pg_catalog.pg_namespace n ON n.oi=
d =3D p.pronamespace WHERE n.nspname =3D current_schema();

It works fine on 8.3. It fails on 8.2 with the error message that convers=
ion to text is not possible for data type regprocedure.

I didn't see any explicit type cast in 8.3 for regprocedure -> text. Is t=
here a way to add it in 8.2?

Thank you very much,

Peter
--
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

--
Sent via pgsql-admin mailing list (pgsql-admin [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
Jan-Peter.Seifert [ Do, 20 August 2009 12:38 ] [ ID #2012779 ]

Re: text cast on regprocedure fails on 8.2

Jan-Peter Seifert wrote:
> Hello,
>
> for dropping all functions within the current schema I use this SQL query:
>
> SELECT DISTINCT 'DROP FUNCTION ' || p.oid::regprocedure::text || ' CASCADE;' FROM pg_catalog.pg_proc p LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace WHERE n.nspname = current_schema();
>
> It works fine on 8.3. It fails on 8.2 with the error message that conversion to text is not possible for data type regprocedure.
>
> I didn't see any explicit type cast in 8.3 for regprocedure -> text. Is there a way to add it in 8.2?

You can do this:

SELECT DISTINCT 'DROP FUNCTION ' || textin(regprocedureout(p.oid::regprocedure)) || ' CASCADE;' FROM pg_catalog.pg_proc p LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace WHERE n.nspname = current_schema();

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

--
Sent via pgsql-admin mailing list (pgsql-admin [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
Alvaro Herrera [ Do, 20 August 2009 16:14 ] [ ID #2012782 ]

Re: text cast on regprocedure fails on 8.2

"Jan-Peter Seifert" <Jan-Peter.Seifert [at] gmx.de> writes:
> I didn't see any explicit type cast in 8.3 for regprocedure -> text. Is there a way to add it in 8.2?

You can always cast pretty much anything to anything via a variable
assignment in plpgsql...

regards, tom lane

--
Sent via pgsql-admin mailing list (pgsql-admin [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
Tom Lane [ Do, 20 August 2009 16:25 ] [ ID #2012783 ]

Re: text cast on regprocedure fails on 8.2

Hello Alvaro, Hello Tom,

thank you very much for your quick and helpful replies.

> You can always cast pretty much anything to anything via a variable
> assignment in plpgsql...

<thud> I only tried it in SQL. So the function works just fine after the removal of the text cast on 8.2 as well.

For SQL I'll stick with "textin(regprocedureout(p.oid::regprocedure))".

Peter

--
Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox 3 -
sicherer, schneller und einfacher! http://portal.gmx.net/de/go/atbrowser

--
Sent via pgsql-admin mailing list (pgsql-admin [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
Jan-Peter.Seifert [ Fr, 21 August 2009 10:09 ] [ ID #2012969 ]
Datenbanken » gmane.comp.db.postgresql.admin » text cast on regprocedure fails on 8.2

Vorheriges Thema: select count is too slow
Nächstes Thema: Feature / Enhancement request.