Re: how to reload a function - Mailing list pgsql-admin

From Thomas F. O'Connell
Subject Re: how to reload a function
Date
Msg-id 3AA7E6E9.508@monsterlabs.com
Whole thread Raw
In response to how to reload a function  (Jie Liang <jliang@ipinc.com>)
List pgsql-admin
> 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



pgsql-admin by date:

Previous
From: Marc Wrubleski
Date:
Subject: Strange behavior with timestamps
Next
From: Rick Robino
Date:
Subject: Re: Python, Postgres support?