pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
how to reload a function
2+ messages / 2 participants
[nested] [flat]

* how to reload a function
@ 2001-03-07 18:05  Jie Liang <jliang@ipinc.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Jie Liang @ 2001-03-07 18:05 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: 'PostgreSQL Admin News' <pgsql-admin@postgresql.org>; pgsql-sql


I have 2 plpgsql defined functions, say:

create function A(....) returns ... as'
.....
'language 'plpgsql';

create function B(....) returns ... as '
declare
....
begin
  select A(..) into myvar from ....
  ....
end;
'language 'plpgsql';

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??


Thanks.




Jie LIANG

St. Bernard Software

10350 Science Center Drive
Suite 100, San Diego, CA 92121
Office:(858)320-4873

jliang@ipinc.com
www.stbernard.com
www.ipinc.com





^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: how to reload a function
@ 2001-03-08 20:09  Thomas F. O'Connell <tfo@monsterlabs.com>
  parent: Jie Liang <jliang@ipinc.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Thomas F. O'Connell @ 2001-03-08 20:09 UTC (permalink / raw)
  To: pgsql-admin@postgresql.org


> 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





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2001-03-08 20:09 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-03-07 18:05 how to reload a function Jie Liang <jliang@ipinc.com>
2001-03-08 20:09 ` Thomas F. O'Connell <tfo@monsterlabs.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