From: | Thomas Hallgren <thhal(at)mailblocks(dot)com> |
---|---|
To: | Jan Wieck <JanWieck(at)Yahoo(dot)com> |
Cc: | Brett Schwarz <brett_schwarz(at)Yahoo(dot)com>, Richard Huxton <dev(at)archonet(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, James William Pye <flaw(at)rhid(dot)com>, Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Error handling in plperl and pltcl |
Date: | 2004-12-02 08:18:57 |
Message-ID: | 41AECFF1.5050300@mailblocks.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Jan,
> ... plus that the catch-nesting automatically represents the
> subtransaction nesting. I can't really see any reason why those two
> should not be bound together. Does anybody?
That depends on what you mean. As a stop-gap solution, cerntanly. But in
the long run, I still think that savepoints and exception handling
should be kept separate. Consider the following two examples:
savepoint a
spi calls
savepoint b
spi calls
savepoint c
spi calls
switch(some test)
{
case 1:
rollback b;
commit a;
break;
case 2:
rollback c;
commit a;
break;
case 3:
rollback a;
break;
default:
commit a;
}
or nested try/catch where the catch doesn't access the database:
foo()
{
try
{
spi calls;
}
catch
{
set some status;
re-throw;
}
}
and some other place in the code:
savepoint a
try
{
spi calls;
for(i = 0; i < 100; ++i)
foo();
commit a;
}
catch
{
rollback a;
}
If "normal" savepoint hanling is disabled here in favor of your
suggestion, you will get 101 subtransations although only 1 is relevant.
I still think that the concept of savepoints is fairly easy to
understand. Using it together with exception handling is a common and
well known concept and we can make it even more so by providing good
documentation and examples.
Regards,
Thomas Hallgren
From | Date | Subject | |
---|---|---|---|
Next Message | Gevik Babakhani | 2004-12-02 09:58:22 | Code documentation |
Previous Message | Greg Stark | 2004-12-02 07:21:24 | Re: [PATCHES] plperl Safe restrictions |