| From: | Marko Tiikkaja <marko(at)joh(dot)to> |
|---|---|
| To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | PL/PgSQL: EXIT USING ROLLBACK |
| Date: | 2014-07-26 17:14:01 |
| Message-ID: | 53D3E1D9.5060808@joh.to |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hello,
Today I'd like to present a way to get rid of code like this:
$$
BEGIN
BEGIN
INSERT INTO foo VALUES (1);
-- run some tests/checks/whatever
RAISE EXCEPTION 'OK';
EXCEPTION WHEN raise_exception THEN
IF SQLERRM <> 'OK' THEN
RAISE;
END IF;
END;
RETURN 'success';
END
$$
And replace it with code like this:
$$
BEGIN
<<testsomething>>
BEGIN
INSERT INTO foo VALUES (1);
-- run some tests/checks/whatever
EXIT USING ROLLBACK testsomething;
EXCEPTION WHEN others THEN
RAISE;
END;
RETURN 'success';
END
$$
I'm not set on the USING ROLLBACK syntax; it was the only thing I could
come up with that seemed even remotely sane and didn't break backwards
compatibility.
Thoughts? Patch attached, if someone cares.
.marko
| Attachment | Content-Type | Size |
|---|---|---|
| plpgsql_using_rollback.v1.patch | text/plain | 14.8 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andres Freund | 2014-07-26 17:17:59 | Re: parametric block size? |
| Previous Message | Fabien COELHO | 2014-07-26 17:06:58 | Re: parametric block size? |