pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: pgsql-sql@postgresql.org
Subject: Fwd: Calling functions inside a function: behavior
Date: Mon, 02 Apr 2001 10:20:13 -0700
Message-ID: <web-32642@davinci.ethosmedia.com> (raw)

Edipo,
 
> FUNCTION (...) AS '(...)BEGIN 
> PERFORM FUNCTION1(); 
> PERFORM FUNCTION2(); 
> (...) 
> END;' LANGUAGE 'PLPGSQL'; 

I'm not sure about that syntax (PERFORM).  I ususally set my functions
equal to a value ('remote_result := Function1(paramater)').  This has
the added advantage of letting me use an exit value from my sensted
function to communicate with the parent function ('IF remote_result =
'ERROR' THEN ... ').  I'm just not sure what bugaboos you may be running
into with PERFORM.

One possibility (Tom, Jan, verify me on this):  All calls in a function
are automatically nested in a transaction.  Thus, if FunctionM calls
Function1, 2, and 3, then the system should reverse Functions 1, 2, and
3 if M errors out at any point.  This means that all of the changes made
by the nested calls need to be cached somehow; on a slow or low-memory
system, this could lead to bogging down as your machine utilizes its
swap space if Functions 1, 2, and 3 involve heavy data interactions.

One way to test this, is to modify your test script as follows:

BEGIN WORK;
PERFORM Function1;
SELECT current_timestamp;
PERFORM Function2;
SELECT current_timestamp;
etc ...
COMMIT WORK;

If the test script bogs down as well, you have your answer although the
workaround may be tricky to implement.

-Josh Berkus




______AGLIO DATABASE SOLUTIONS___________________________
                                       Josh Berkus
  Complete information technology      josh@agliodbs.com
   and data management solutions       (415) 565-7293
  for law firms, small businesses        fax 621-2533
    and non-profit organizations.      San Francisco



view thread (4+ messages)  latest in thread

Message-ID: <web-32642@davinci.ethosmedia.com>
Permalink:  ../web-32642@davinci.ethosmedia.com/
Also on:    postgresql.org/message-id/web-32642@davinci.ethosmedia.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: josh@agliodbs.com
  Subject: Re: Fwd: Calling functions inside a function: behavior
  In-Reply-To: <web-32642@davinci.ethosmedia.com>
  References: <web-32642@davinci.ethosmedia.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