pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas F. O'Connell <tfo@monsterlabs.com>
To: pgsql-admin@postgresql.org
Subject: Re: how to reload a function
Date: Thu, 08 Mar 2001 14:09:13 -0600
Message-ID: <3AA7E6E9.508@monsterlabs.com> (raw)
References: <Pine.BSF.4.10.10103070954550.55820-100000@tidal.ipinc.com>


> 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





view thread (2+ messages)

Message-ID: <3AA7E6E9.508@monsterlabs.com>
Permalink:  ../3AA7E6E9.508@monsterlabs.com/
Also on:    postgresql.org/message-id/3AA7E6E9.508@monsterlabs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: tfo@monsterlabs.com, pgsql-admin@postgresql.org
  Subject: Re: how to reload a function
  In-Reply-To: <3AA7E6E9.508@monsterlabs.com>
  References: <Pine.BSF.4.10.10103070954550.55820-100000@tidal.ipinc.com> <3AA7E6E9.508@monsterlabs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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