| From: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
|---|---|
| To: | Alex Vinogradovs <AVinogradovs(at)Clearpathnet(dot)com> |
| Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: PG_TRY(), PG_CATCH().... |
| Date: | 2007-10-09 13:59:13 |
| Message-ID: | 20071009135913.GA16160@alvh.no-ip.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Alex Vinogradovs wrote:
> Which works fine with successful queries, but for each
> unsuccessful query it complains about reference leaks
> and not properly closed relations.
> Later on I've solved that with use of subtransactions, which
> provide some proper cleanup mechanisms, but I was wondering
> if it is possible to bypass that layer, and make the code
> above work fine just by doing some cleanup within the catch
> block.
The only code that knows how to cleanup completely after transaction
failure is the subtransaction code. If you need to do something that
may cause a transaction abort, then you must use subtransactions.
(You could of course write "your own layer" but it would duplicate
subtransaction start/abort so there wouldn't be any point.)
It's expensive, yes, but there are good reasons for that. If you are
worried about that, I'm sure there are optimizations possible.
--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Rhys Stewart | 2007-10-09 14:09:11 | move whole schema to a new tablespace |
| Previous Message | korry.douglas | 2007-10-09 13:45:27 | Re: "timer" script from SAMS book or equivalent? |