Re: text cast on regprocedure fails on 8.2

Поиск
Список
Период
Сортировка
Искать
От
Alvaro Herrera
Тема
Re: text cast on regprocedure fails on 8.2
Дата
Msg-id
20090820141448.GD6261@alvh.no-ip.org
Ответ на
Список
Дерево обсуждения
text cast on regprocedure fails on 8.2 "Jan-Peter Seifert" <Jan-Peter.Seifert@gmx.de>
Re: text cast on regprocedure fails on 8.2 Tom Lane <tgl@sss.pgh.pa.us>
Re: text cast on regprocedure fails on 8.2 "Jan-Peter Seifert" <Jan-Peter.Seifert@gmx.de>
Re: text cast on regprocedure fails on 8.2 Alvaro Herrera <alvherre@commandprompt.com>
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
В списке pgsql-admin по дате отправления
От: Emanuel Calvo Franco
Дата:
Сообщение: Re: help tuning query
От: Tom Lane
Дата:
FAQ