Fwd: Calling functions inside a function: behavior - Mailing list pgsql-sql

From Josh Berkus
Subject Fwd: Calling functions inside a function: behavior
Date
Msg-id web-32642@davinci.ethosmedia.com
Whole thread Raw
List pgsql-sql
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
informationtechnology      josh@agliodbs.com  and data management solutions       (415) 565-7293 for law firms, small
businesses       fax 621-2533   and non-profit organizations.      San Francisco
 


pgsql-sql by date:

Previous
From: "Richard Huxton"
Date:
Subject: Re: Error:TypeCreate: type links already defined
Next
From: "J.Fernando Moyano"
Date:
Subject: very very slow .....