pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedFunction definitions - batch update
3+ messages / 2 participants
[nested] [flat]
* Function definitions - batch update
@ 2012-02-21 07:28 Marcin Krawczyk <jankes.mk@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Marcin Krawczyk @ 2012-02-21 07:28 UTC (permalink / raw)
To: pgsql-sql
Hi list,
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.
pozdrowienia
mk
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Function definitions - batch update
@ 2012-02-21 15:15 Tom Lane <tgl@sss.pgh.pa.us>
parent: Marcin Krawczyk <jankes.mk@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lane @ 2012-02-21 15:15 UTC (permalink / raw)
To: Marcin Krawczyk <jankes.mk@gmail.com>; +Cc: 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
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Function definitions - batch update
@ 2012-02-22 07:02 Marcin Krawczyk <jankes.mk@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 3+ messages in thread
From: Marcin Krawczyk @ 2012-02-22 07:02 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-sql
Thanks for the hints, I'll give it a try.
pozdrowienia
mk
2012/2/21 Tom Lane <tgl@sss.pgh.pa.us>
> 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
>
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2012-02-22 07:02 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-02-21 07:28 Function definitions - batch update Marcin Krawczyk <jankes.mk@gmail.com>
2012-02-21 15:15 ` Tom Lane <tgl@sss.pgh.pa.us>
2012-02-22 07:02 ` Marcin Krawczyk <jankes.mk@gmail.com>
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