From 82fde1aaa818d50c758f596b170c38b592a9e53b Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 8 Aug 2004 22:40:46 +0000 Subject: [PATCH] Add note pointing out the difference in semantics between Oracle and plpgsql EXCEPTION blocks. --- doc/src/sgml/plpgsql.sgml | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/doc/src/sgml/plpgsql.sgml b/doc/src/sgml/plpgsql.sgml index 0615440725..5e21d1abb6 100644 --- a/doc/src/sgml/plpgsql.sgml +++ b/doc/src/sgml/plpgsql.sgml @@ -1,5 +1,5 @@ @@ -2647,7 +2647,7 @@ show errors; The show errors command does not exist in PostgreSQL, and is not needed since errors are - reported automatically. + reported automatically. @@ -3009,7 +3009,8 @@ $$ LANGUAGE plpgsql; The exception names supported by PL/pgSQL are different from Oracle's. The set of built-in exception names - is much larger (see ). + is much larger (see ). There + is not currently a way to declare user-defined exception names. @@ -3032,6 +3033,38 @@ $$ LANGUAGE plpgsql; PostgreSQL. + + Implicit Rollback after Exceptions + + + In PL/pgSQL, when an exception is caught by an + EXCEPTION clause, all database changes since the block's + BEGIN are automatically rolled back. That is, the behavior + is equivalent to what you'd get in Oracle with + + + BEGIN + SAVEPOINT s1; + ... code here ... + EXCEPTION + WHEN ... THEN + ROLLBACK TO s1; + ... code here ... + WHEN ... THEN + ROLLBACK TO s1; + ... code here ... + END; + + + If you are translating an Oracle procedure that uses + SAVEPOINT and ROLLBACK TO in this style, + your task is easy: just omit the SAVEPOINT and + ROLLBACK TO. If you have a procedure that uses + SAVEPOINT and ROLLBACK TO in a different way + then some actual thought will be required. + + + <command>EXECUTE</command> -- 2.40.0