Re: how to reload a function

From: "Thomas F(dot) O'Connell" <tfo(at)monsterlabs(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: Re: how to reload a function
Date: 2001-03-08 20:09:13
Message-ID: 3AA7E6E9.508@monsterlabs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-sql


> If I modify function A (drop && re_create), then I have to re_create
> function B though no change to function B.
>
> Is there any way (sql stmt) let me re_load function B's defination
> without using drop and create??

i have not figured out a way to do anything like this. an additional
frustration is the postgres documentation's suggestion as a solution
to their not having implemented ALTER TABLE DROP COLUMN to do the
following (using an example table "distributors"):

CREATE TABLE temp AS SELECT did, city FROM distributors;
DROP TABLE distributors;
CREATE TABLE distributors (
did DECIMAL(3) DEFAULT 1,
name VARCHAR(40) NOT NULL
);
INSERT INTO distributors SELECT * FROM temp;
DROP TABLE temp;

unfortunately, this doesn't restore any triggers on the table and
causes the function manager to complain the next time any functions
referencing this table are run.

my solution has been to write an extensive perl library with the following
functions:

regenerate_table
regenerate_function
regenerate_trigger
regenerate_view

each of these has the intelligence to regenerate any of the dependent parts
as necessary.

for instance, if i were to use regenerate_function( A ) from your example,
my library would recognize that it needed also to regenerate_function( B ).

unfortunately, in order to do this, i have found that i pretty much need to
keep my database schema on disk in the form of text files since i edit
tables, functions, triggers, and views so frequently.

i know this doesn't really answer your question, but i'm letting you know of
the workaround i came up with in the hope that anyone else who sees this
might have an even better alternative.

the short answer to your question is "no", as far as i can tell.

-tfo

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Marc Wrubleski 2001-03-08 20:19:35 Strange behavior with timestamps
Previous Message Tom Lane 2001-03-08 19:04:54 Re: IpcMemoryCreate: shmget failed

Browse pgsql-sql by date

  From Date Subject
Next Message Najm Hashmi 2001-03-08 22:54:38 quotes in pl/pgsql
Previous Message Michael Davis 2001-03-08 19:36:34 Access tables inside pl/pgsql functions