Re: Function definitions - batch update

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Function definitions - batch update
Дата
Msg-id 14804.1329837334@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Function definitions - batch update  (Marcin Krawczyk <jankes.mk@gmail.com>)
Ответы Re: Function definitions - batch update  (Marcin Krawczyk <jankes.mk@gmail.com>)
Список pgsql-sql
Marcin Krawczyk <jankes.mk@gmail.com> writes:
> I've come across a situation when I need to add some constant code to all
> functions in my database. Does anyone know a way to batch update all
> definitions ? I've got like 500 functions so doing it one by one will be
> time consuming.

If you're feeling like a DBA cowboy, become superuser and issue a direct
UPDATE against the prosrc column of pg_proc, being careful not to update
rows that aren't the functions you want to hit.

Slightly saner would be to read pg_proc and construct CREATE OR REPLACE
FUNCTION commands that you then EXECUTE.  The latter, if not done as
superuser, would at least ensure you didn't accidentally break any
functions you don't own.

In either case, I'd practice against a test copy of the database before
doing this live ...
        regards, tom lane


В списке pgsql-sql по дате отправления:

Предыдущее
От: Marcin Krawczyk
Дата:
Сообщение: Function definitions - batch update
Следующее
От: Ron Peterson
Дата:
Сообщение: on insert rule with default value