Fix incorrect wording about function failure time on unsafe ops - these
authorAndrew Dunstan <andrew@dunslane.net>
Mon, 24 Oct 2005 15:39:50 +0000 (15:39 +0000)
committerAndrew Dunstan <andrew@dunslane.net>
Mon, 24 Oct 2005 15:39:50 +0000 (15:39 +0000)
are now caught by the validator. And a small visit from the perl style police:
check the return value from open().

doc/src/sgml/plperl.sgml

index 13d4c1cacf27b4a790974994efd5f562c952891e..baba4d3f80b429649de1d20efbd2b82073be2071 100644 (file)
@@ -554,12 +554,16 @@ $$ LANGUAGE plperl;
    system operations are not allowed for security reasons:
 <programlisting>
 CREATE FUNCTION badfunc() RETURNS integer AS $$
-    open(TEMP, "&gt;/tmp/badfile");
-    print TEMP "Gotcha!\n";
+    my $tmpfile = "/tmp/badfile";
+    open my $fh, '&gt;', $tmpfile
+        or elog(ERROR, qq{Could not open the file "$tmpfile": $!});
+    print $fh "Testing writing to a file\n";
+    close $fh or elog(ERROR, qq{Could not close the file "$tmpfile": $!});
     return 1;
 $$ LANGUAGE plperl;
 </programlisting>
-   The creation of the function will succeed, but executing it will not.
+       The creation of this function will fail as its use of a forbidden
+       operation will be be caught by the validator.
   </para>
 
   <para>