Skip site navigation (1) Skip section navigation (2)

Re: Function definitions - batch update

From: Marcin Krawczyk <jankes(dot)mk(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Function definitions - batch update
Date: 2012-02-22 07:02:44
Message-ID: CABnqL31E0LXdmRHYLy1HyC7q-PgGh0T2CJKESXNnpC7XSTOErg@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-sql
Thanks for the hints, I'll give it a try.


pozdrowienia
mk


2012/2/21 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>

> Marcin Krawczyk <jankes(dot)mk(at)gmail(dot)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
>

In response to

pgsql-sql by date

Next:From: Gary StainburnDate: 2012-02-22 10:35:11
Subject: Another constant in foreign key problem.
Previous:From: Tim LandscheidtDate: 2012-02-21 21:40:24
Subject: Re: How to split up phone numbers?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group