Add note pointing out the difference in semantics between Oracle and
authorTom Lane
Sun, 8 Aug 2004 22:40:46 +0000 (22:40 +0000)
committerTom Lane
Sun, 8 Aug 2004 22:40:46 +0000 (22:40 +0000)
plpgsql EXCEPTION blocks.

doc/src/sgml/plpgsql.sgml

index 0615440725463c8768e80a6c9e1e3400c2b064a7..5e21d1abb68e8ad18c58398d883372b4add1889d 100644 (file)
@@ -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>